mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-29 22:19:39 +08:00
Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 26cf72189c | |||
| b020f1676a | |||
| 02938b5d5b | |||
| 7b7a48a834 | |||
| faf49f689d | |||
| 882a6c06e0 | |||
| b21dd9fb92 | |||
| b07e4f2bc6 | |||
| a3130e30ff | |||
| f095ed68a8 | |||
| ddcd285075 | |||
| 6994538d87 | |||
| 92e3abe752 | |||
| 2b6bd5a532 | |||
| b4cc5f88ca | |||
| db4339f698 | |||
| 0535783f46 | |||
| 99004a3ccd | |||
| e1a3b92567 | |||
| 8f9456229a | |||
| 5b602c0232 | |||
| 26c502914c | |||
| a158960c20 | |||
| 5228335f15 | |||
| 21f964a0dc | |||
| 6133313a83 | |||
| 6db095ec82 | |||
| 5a08a9bb43 | |||
| f9d92135a0 | |||
| 8779c96c3a | |||
| 4c6cff1116 | |||
| 82ab181861 | |||
| 007bf6fa73 | |||
| 8e1e89c024 | |||
| 2764aaab3f | |||
| 7b950166d7 | |||
| eb1195e59a | |||
| e13cb28267 | |||
| 956da769a3 | |||
| d7bd814fb9 | |||
| 96fde5764f | |||
| 7a108c6f87 | |||
| eb252af7b3 | |||
| 8e5a0bfb19 | |||
| d991e32b15 | |||
| 93829e3242 |
Binary file not shown.
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 345 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 227 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 104 KiB |
@@ -231,6 +231,11 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Download build artifacts
|
- name: Download build artifacts
|
||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
@@ -258,6 +263,61 @@ jobs:
|
|||||||
tar -czf "release-assets/sharpemu-${VERSION}-linux-x64.tar.gz" -C "${linux_dir}" .
|
tar -czf "release-assets/sharpemu-${VERSION}-linux-x64.tar.gz" -C "${linux_dir}" .
|
||||||
tar -czf "release-assets/sharpemu-${VERSION}-osx-x64.tar.gz" -C "${macos_dir}" .
|
tar -czf "release-assets/sharpemu-${VERSION}-osx-x64.tar.gz" -C "${macos_dir}" .
|
||||||
|
|
||||||
|
- name: Build release notes
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
MAX_COMMITS: 200
|
||||||
|
RELEASE_TAG: ${{ needs.init.outputs.release-tag }}
|
||||||
|
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
|
||||||
|
SHORT_SHA: ${{ needs.init.outputs.short-sha }}
|
||||||
|
VERSION: ${{ needs.init.outputs.version }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
previous_tag="$(git describe --tags --abbrev=0 --match 'v*' "${RELEASE_TAG}^" 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [ -n "${previous_tag}" ]; then
|
||||||
|
range="${previous_tag}..${RELEASE_TAG}"
|
||||||
|
else
|
||||||
|
range="${RELEASE_TAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
git log --no-merges --reverse --pretty=tformat:"%H%x1f%h%x1f%s" "${range}" > commits.txt
|
||||||
|
total="$(wc -l < commits.txt)"
|
||||||
|
|
||||||
|
{
|
||||||
|
printf 'Automated SharpEmu v%s build for commit [`%s`](%s/commit/%s).\n\n' \
|
||||||
|
"${VERSION}" "${SHORT_SHA}" "${REPO_URL}" "${GITHUB_SHA}"
|
||||||
|
|
||||||
|
if [ -n "${previous_tag}" ]; then
|
||||||
|
printf '## Changes since %s\n\n' "${previous_tag}"
|
||||||
|
else
|
||||||
|
printf '## Changes\n\n'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${total}" -eq 0 ]; then
|
||||||
|
printf '_No commits since %s._\n' "${previous_tag}"
|
||||||
|
else
|
||||||
|
head -n "${MAX_COMMITS}" commits.txt | while IFS=$'\x1f' read -r sha short subject; do
|
||||||
|
printf -- '- %s ([`%s`](%s/commit/%s))\n' "${subject}" "${short}" "${REPO_URL}" "${sha}"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "${total}" -gt "${MAX_COMMITS}" ]; then
|
||||||
|
printf '\n_…and %s more commits._\n' "$((total - MAX_COMMITS))"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '\n'
|
||||||
|
|
||||||
|
if [ -n "${previous_tag}" ]; then
|
||||||
|
printf '**Full changelog**: %s/compare/%s...%s\n' "${REPO_URL}" "${previous_tag}" "${RELEASE_TAG}"
|
||||||
|
else
|
||||||
|
printf '**Full changelog**: %s/commits/%s\n' "${REPO_URL}" "${RELEASE_TAG}"
|
||||||
|
fi
|
||||||
|
} > release-notes.md
|
||||||
|
|
||||||
|
cat release-notes.md
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
@@ -265,7 +325,6 @@ jobs:
|
|||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
RELEASE_NAME: ${{ needs.init.outputs.release-name }}
|
RELEASE_NAME: ${{ needs.init.outputs.release-name }}
|
||||||
RELEASE_TAG: ${{ needs.init.outputs.release-tag }}
|
RELEASE_TAG: ${{ needs.init.outputs.release-tag }}
|
||||||
VERSION: ${{ needs.init.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
mapfile -t assets < <(find release-assets -maxdepth 1 -type f \( -name '*.zip' -o -name '*.tar.gz' \) | sort)
|
mapfile -t assets < <(find release-assets -maxdepth 1 -type f \( -name '*.zip' -o -name '*.tar.gz' \) | sort)
|
||||||
if [ "${#assets[@]}" -ne 3 ]; then
|
if [ "${#assets[@]}" -ne 3 ]; then
|
||||||
@@ -273,8 +332,6 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
notes="Automated SharpEmu v${VERSION} build for commit ${GITHUB_SHA}."
|
|
||||||
|
|
||||||
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
|
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
|
||||||
echo "Release ${RELEASE_TAG} already exists and will not be modified." >&2
|
echo "Release ${RELEASE_TAG} already exists and will not be modified." >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -283,4 +340,4 @@ jobs:
|
|||||||
gh release create "${RELEASE_TAG}" "${assets[@]}" \
|
gh release create "${RELEASE_TAG}" "${assets[@]}" \
|
||||||
--verify-tag \
|
--verify-tag \
|
||||||
--title "${RELEASE_NAME}" \
|
--title "${RELEASE_NAME}" \
|
||||||
--notes "${notes}"
|
--notes-file release-notes.md
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<SharpEmuVersion>0.0.2-beta.4</SharpEmuVersion>
|
<SharpEmuVersion>0.0.3-hotfix-2</SharpEmuVersion>
|
||||||
<Version>$(SharpEmuVersion)</Version>
|
<Version>$(SharpEmuVersion)</Version>
|
||||||
|
|
||||||
<RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)'))</RepoRoot>
|
<RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)'))</RepoRoot>
|
||||||
|
|||||||
@@ -7,23 +7,23 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageVersion Include="Avalonia" Version="11.3.18" />
|
<PackageVersion Include="Avalonia" Version="12.1.0" />
|
||||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.18" />
|
<PackageVersion Include="Avalonia.Desktop" Version="12.1.0" />
|
||||||
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.3.18" />
|
<PackageVersion Include="Avalonia.Fonts.Inter" Version="12.1.0" />
|
||||||
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.3.18" />
|
<PackageVersion Include="Avalonia.Themes.Fluent" Version="12.1.0" />
|
||||||
<PackageVersion Include="FFmpeg.AutoGen" Version="7.1.1" />
|
<PackageVersion Include="FFmpeg.AutoGen" Version="7.1.1" />
|
||||||
<PackageVersion Include="Iced" Version="1.21.0" />
|
<PackageVersion Include="Iced" Version="1.21.0" />
|
||||||
<PackageVersion Include="Microsoft.Build.Framework" Version="17.14.8" />
|
<PackageVersion Include="Microsoft.Build.Framework" Version="17.14.8" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
|
||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||||
<PackageVersion Include="Silk.NET.Input" Version="2.23.0" />
|
<PackageVersion Include="NLayer" Version="1.14.0" />
|
||||||
|
<PackageVersion Include="ppy.SDL3-CS" Version="2026.629.0" />
|
||||||
<PackageVersion Include="Silk.NET.Vulkan" Version="2.23.0" />
|
<PackageVersion Include="Silk.NET.Vulkan" Version="2.23.0" />
|
||||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.23.0" />
|
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.23.0" />
|
||||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.23.0" />
|
<PackageVersion Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.23.0" />
|
||||||
<PackageVersion Include="Silk.NET.Windowing" Version="2.23.0" />
|
<!-- Transitive of Avalonia.Desktop; pinned. Avalonia 12 requires 0.94.1+. -->
|
||||||
<!-- Transitive of Avalonia.Desktop; pinned to fix GHSA-xrw6-gwf8-vvr9 -->
|
<PackageVersion Include="Tmds.DBus.Protocol" Version="0.94.1" />
|
||||||
<PackageVersion Include="Tmds.DBus.Protocol" Version="0.21.3" />
|
|
||||||
<PackageVersion Include="xunit" Version="2.9.3" />
|
<PackageVersion Include="xunit" Version="2.9.3" />
|
||||||
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
|
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -13,14 +13,12 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
An experimental PlayStation 5 emulator for Windows, Linux and macOS.
|
An experimental PlayStation 5 emulator for Windows, Linux and macOS.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
---
|
||||||
<a href="https://discord.gg/6GejPEDqpc">
|
|
||||||
<img src="https://img.shields.io/badge/Discord-Join%20our%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord">
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<strong>Join our Discord for development updates, compatibility discussions, support, and community chat.</strong>
|
<a href="#support">
|
||||||
|
<img src="https://img.shields.io/badge/Support-GitHub%20Sponsors%20%26%20Crypto-EA4AAA?style=for-the-badge&logo=githubsponsors&logoColor=white" alt="Support SharpEmu">
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -136,6 +134,18 @@ Provided valuable references for filesystem handling and low-level C# implementa
|
|||||||
|
|
||||||
- [**GPL-2.0 license**](https://github.com/sharpemu/sharpemu/blob/main/LICENSE)
|
- [**GPL-2.0 license**](https://github.com/sharpemu/sharpemu/blob/main/LICENSE)
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Support SharpEmu via GitHub Sponsors or cryptocurrency. Every contribution helps fund ongoing development and long-term maintenance. GitHub Sponsors is the preferred way to support the project, but cryptocurrency donations are also appreciated.
|
||||||
|
|
||||||
|
### ETH/USDT
|
||||||
|
|
||||||
|
`0xF315F5d986c790bB3A58DbE60F1B2760997dEd82`
|
||||||
|
|
||||||
|
### BTC
|
||||||
|
|
||||||
|
`bc1qmr9k8899njys5ny63xsues4jgmkk96erslrkmv`
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Before opening an issue or pull request, please read our contribution guidelines:
|
Before opening an issue or pull request, please read our contribution guidelines:
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ SPDX-FileCopyrightText = "SharpEmu Emulator Project"
|
|||||||
SPDX-License-Identifier = "GPL-2.0-or-later"
|
SPDX-License-Identifier = "GPL-2.0-or-later"
|
||||||
|
|
||||||
[[annotations]]
|
[[annotations]]
|
||||||
path = "src/SharpEmu.GUI/Atrac9/**"
|
path = "src/SharpEmu.LibAtrac9/**"
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "2018 Alex Barney"
|
SPDX-FileCopyrightText = "2018 Alex Barney"
|
||||||
SPDX-License-Identifier = "MIT"
|
SPDX-License-Identifier = "MIT"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
|
|
||||||
<Solution>
|
<Solution>
|
||||||
<Folder Name="/src/">
|
<Folder Name="/src/">
|
||||||
|
<Project Path="src/SharpEmu.LibAtrac9/SharpEmu.LibAtrac9.csproj" />
|
||||||
<Project Path="src/SharpEmu.CLI/SharpEmu.CLI.csproj" />
|
<Project Path="src/SharpEmu.CLI/SharpEmu.CLI.csproj" />
|
||||||
<Project Path="src/SharpEmu.Core/SharpEmu.Core.csproj" />
|
<Project Path="src/SharpEmu.Core/SharpEmu.Core.csproj" />
|
||||||
<Project Path="src/SharpEmu.DebugClient/SharpEmu.DebugClient.csproj" />
|
<Project Path="src/SharpEmu.DebugClient/SharpEmu.DebugClient.csproj" />
|
||||||
@@ -21,6 +22,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<Folder Name="/tests/">
|
<Folder Name="/tests/">
|
||||||
<Project Path="tests/SharpEmu.Libs.Tests/SharpEmu.Libs.Tests.csproj" />
|
<Project Path="tests/SharpEmu.Libs.Tests/SharpEmu.Libs.Tests.csproj" />
|
||||||
<Project Path="tests/SharpEmu.ShaderCompiler.Metal.Tests/SharpEmu.ShaderCompiler.Metal.Tests.csproj" />
|
<Project Path="tests/SharpEmu.ShaderCompiler.Metal.Tests/SharpEmu.ShaderCompiler.Metal.Tests.csproj" />
|
||||||
|
<Project Path="tests/SharpEmu.ShaderCompiler.Tests/SharpEmu.ShaderCompiler.Tests.csproj" />
|
||||||
<Project Path="tests/SharpEmu.SourceGenerators.Tests/SharpEmu.SourceGenerators.Tests.csproj" />
|
<Project Path="tests/SharpEmu.SourceGenerators.Tests/SharpEmu.SourceGenerators.Tests.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
</Solution>
|
</Solution>
|
||||||
|
|||||||
@@ -153133,6 +153133,7 @@ scePsmlMfsrGetContextBufferRequirement800M3_2
|
|||||||
scePsmlMfsrGetDispatchMfsrPacket1000
|
scePsmlMfsrGetDispatchMfsrPacket1000
|
||||||
scePsmlMfsrGetDispatchMfsrPacket1100
|
scePsmlMfsrGetDispatchMfsrPacket1100
|
||||||
scePsmlMfsrGetDispatchMfsrPacketSizeInDwords
|
scePsmlMfsrGetDispatchMfsrPacketSizeInDwords
|
||||||
|
scePsmlMfsrGetDispatchMfsrPacket900
|
||||||
scePsmlMfsrGetMipmapBias
|
scePsmlMfsrGetMipmapBias
|
||||||
scePsmlMfsrGetSharedResourcesInitRequirement
|
scePsmlMfsrGetSharedResourcesInitRequirement
|
||||||
scePsmlMfsrInit
|
scePsmlMfsrInit
|
||||||
|
|||||||
@@ -157,6 +157,62 @@ def ensure_tag_does_not_exist(
|
|||||||
raise ReleaseError(f"Tag {tag} already exists on {remote}.")
|
raise ReleaseError(f"Tag {tag} already exists on {remote}.")
|
||||||
|
|
||||||
|
|
||||||
|
def get_previous_tag(repository_root: Path) -> str:
|
||||||
|
try:
|
||||||
|
return run_git(
|
||||||
|
"describe",
|
||||||
|
"--tags",
|
||||||
|
"--abbrev=0",
|
||||||
|
"--match",
|
||||||
|
"v*",
|
||||||
|
"HEAD",
|
||||||
|
cwd=repository_root,
|
||||||
|
capture_output=True,
|
||||||
|
)
|
||||||
|
except ReleaseError:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def get_release_commits(
|
||||||
|
repository_root: Path,
|
||||||
|
previous_tag: str,
|
||||||
|
) -> list[str]:
|
||||||
|
revision_range = f"{previous_tag}..HEAD" if previous_tag else "HEAD"
|
||||||
|
|
||||||
|
output = run_git(
|
||||||
|
"log",
|
||||||
|
"--no-merges",
|
||||||
|
"--reverse",
|
||||||
|
"--pretty=tformat:%h %s",
|
||||||
|
revision_range,
|
||||||
|
cwd=repository_root,
|
||||||
|
capture_output=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
return output.splitlines()
|
||||||
|
|
||||||
|
|
||||||
|
def print_release_notes_preview(repository_root: Path) -> None:
|
||||||
|
previous_tag = get_previous_tag(repository_root)
|
||||||
|
commits = get_release_commits(repository_root, previous_tag)
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
if previous_tag:
|
||||||
|
print(f"Commits since {previous_tag} ({len(commits)}):")
|
||||||
|
else:
|
||||||
|
print(f"Commits in this release ({len(commits)}):")
|
||||||
|
|
||||||
|
if not commits:
|
||||||
|
print(" (none)")
|
||||||
|
|
||||||
|
for commit in commits:
|
||||||
|
print(f" {commit}")
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("These commits go into the generated release notes.")
|
||||||
|
|
||||||
|
|
||||||
def read_version(props_path: Path) -> str:
|
def read_version(props_path: Path) -> str:
|
||||||
if not props_path.exists():
|
if not props_path.exists():
|
||||||
raise ReleaseError(f"Version file not found: {props_path}")
|
raise ReleaseError(f"Version file not found: {props_path}")
|
||||||
@@ -323,6 +379,8 @@ def create_release_tag(
|
|||||||
remote,
|
remote,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print_release_notes_preview(repository_root)
|
||||||
|
|
||||||
run_git(
|
run_git(
|
||||||
"tag",
|
"tag",
|
||||||
"-a",
|
"-a",
|
||||||
|
|||||||
+270
-98
@@ -8,6 +8,7 @@ using SharpEmu.HLE;
|
|||||||
using SharpEmu.Libs.VideoOut;
|
using SharpEmu.Libs.VideoOut;
|
||||||
using SharpEmu.Logging;
|
using SharpEmu.Logging;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Loader;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
@@ -45,6 +46,8 @@ internal static partial class Program
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
private static int Main(string[] args)
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
|
ConfigureManagedPluginResolution();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Run(args);
|
return Run(args);
|
||||||
@@ -56,6 +59,25 @@ internal static partial class Program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ConfigureManagedPluginResolution()
|
||||||
|
{
|
||||||
|
AssemblyLoadContext.Default.Resolving += static (loadContext, assemblyName) =>
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(assemblyName.Name))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var assemblyPath = Path.Combine(
|
||||||
|
AppContext.BaseDirectory,
|
||||||
|
"plugins",
|
||||||
|
assemblyName.Name + ".dll");
|
||||||
|
return File.Exists(assemblyPath)
|
||||||
|
? loadContext.LoadFromAssemblyPath(assemblyPath)
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private static int Run(string[] args)
|
private static int Run(string[] args)
|
||||||
{
|
{
|
||||||
if (Updater.TryApply(args, out var updateExitCode))
|
if (Updater.TryApply(args, out var updateExitCode))
|
||||||
@@ -64,7 +86,6 @@ internal static partial class Program
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = NormalizeInternalArguments(args, out var isMitigatedChild);
|
args = NormalizeInternalArguments(args, out var isMitigatedChild);
|
||||||
PreloadGlfw();
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
if (args.Length == 0)
|
||||||
{
|
{
|
||||||
@@ -93,14 +114,9 @@ internal static partial class Program
|
|||||||
PreloadMacVulkanLoader();
|
PreloadMacVulkanLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLFW requires window creation and event processing on the
|
// SDL/AppKit window work belongs on the process main thread on
|
||||||
// process main thread: AppKit demands it on macOS, and X11 has a
|
// macOS. Linux uses the same model for consistent X11/Wayland
|
||||||
// single event queue that must be serviced from the main thread
|
// event ownership. Emulation remains on a worker thread.
|
||||||
// (a window created and polled off it may never map, which showed
|
|
||||||
// as a running game with no visible window on Linux). Emulation
|
|
||||||
// moves to a worker thread and the main thread services the window
|
|
||||||
// work the video presenter posts. Windows keeps a per-thread event
|
|
||||||
// queue, so its window stays on the presenter's own thread.
|
|
||||||
var exitCode = 0;
|
var exitCode = 0;
|
||||||
HostMainThread.Enable();
|
HostMainThread.Enable();
|
||||||
var emulation = new Thread(() =>
|
var emulation = new Thread(() =>
|
||||||
@@ -131,10 +147,9 @@ internal static partial class Program
|
|||||||
/// starts: the CPU backend executes guest x86-64 code natively, so the
|
/// starts: the CPU backend executes guest x86-64 code natively, so the
|
||||||
/// host process must be x86-64 — win-x64/linux-x64 on x64 hardware, or
|
/// host process must be x86-64 — win-x64/linux-x64 on x64 hardware, or
|
||||||
/// osx-x64 under Rosetta 2 on Apple Silicon (Rosetta translates the
|
/// osx-x64 under Rosetta 2 on Apple Silicon (Rosetta translates the
|
||||||
/// whole process, so it still reports as X64 here). An arm64 process
|
/// whole process, so it still reports as X64 here). Failing up front on
|
||||||
/// (e.g. the osx-arm64 build) can browse the GUI but cannot run games;
|
/// any other process architecture distinguishes that from MoltenVK,
|
||||||
/// failing up front distinguishes that from MoltenVK, signal-handler,
|
/// signal-handler, or guest-memory startup problems.
|
||||||
/// or guest-memory startup problems.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool CheckHostArchitecture()
|
private static bool CheckHostArchitecture()
|
||||||
{
|
{
|
||||||
@@ -178,11 +193,11 @@ internal static partial class Program
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Makes a Vulkan loader visible to GLFW's dlopen("libvulkan.1.dylib").
|
/// Makes a Vulkan loader visible before SDL creates its Vulkan surface.
|
||||||
/// Homebrew's Vulkan libraries are arm64-only and cannot load into this
|
/// Homebrew's Vulkan libraries are arm64-only and cannot load into this
|
||||||
/// x86-64 (Rosetta 2) process, so a universal libMoltenVK.dylib placed
|
/// x86-64 (Rosetta 2) process, so a universal libMoltenVK.dylib placed
|
||||||
/// next to the executable (named libvulkan.1.dylib) is preloaded here;
|
/// next to the executable (named libvulkan.1.dylib) is preloaded here;
|
||||||
/// dyld then resolves GLFW's bare-name dlopen to the loaded image.
|
/// dyld can then resolve the loader for SDL and Silk.NET.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void PreloadMacVulkanLoader()
|
private static void PreloadMacVulkanLoader()
|
||||||
{
|
{
|
||||||
@@ -214,27 +229,6 @@ internal static partial class Program
|
|||||||
"as libvulkan.1.dylib.");
|
"as libvulkan.1.dylib.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SharpEmu.CLI.csproj publishes glfw into a "plugins" subfolder rather
|
|
||||||
/// than flat next to the executable, which falls outside the default OS
|
|
||||||
/// DLL/dlopen search path. Preloading it here by full path first means
|
|
||||||
/// any later bare-name lookup (however Silk.NET/GLFW itself resolves the
|
|
||||||
/// library) finds it already loaded in the process and reuses it -- the
|
|
||||||
/// same technique <see cref="PreloadMacVulkanLoader"/> already relies on
|
|
||||||
/// for the Vulkan loader.
|
|
||||||
/// </summary>
|
|
||||||
private static void PreloadGlfw()
|
|
||||||
{
|
|
||||||
var fileName = OperatingSystem.IsWindows() ? "glfw3.dll"
|
|
||||||
: OperatingSystem.IsMacOS() ? "libglfw.3.dylib"
|
|
||||||
: "libglfw.so.3";
|
|
||||||
var candidate = Path.Combine(AppContext.BaseDirectory, "plugins", fileName);
|
|
||||||
if (File.Exists(candidate))
|
|
||||||
{
|
|
||||||
NativeLibrary.TryLoad(candidate, out _);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int RunEmulator(string[] args, bool isMitigatedChild)
|
private static int RunEmulator(string[] args, bool isMitigatedChild)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"[DEBUG] SharpEmu starting with {args.Length} args");
|
Console.Error.WriteLine($"[DEBUG] SharpEmu starting with {args.Length} args");
|
||||||
@@ -244,17 +238,13 @@ internal static partial class Program
|
|||||||
return childExitCode;
|
return childExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TryExtractHostSurfaceArgument(args, out var emulatorArgs, out var hostSurface, out var hostSurfaceError))
|
if (!TryParseArguments(
|
||||||
{
|
args,
|
||||||
Console.Error.WriteLine($"[LOADER][ERROR] {hostSurfaceError}");
|
out var ebootPath,
|
||||||
return 1;
|
out var runtimeOptions,
|
||||||
}
|
out var videoOptions,
|
||||||
|
out var logLevel,
|
||||||
HostSessionControl.SetEmbeddedHostSurface(
|
out var logFilePath))
|
||||||
hostSurface?.WindowHandle ?? 0,
|
|
||||||
hostSurface?.DisplayHandle ?? 0);
|
|
||||||
|
|
||||||
if (!TryParseArguments(emulatorArgs, out var ebootPath, out var runtimeOptions, out var logLevel, out var logFilePath))
|
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return 1;
|
return 1;
|
||||||
@@ -266,6 +256,11 @@ internal static partial class Program
|
|||||||
}
|
}
|
||||||
|
|
||||||
SharpEmuLog.MinimumLevel = logLevel;
|
SharpEmuLog.MinimumLevel = logLevel;
|
||||||
|
if (!HostVideoHost.TryConfigureVideo(videoOptions))
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("[LOADER][ERROR] Video options cannot change while a presenter is active.");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
Log.Info(BuildInfo.Banner);
|
Log.Info(BuildInfo.Banner);
|
||||||
Log.Info(HostSystemInfo.Summary);
|
Log.Info(HostSystemInfo.Summary);
|
||||||
@@ -309,12 +304,6 @@ internal static partial class Program
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (hostSurface is not null && !VulkanVideoHost.TryAttachSurface(hostSurface))
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("[LOADER][ERROR] The requested GUI host surface is already active.");
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var runtime = SharpEmuRuntime.CreateDefault(runtimeOptions);
|
using var runtime = SharpEmuRuntime.CreateDefault(runtimeOptions);
|
||||||
|
|
||||||
OrbisGen2Result result;
|
OrbisGen2Result result;
|
||||||
@@ -384,53 +373,9 @@ internal static partial class Program
|
|||||||
debugHost.DisposeAsync().AsTask().GetAwaiter().GetResult();
|
debugHost.DisposeAsync().AsTask().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
HostSessionControl.SetEmbeddedHostSurface(0);
|
|
||||||
if (hostSurface is not null)
|
|
||||||
{
|
|
||||||
VulkanVideoHost.RequestClose();
|
|
||||||
VulkanVideoHost.DetachSurface(hostSurface);
|
|
||||||
hostSurface.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryExtractHostSurfaceArgument(
|
|
||||||
IReadOnlyList<string> args,
|
|
||||||
out string[] emulatorArgs,
|
|
||||||
out VulkanHostSurface? hostSurface,
|
|
||||||
out string? error)
|
|
||||||
{
|
|
||||||
const string hostSurfacePrefix = "--host-surface=";
|
|
||||||
var remaining = new List<string>(args.Count);
|
|
||||||
hostSurface = null;
|
|
||||||
error = null;
|
|
||||||
foreach (var argument in args)
|
|
||||||
{
|
|
||||||
if (!argument.StartsWith(hostSurfacePrefix, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
remaining.Add(argument);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostSurface is not null)
|
|
||||||
{
|
|
||||||
emulatorArgs = [];
|
|
||||||
error = "more than one GUI host surface was specified";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var descriptor = argument[hostSurfacePrefix.Length..];
|
|
||||||
if (!VulkanHostSurface.TryCreateChildProcessSurface(descriptor, out hostSurface, out error))
|
|
||||||
{
|
|
||||||
emulatorArgs = [];
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emulatorArgs = remaining.ToArray();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void EnsureCliConsole()
|
private static void EnsureCliConsole()
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsWindows())
|
if (!OperatingSystem.IsWindows())
|
||||||
@@ -1042,7 +987,7 @@ internal static partial class Program
|
|||||||
|
|
||||||
private static void PrintUsage()
|
private static void PrintUsage()
|
||||||
{
|
{
|
||||||
Log.Info("Usage: SharpEmu.CLI [--strict] [--trace-imports[=N]] [--cpu-engine=<native>] [--log-level=<level>] [--log-file[=<path>]] [--debug-server[=host:port]] <path-to-eboot.bin>");
|
Log.Info("Usage: SharpEmu.CLI [--strict] [--trace-imports[=N]] [--cpu-engine=<native>] [--log-level=<level>] [--log-file[=<path>]] [--window-mode=<windowed|borderless|exclusive>] [--resolution=<WIDTHxHEIGHT>] [--display=<N>] [--refresh-rate=<HZ>] [--scaling=<fit|cover|stretch|integer>] [--vsync=<on|off>] [--hdr=<auto|on|off>] [--debug-server[=host:port]] <path-to-eboot.bin>");
|
||||||
Log.Info(@"Example: SharpEmu.CLI --cpu-engine=native --trace-imports=64 --log-level=debug --log-file ""E:\Games\...\eboot.bin""");
|
Log.Info(@"Example: SharpEmu.CLI --cpu-engine=native --trace-imports=64 --log-level=debug --log-file ""E:\Games\...\eboot.bin""");
|
||||||
Log.Info("Debug server: --debug-server starts a live debug listener (default 127.0.0.1:5714); connect with SharpEmu.DebugClient.");
|
Log.Info("Debug server: --debug-server starts a live debug listener (default 127.0.0.1:5714); connect with SharpEmu.DebugClient.");
|
||||||
}
|
}
|
||||||
@@ -1087,6 +1032,7 @@ internal static partial class Program
|
|||||||
string[] args,
|
string[] args,
|
||||||
out string ebootPath,
|
out string ebootPath,
|
||||||
out SharpEmuRuntimeOptions runtimeOptions,
|
out SharpEmuRuntimeOptions runtimeOptions,
|
||||||
|
out HostVideoOptions videoOptions,
|
||||||
out LogLevel logLevel,
|
out LogLevel logLevel,
|
||||||
out string? logFilePath)
|
out string? logFilePath)
|
||||||
{
|
{
|
||||||
@@ -1094,6 +1040,7 @@ internal static partial class Program
|
|||||||
{
|
{
|
||||||
ebootPath = string.Empty;
|
ebootPath = string.Empty;
|
||||||
runtimeOptions = default;
|
runtimeOptions = default;
|
||||||
|
videoOptions = HostVideoOptions.Default;
|
||||||
logLevel = SharpEmuLog.MinimumLevel;
|
logLevel = SharpEmuLog.MinimumLevel;
|
||||||
logFilePath = null;
|
logFilePath = null;
|
||||||
return false;
|
return false;
|
||||||
@@ -1102,12 +1049,99 @@ internal static partial class Program
|
|||||||
var strictDynlibResolution = false;
|
var strictDynlibResolution = false;
|
||||||
var importTraceLimit = 0;
|
var importTraceLimit = 0;
|
||||||
var cpuEngine = CpuExecutionEngine.NativeOnly;
|
var cpuEngine = CpuExecutionEngine.NativeOnly;
|
||||||
|
HostWindowMode? windowModeOverride = null;
|
||||||
|
HostScalingMode? scalingModeOverride = null;
|
||||||
|
int? windowWidthOverride = null;
|
||||||
|
int? windowHeightOverride = null;
|
||||||
|
int? displayIndexOverride = null;
|
||||||
|
int? refreshRateOverride = null;
|
||||||
|
bool? vsyncOverride = null;
|
||||||
|
HostHdrMode? hdrModeOverride = null;
|
||||||
|
videoOptions = HostVideoOptions.Default;
|
||||||
logFilePath = null;
|
logFilePath = null;
|
||||||
logLevel = SharpEmuLog.MinimumLevel;
|
logLevel = SharpEmuLog.MinimumLevel;
|
||||||
var pathTokens = new List<string>(args.Length);
|
var pathTokens = new List<string>(args.Length);
|
||||||
for (var i = 0; i < args.Length; i++)
|
for (var i = 0; i < args.Length; i++)
|
||||||
{
|
{
|
||||||
var argument = args[i];
|
var argument = args[i];
|
||||||
|
if (TrySplitOption(argument, "--window-mode", out var windowModeText))
|
||||||
|
{
|
||||||
|
if (!TryParseWindowMode(windowModeText, out var windowMode))
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
windowModeOverride = windowMode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TrySplitOption(argument, "--resolution", out var resolutionText))
|
||||||
|
{
|
||||||
|
if (!TryParseResolution(resolutionText, out var windowWidth, out var windowHeight))
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
windowWidthOverride = windowWidth;
|
||||||
|
windowHeightOverride = windowHeight;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TrySplitOption(argument, "--display", out var displayText))
|
||||||
|
{
|
||||||
|
if (!int.TryParse(displayText, out var displayIndex) || displayIndex < 0)
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
displayIndexOverride = displayIndex;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TrySplitOption(argument, "--refresh-rate", out var refreshText))
|
||||||
|
{
|
||||||
|
if (!int.TryParse(refreshText, out var refreshRate) || refreshRate < 0)
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
refreshRateOverride = refreshRate;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TrySplitOption(argument, "--scaling", out var scalingText))
|
||||||
|
{
|
||||||
|
if (!TryParseScalingMode(scalingText, out var scalingMode))
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
scalingModeOverride = scalingMode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TrySplitOption(argument, "--vsync", out var vsyncText))
|
||||||
|
{
|
||||||
|
if (!TryParseSwitch(vsyncText, out var vsync))
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vsyncOverride = vsync;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TrySplitOption(argument, "--hdr", out var hdrText))
|
||||||
|
{
|
||||||
|
if (!TryParseHdrMode(hdrText, out var hdrMode))
|
||||||
|
{
|
||||||
|
ebootPath = string.Empty;
|
||||||
|
runtimeOptions = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hdrModeOverride = hdrMode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (string.Equals(argument, "--strict", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(argument, "--strict", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
strictDynlibResolution = true;
|
strictDynlibResolution = true;
|
||||||
@@ -1269,9 +1303,147 @@ internal static partial class Program
|
|||||||
StrictDynlibResolution = strictDynlibResolution,
|
StrictDynlibResolution = strictDynlibResolution,
|
||||||
ImportTraceLimit = importTraceLimit,
|
ImportTraceLimit = importTraceLimit,
|
||||||
};
|
};
|
||||||
|
var configuredVideoOptions = LoadConfiguredVideoOptions(ebootPath);
|
||||||
|
videoOptions = (configuredVideoOptions with
|
||||||
|
{
|
||||||
|
WindowMode = windowModeOverride ?? configuredVideoOptions.WindowMode,
|
||||||
|
ScalingMode = scalingModeOverride ?? configuredVideoOptions.ScalingMode,
|
||||||
|
Width = windowWidthOverride ?? configuredVideoOptions.Width,
|
||||||
|
Height = windowHeightOverride ?? configuredVideoOptions.Height,
|
||||||
|
DisplayIndex = displayIndexOverride ?? configuredVideoOptions.DisplayIndex,
|
||||||
|
RefreshRate = refreshRateOverride ?? configuredVideoOptions.RefreshRate,
|
||||||
|
VSync = vsyncOverride ?? configuredVideoOptions.VSync,
|
||||||
|
HdrMode = hdrModeOverride ?? configuredVideoOptions.HdrMode,
|
||||||
|
}).Normalize();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static HostVideoOptions LoadConfiguredVideoOptions(string ebootPath)
|
||||||
|
{
|
||||||
|
var defaults = HostVideoOptions.Default;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var effective = EffectiveLaunchSettings.Resolve(
|
||||||
|
GuiSettings.Load(),
|
||||||
|
PerGameSettings.Load(TryReadTitleId(ebootPath)));
|
||||||
|
|
||||||
|
var windowMode = TryParseWindowMode(effective.WindowMode, out var parsedWindowMode)
|
||||||
|
? parsedWindowMode
|
||||||
|
: defaults.WindowMode;
|
||||||
|
var scalingMode = TryParseScalingMode(effective.ScalingMode, out var parsedScalingMode)
|
||||||
|
? parsedScalingMode
|
||||||
|
: defaults.ScalingMode;
|
||||||
|
var hasResolution = TryParseResolution(
|
||||||
|
effective.Resolution,
|
||||||
|
out var configuredWidth,
|
||||||
|
out var configuredHeight);
|
||||||
|
var hdrMode = TryParseHdrMode(effective.HdrMode, out var parsedHdrMode)
|
||||||
|
? parsedHdrMode
|
||||||
|
: defaults.HdrMode;
|
||||||
|
|
||||||
|
return new HostVideoOptions
|
||||||
|
{
|
||||||
|
WindowMode = windowMode,
|
||||||
|
ScalingMode = scalingMode,
|
||||||
|
Width = hasResolution ? configuredWidth : defaults.Width,
|
||||||
|
Height = hasResolution ? configuredHeight : defaults.Height,
|
||||||
|
DisplayIndex = effective.DisplayIndex,
|
||||||
|
RefreshRate = effective.RefreshRate,
|
||||||
|
VSync = effective.VSync,
|
||||||
|
HdrMode = hdrMode,
|
||||||
|
}.Normalize();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][WARN] GUI video settings could not be loaded; using defaults: {exception.Message}");
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TrySplitOption(string argument, string name, out string value)
|
||||||
|
{
|
||||||
|
var prefix = name + "=";
|
||||||
|
if (argument.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
value = argument[prefix.Length..];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = string.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryParseWindowMode(string value, out HostWindowMode mode)
|
||||||
|
{
|
||||||
|
mode = value.ToLowerInvariant() switch
|
||||||
|
{
|
||||||
|
"windowed" => HostWindowMode.Windowed,
|
||||||
|
"borderless" => HostWindowMode.Borderless,
|
||||||
|
"exclusive" or "fullscreen" => HostWindowMode.ExclusiveFullscreen,
|
||||||
|
_ => (HostWindowMode)(-1),
|
||||||
|
};
|
||||||
|
return Enum.IsDefined(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryParseScalingMode(string value, out HostScalingMode mode)
|
||||||
|
{
|
||||||
|
mode = value.ToLowerInvariant() switch
|
||||||
|
{
|
||||||
|
"fit" => HostScalingMode.Fit,
|
||||||
|
"cover" => HostScalingMode.Cover,
|
||||||
|
"stretch" => HostScalingMode.Stretch,
|
||||||
|
"integer" => HostScalingMode.Integer,
|
||||||
|
_ => (HostScalingMode)(-1),
|
||||||
|
};
|
||||||
|
return Enum.IsDefined(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryParseHdrMode(string value, out HostHdrMode mode)
|
||||||
|
{
|
||||||
|
mode = value.ToLowerInvariant() switch
|
||||||
|
{
|
||||||
|
"auto" => HostHdrMode.Auto,
|
||||||
|
"on" or "true" or "1" => HostHdrMode.On,
|
||||||
|
"off" or "false" or "0" => HostHdrMode.Off,
|
||||||
|
_ => (HostHdrMode)(-1),
|
||||||
|
};
|
||||||
|
return Enum.IsDefined(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryParseResolution(string value, out int width, out int height)
|
||||||
|
{
|
||||||
|
var parts = value.Split('x', 'X');
|
||||||
|
if (parts.Length == 2 && int.TryParse(parts[0], out width) && int.TryParse(parts[1], out height) &&
|
||||||
|
width >= 640 && height >= 360)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryParseSwitch(string value, out bool enabled)
|
||||||
|
{
|
||||||
|
if (value is "1" || value.Equals("on", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
value.Equals("true", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
enabled = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value is "0" || value.Equals("off", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
enabled = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool TryParseCpuEngine(string valueText, out CpuExecutionEngine engine)
|
private static bool TryParseCpuEngine(string valueText, out CpuExecutionEngine engine)
|
||||||
{
|
{
|
||||||
if (string.Equals(valueText, "native", StringComparison.OrdinalIgnoreCase) ||
|
if (string.Equals(valueText, "native", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|||||||
@@ -77,35 +77,47 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<TargetPath>Languages\%(Filename)%(Extension)</TargetPath>
|
<TargetPath>Languages\%(Filename)%(Extension)</TargetPath>
|
||||||
<Visible>False</Visible>
|
<Visible>False</Visible>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="..\SharpEmu.LibAtrac9\LICENSE.txt">
|
||||||
|
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
|
||||||
|
<TargetPath>licenses\LibAtrac9.txt</TargetPath>
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
<Visible>False</Visible>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Native libraries (glfw, FFmpeg) publish into a subfolder next to the
|
<Target Name="KeepLibAtrac9External" BeforeTargets="_ComputeFilesToBundle">
|
||||||
|
<ItemGroup>
|
||||||
|
<ResolvedFileToPublish Update="@(ResolvedFileToPublish)"
|
||||||
|
Condition="'%(Filename)%(Extension)' == 'SharpEmu.LibAtrac9.dll'">
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
<RelativePath>plugins\SharpEmu.LibAtrac9.dll</RelativePath>
|
||||||
|
</ResolvedFileToPublish>
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- These are native debug symbols emitted by Skia/HarfBuzz, not managed
|
||||||
|
symbols that single-file publish can bundle. They are not needed at
|
||||||
|
runtime and would otherwise add more than 100 MB to every release. -->
|
||||||
|
<Target Name="RemoveNativeDebugSymbols" AfterTargets="Publish">
|
||||||
|
<ItemGroup>
|
||||||
|
<_NativeDebugSymbols Include="$(PublishDir)**\*.pdb" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Delete Files="@(_NativeDebugSymbols)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Native FFmpeg libraries publish into a subfolder next to the
|
||||||
executable instead of sitting loose beside it, so the publish
|
executable instead of sitting loose beside it, so the publish
|
||||||
directory stays uncluttered as more native deps get added. The folder
|
directory stays uncluttered as more native deps get added. The folder
|
||||||
name is a fixed constant, not derived from the RID/architecture: each
|
name is a fixed constant, not derived from the RID/architecture: each
|
||||||
publish output only ever holds one architecture's binaries anyway, so
|
publish output only ever holds one architecture's binaries anyway, so
|
||||||
varying the name added a class of bugs (RID resolution timing, host-OS
|
varying the name added a class of bugs (RID resolution timing, host-OS
|
||||||
vs. target-RID mixups) for no benefit. Runtime code (Program.cs's
|
vs. target-RID mixups) for no benefit. Runtime code (Program.cs's
|
||||||
PreloadGlfw, FfmpegNativeBinkFrameSource's RootPath) uses the same
|
FfmpegNativeBinkFrameSource uses the same literal "plugins" folder
|
||||||
literal "plugins" folder name. -->
|
name. -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<NativeLibraryFolderName>plugins</NativeLibraryFolderName>
|
<NativeLibraryFolderName>plugins</NativeLibraryFolderName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Keep glfw as a loose file in the native subfolder; every other native
|
|
||||||
library is embedded into the single-file bundle. -->
|
|
||||||
<Target Name="KeepGlfwOutsideSingleFile" AfterTargets="ComputeResolvedFilesToPublishList">
|
|
||||||
<ItemGroup>
|
|
||||||
<_GlfwPublishFiles Include="@(ResolvedFileToPublish)"
|
|
||||||
Condition="$([System.String]::Copy('%(ResolvedFileToPublish.Filename)').StartsWith('glfw')) Or $([System.String]::Copy('%(ResolvedFileToPublish.Filename)').StartsWith('libglfw'))" />
|
|
||||||
<ResolvedFileToPublish Remove="@(_GlfwPublishFiles)" />
|
|
||||||
<ResolvedFileToPublish Include="@(_GlfwPublishFiles)">
|
|
||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
|
||||||
<RelativePath>$(NativeLibraryFolderName)/%(Filename)%(Extension)</RelativePath>
|
|
||||||
</ResolvedFileToPublish>
|
|
||||||
</ItemGroup>
|
|
||||||
</Target>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<FfmpegRuntimeTag>2c92585</FfmpegRuntimeTag>
|
<FfmpegRuntimeTag>2c92585</FfmpegRuntimeTag>
|
||||||
<FfmpegRuntimeDir>
|
<FfmpegRuntimeDir>
|
||||||
|
|||||||
@@ -23,14 +23,71 @@ public sealed partial class DirectExecutionBackend
|
|||||||
private static long _perfHleTotal;
|
private static long _perfHleTotal;
|
||||||
private static long _perfHleDispatchTicks;
|
private static long _perfHleDispatchTicks;
|
||||||
|
|
||||||
|
private sealed class PerfHleExportCost
|
||||||
|
{
|
||||||
|
public long Calls;
|
||||||
|
public long Ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly System.Collections.Concurrent.ConcurrentDictionary<string, PerfHleExportCost> _perfHleCosts = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the export currently being dispatched on this thread, so the
|
||||||
|
/// gateway can attribute its elapsed time once the call returns. Answering
|
||||||
|
/// "which export is worth optimising" needs cost per export, not just call
|
||||||
|
/// counts — a rare expensive call and a hot cheap one look identical in a
|
||||||
|
/// frequency histogram.
|
||||||
|
/// </summary>
|
||||||
|
[System.ThreadStatic]
|
||||||
|
private static string? _perfHleCurrentExport;
|
||||||
|
|
||||||
|
private static long _perfHleFirstTimestamp;
|
||||||
|
|
||||||
private static void RecordPerfHleDispatchTime(long ticks)
|
private static void RecordPerfHleDispatchTime(long ticks)
|
||||||
{
|
{
|
||||||
var total = System.Threading.Interlocked.Add(ref _perfHleDispatchTicks, ticks);
|
var total = System.Threading.Interlocked.Add(ref _perfHleDispatchTicks, ticks);
|
||||||
var calls = System.Threading.Interlocked.Read(ref _perfHleTotal);
|
var calls = System.Threading.Interlocked.Read(ref _perfHleTotal);
|
||||||
|
|
||||||
|
var name = _perfHleCurrentExport;
|
||||||
|
if (name is not null)
|
||||||
|
{
|
||||||
|
var cost = _perfHleCosts.GetOrAdd(name, static _ => new PerfHleExportCost());
|
||||||
|
System.Threading.Interlocked.Increment(ref cost.Calls);
|
||||||
|
System.Threading.Interlocked.Add(ref cost.Ticks, ticks);
|
||||||
|
}
|
||||||
|
|
||||||
if (calls > 0 && calls % 500000 == 0)
|
if (calls > 0 && calls % 500000 == 0)
|
||||||
{
|
{
|
||||||
var avgUs = (double)total / System.Diagnostics.Stopwatch.Frequency * 1_000_000.0 / calls;
|
var frequency = (double)System.Diagnostics.Stopwatch.Frequency;
|
||||||
System.Console.Error.WriteLine($"[PERF][HLE] managed_dispatch_avg={avgUs:F3}us total_managed_s={(double)total / System.Diagnostics.Stopwatch.Frequency:F2}");
|
var avgUs = (double)total / frequency * 1_000_000.0 / calls;
|
||||||
|
var first = System.Threading.Interlocked.CompareExchange(ref _perfHleFirstTimestamp, 0, 0);
|
||||||
|
var wallSeconds = first == 0
|
||||||
|
? 0
|
||||||
|
: (double)(System.Diagnostics.Stopwatch.GetTimestamp() - first) / frequency;
|
||||||
|
System.Console.Error.WriteLine(
|
||||||
|
$"[PERF][HLE] managed_dispatch_avg={avgUs:F3}us " +
|
||||||
|
$"total_managed_s={(double)total / frequency:F2} " +
|
||||||
|
$"wall_s={wallSeconds:F2} " +
|
||||||
|
$"cores={(wallSeconds > 0 ? total / frequency / wallSeconds : 0):F2}");
|
||||||
|
|
||||||
|
var snapshot = new System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, PerfHleExportCost>>(_perfHleCosts.Count + 16);
|
||||||
|
foreach (var kvp in _perfHleCosts)
|
||||||
|
{
|
||||||
|
snapshot.Add(kvp);
|
||||||
|
}
|
||||||
|
|
||||||
|
var top = snapshot
|
||||||
|
.OrderByDescending(kvp => System.Threading.Interlocked.Read(ref kvp.Value.Ticks))
|
||||||
|
.Take(12)
|
||||||
|
.Select(kvp =>
|
||||||
|
{
|
||||||
|
var seconds = System.Threading.Interlocked.Read(ref kvp.Value.Ticks) / frequency;
|
||||||
|
var callCount = System.Threading.Interlocked.Read(ref kvp.Value.Calls);
|
||||||
|
var cores = wallSeconds > 0 ? seconds / wallSeconds : 0;
|
||||||
|
var perCallUs = callCount > 0 ? seconds * 1_000_000.0 / callCount : 0;
|
||||||
|
return $"{kvp.Key}: {cores:F2}cores {seconds:F1}s n={callCount} {perCallUs:F2}us/call";
|
||||||
|
});
|
||||||
|
System.Console.Error.WriteLine($"[PERF][HLE] cost: {string.Join(" | ", top)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +96,16 @@ public sealed partial class DirectExecutionBackend
|
|||||||
|
|
||||||
private static void RecordPerfHleCall(string name)
|
private static void RecordPerfHleCall(string name)
|
||||||
{
|
{
|
||||||
|
_perfHleCurrentExport = name;
|
||||||
var total = System.Threading.Interlocked.Increment(ref _perfHleTotal);
|
var total = System.Threading.Interlocked.Increment(ref _perfHleTotal);
|
||||||
|
if (total == 1)
|
||||||
|
{
|
||||||
|
System.Threading.Interlocked.CompareExchange(
|
||||||
|
ref _perfHleFirstTimestamp,
|
||||||
|
System.Diagnostics.Stopwatch.GetTimestamp(),
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_perfHleNoDict)
|
if (!_perfHleNoDict)
|
||||||
{
|
{
|
||||||
_perfHleCounts.AddOrUpdate(name, 1, static (_, v) => v + 1);
|
_perfHleCounts.AddOrUpdate(name, 1, static (_, v) => v + 1);
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ public sealed partial class DirectExecutionBackend
|
|||||||
private static int _lazyCommitTraceCount;
|
private static int _lazyCommitTraceCount;
|
||||||
private static int _guestAllocatorHoleRecoveries;
|
private static int _guestAllocatorHoleRecoveries;
|
||||||
private static int _auxiliaryThreadExecuteFaultRecoveries;
|
private static int _auxiliaryThreadExecuteFaultRecoveries;
|
||||||
|
private static int _auxiliaryThreadExecuteFaultSkips;
|
||||||
|
private nint _workerAbortStack;
|
||||||
|
private const uint WorkerAbortStackSize = 0x10000u;
|
||||||
|
|
||||||
private unsafe void SetupExceptionHandler()
|
private unsafe void SetupExceptionHandler()
|
||||||
{
|
{
|
||||||
@@ -37,6 +40,15 @@ public sealed partial class DirectExecutionBackend
|
|||||||
}
|
}
|
||||||
_rawExceptionHandler = (nint)AddVectoredExceptionHandler(1u, _rawExceptionHandlerStub);
|
_rawExceptionHandler = (nint)AddVectoredExceptionHandler(1u, _rawExceptionHandlerStub);
|
||||||
Console.Error.WriteLine($"[LOADER][INFO] Raw exception handler installed: 0x{_rawExceptionHandler:X16}");
|
Console.Error.WriteLine($"[LOADER][INFO] Raw exception handler installed: 0x{_rawExceptionHandler:X16}");
|
||||||
|
|
||||||
|
// The raw handler carries the guest-image write-fault bridge, so the
|
||||||
|
// path must be compiled before the first protected-page store can
|
||||||
|
// reach it. Guest code has not started yet, so warming here cannot
|
||||||
|
// race a real fault.
|
||||||
|
SharpEmu.HLE.GuestImageWriteTracker.WarmUp();
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[LOADER][INFO] Guest image CPU write tracking: " +
|
||||||
|
$"{(SharpEmu.HLE.GuestImageWriteTracker.Enabled ? "enabled" : "disabled")}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -52,6 +64,7 @@ public sealed partial class DirectExecutionBackend
|
|||||||
}
|
}
|
||||||
_exceptionHandler = (nint)AddVectoredExceptionHandler(1u, _exceptionHandlerStub);
|
_exceptionHandler = (nint)AddVectoredExceptionHandler(1u, _exceptionHandlerStub);
|
||||||
Console.Error.WriteLine($"[LOADER][INFO] Exception handler installed: 0x{_exceptionHandler:X16}");
|
Console.Error.WriteLine($"[LOADER][INFO] Exception handler installed: 0x{_exceptionHandler:X16}");
|
||||||
|
SharpEmu.HLE.GuestImageWriteTracker.WarmUp();
|
||||||
|
|
||||||
_unhandledFilterDelegate = UnhandledExceptionFilter;
|
_unhandledFilterDelegate = UnhandledExceptionFilter;
|
||||||
_unhandledFilterHandle = GCHandle.Alloc(_unhandledFilterDelegate);
|
_unhandledFilterHandle = GCHandle.Alloc(_unhandledFilterDelegate);
|
||||||
@@ -114,6 +127,13 @@ public sealed partial class DirectExecutionBackend
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (exceptionCode == 3221225477u &&
|
||||||
|
exceptionRecord->NumberParameters >= 2 &&
|
||||||
|
SharpEmu.HLE.GuestImageWriteTracker.TryHandleWriteFault(
|
||||||
|
exceptionRecord->ExceptionInformation[1]))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (TryRecoverAuxiliaryThreadExecuteFault(exceptionRecord, contextRecord, rip))
|
if (TryRecoverAuxiliaryThreadExecuteFault(exceptionRecord, contextRecord, rip))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@@ -435,18 +455,91 @@ public sealed partial class DirectExecutionBackend
|
|||||||
void* contextRecord,
|
void* contextRecord,
|
||||||
ulong rip)
|
ulong rip)
|
||||||
{
|
{
|
||||||
if (exceptionRecord->ExceptionCode != 3221225477u ||
|
if (exceptionRecord->ExceptionCode != 3221225477u)
|
||||||
rip >= 0x0000000800000000UL ||
|
|
||||||
_activeGuestThreadState is not { Name: "tbb_thead" } activeThread)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefer ThreadStatic active state; fall back to host-thread name when
|
||||||
|
// concurrent TBB AVs race logging (tLT61: recover skipped, then Fatal).
|
||||||
|
GuestThreadState? activeThread = _activeGuestThreadState;
|
||||||
|
if (activeThread is null || activeThread.Name != "tbb_thead")
|
||||||
|
{
|
||||||
|
var hostName = Thread.CurrentThread.Name;
|
||||||
|
if (hostName is null ||
|
||||||
|
!hostName.StartsWith("SharpEmu-tbb_thead", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeThread = FindGuestThreadStateByHostThreadId(unchecked((int)GetCurrentThreadId()));
|
||||||
|
if (activeThread is null || activeThread.Name != "tbb_thead")
|
||||||
|
{
|
||||||
|
var skip = Interlocked.Increment(ref _auxiliaryThreadExecuteFaultSkips);
|
||||||
|
if (skip <= 8 || skip % 64 == 0)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][WARN] tbb_recover skip #{skip}: rip=0x{rip:X16} " +
|
||||||
|
$"host='{hostName}' active={(activeThread?.Name ?? "null")}");
|
||||||
|
Console.Error.Flush();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var hostExit = ActiveEntryReturnSentinelRip;
|
var hostExit = ActiveEntryReturnSentinelRip;
|
||||||
if (hostExit < 0x10000)
|
if (hostExit < 0x10000)
|
||||||
{
|
{
|
||||||
hostExit = unchecked((ulong)_guestReturnStub);
|
hostExit = unchecked((ulong)_guestReturnStub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefer worker-abort (SetEvent + ExitThread) over host_exit→RunEpilogue:
|
||||||
|
// the latter FailFasts the process after TBB recover (tLT28/30 silent die).
|
||||||
|
// Do NOT abandon mutexes here — managed HLE from inside VEH can re-enter
|
||||||
|
// and Fatal (tLT73). NativeGuestExecutor.Run abandons after detecting abort.
|
||||||
|
var abortRip = unchecked((ulong)_workerAbortStub);
|
||||||
|
if (abortRip >= 0x10000)
|
||||||
|
{
|
||||||
|
// Do NOT SetEvent from managed VEH: that wakes the renter which may
|
||||||
|
// TerminateThread while this thread is still inside VEH return
|
||||||
|
// (tLTA2: recover logged, no respawning, process die). Abort stub
|
||||||
|
// SetEvent's only after CONTINUE_EXECUTION resumes at park.
|
||||||
|
|
||||||
|
// Prefer the entry-stub-saved host RSP (real CreateThread stack).
|
||||||
|
// Do not treat mid-range host stacks as guest — Astro worker stacks
|
||||||
|
// often sit in 0x02xxxxxx_xxxx and were wrongly replaced with a
|
||||||
|
// shared VirtualAlloc abort stack (concurrent TBB AV → die).
|
||||||
|
var hostRspSlot = TlsGetValue(_hostRspSlotTlsIndex);
|
||||||
|
ulong hostRsp = 0;
|
||||||
|
if (hostRspSlot != 0)
|
||||||
|
{
|
||||||
|
hostRsp = *(ulong*)hostRspSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostRsp < 0x10000)
|
||||||
|
{
|
||||||
|
hostRsp = EnsureWorkerAbortStackRsp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostRsp >= 0x10000)
|
||||||
|
{
|
||||||
|
WriteCtxU64(contextRecord, 152, hostRsp & ~0xFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteCtxU64(contextRecord, 120, 0);
|
||||||
|
WriteCtxU64(contextRecord, 248, abortRip);
|
||||||
|
var recovery = Interlocked.Increment(ref _auxiliaryThreadExecuteFaultRecoveries);
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][WARN] Recovered auxiliary TBB execute fault #{recovery}: " +
|
||||||
|
$"thread=0x{activeThread.ThreadHandle:X16} target=0x{rip:X16} " +
|
||||||
|
$"host_rsp=0x{hostRsp:X16} -> worker_abort=0x{abortRip:X16}");
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[LOADER][INFO] tbb_recover: parking native worker (SetEvent+park); " +
|
||||||
|
"renter will TerminateThread+respawn — avoids ExitThread after VEH");
|
||||||
|
Console.Error.Flush();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (hostExit < 0x10000)
|
if (hostExit < 0x10000)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(
|
Console.Error.WriteLine(
|
||||||
@@ -458,13 +551,57 @@ public sealed partial class DirectExecutionBackend
|
|||||||
_ = TryPatchActiveGuestReturnSlot(hostExit);
|
_ = TryPatchActiveGuestReturnSlot(hostExit);
|
||||||
WriteCtxU64(contextRecord, 120, 0);
|
WriteCtxU64(contextRecord, 120, 0);
|
||||||
WriteCtxU64(contextRecord, 248, hostExit);
|
WriteCtxU64(contextRecord, 248, hostExit);
|
||||||
var recovery = Interlocked.Increment(ref _auxiliaryThreadExecuteFaultRecoveries);
|
var recoveryFallback = Interlocked.Increment(ref _auxiliaryThreadExecuteFaultRecoveries);
|
||||||
Console.Error.WriteLine(
|
Console.Error.WriteLine(
|
||||||
$"[LOADER][WARN] Recovered auxiliary TBB execute fault #{recovery}: " +
|
$"[LOADER][WARN] Recovered auxiliary TBB execute fault #{recoveryFallback}: " +
|
||||||
$"thread=0x{activeThread.ThreadHandle:X16} target=0x{rip:X16} -> host_exit=0x{hostExit:X16}");
|
$"thread=0x{activeThread.ThreadHandle:X16} target=0x{rip:X16} -> host_exit=0x{hostExit:X16}");
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[LOADER][INFO] tbb_recover: resumed at host_exit (abort stub unavailable); " +
|
||||||
|
"subsequent FastFail/CLR must not re-enter managed VEH " +
|
||||||
|
"(live trampoline pre-filters 0xC0000409 / 0xE0434352)");
|
||||||
|
Console.Error.Flush();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GuestThreadState? FindGuestThreadStateByHostThreadId(int hostThreadId)
|
||||||
|
{
|
||||||
|
if (hostThreadId == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var thread in SnapshotGuestThreads())
|
||||||
|
{
|
||||||
|
if (Volatile.Read(ref thread.HostThreadId) == hostThreadId)
|
||||||
|
{
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe ulong EnsureWorkerAbortStackRsp()
|
||||||
|
{
|
||||||
|
if (_workerAbortStack == 0)
|
||||||
|
{
|
||||||
|
_workerAbortStack = (nint)VirtualAlloc(null, WorkerAbortStackSize, 12288u, 4u);
|
||||||
|
if (_workerAbortStack == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grow-down stack: hand out near the top with alignment headroom.
|
||||||
|
return (ulong)(_workerAbortStack + (nint)WorkerAbortStackSize - 0x100) & ~0xFUL;
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe bool TryRecoverGuestInt41(uint exceptionCode, void* contextRecord, ulong rip)
|
private unsafe bool TryRecoverGuestInt41(uint exceptionCode, void* contextRecord, ulong rip)
|
||||||
{
|
{
|
||||||
if (!_ignoreGuestInt41 || exceptionCode != 3221225477u || rip < 0x10000)
|
if (!_ignoreGuestInt41 || exceptionCode != 3221225477u || rip < 0x10000)
|
||||||
|
|||||||
@@ -0,0 +1,322 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace SharpEmu.Core.Cpu.Native;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sampling profiler for guest code. Managed profilers only see the emulator's
|
||||||
|
/// own frames — once a guest thread is running translated code it is opaque to
|
||||||
|
/// them, so a title that burns its cores inside its own spin loops looks like
|
||||||
|
/// unattributed native time. This walks the guest thread registry and samples
|
||||||
|
/// each thread's host RIP, which lands directly on the guest instruction being
|
||||||
|
/// executed.
|
||||||
|
/// </summary>
|
||||||
|
public sealed partial class DirectExecutionBackend
|
||||||
|
{
|
||||||
|
private static readonly bool _profileGuestRip =
|
||||||
|
string.Equals(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_PROFILE_GUEST_RIP"),
|
||||||
|
"1",
|
||||||
|
StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static readonly int _profileGuestRipIntervalMs =
|
||||||
|
int.TryParse(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_PROFILE_GUEST_RIP_INTERVAL_MS"),
|
||||||
|
out var interval) && interval > 0
|
||||||
|
? interval
|
||||||
|
: 2;
|
||||||
|
|
||||||
|
private static readonly int _profileGuestRipReportSeconds =
|
||||||
|
int.TryParse(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_PROFILE_GUEST_RIP_REPORT_S"),
|
||||||
|
out var report) && report > 0
|
||||||
|
? report
|
||||||
|
: 15;
|
||||||
|
|
||||||
|
private const ulong GuestImageBase = 0x0000_0008_0000_0000UL;
|
||||||
|
private const ulong GuestImageLimit = 0x0000_0009_0000_0000UL;
|
||||||
|
|
||||||
|
private int _guestRipSamplerStarted;
|
||||||
|
private readonly ConcurrentDictionary<ulong, long> _guestRipSamples = new();
|
||||||
|
private readonly ConcurrentDictionary<string, long> _guestRipThreadSamples = new();
|
||||||
|
private readonly ConcurrentDictionary<string, long> _guestWaitSamples = new();
|
||||||
|
private readonly ConcurrentDictionary<string, long> _guestThreadWaitSamples = new();
|
||||||
|
private long _guestRipTotalSamples;
|
||||||
|
private long _guestWaitTotalSamples;
|
||||||
|
private long _guestRipCaptureFailures;
|
||||||
|
private long _guestRipSamplerErrors;
|
||||||
|
private int _guestRipSampleCursor;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Names the HLE call a thread is parked in, using the guest RIP the import
|
||||||
|
/// dispatcher left on its context.
|
||||||
|
/// </summary>
|
||||||
|
private string ResolveWaitLabel(GuestThreadState thread)
|
||||||
|
{
|
||||||
|
var context = thread.Context;
|
||||||
|
if (context is null)
|
||||||
|
{
|
||||||
|
return "<no-context>";
|
||||||
|
}
|
||||||
|
|
||||||
|
var importIndex = context.ActiveImportIndex;
|
||||||
|
if ((uint)importIndex >= (uint)_importEntries.Length)
|
||||||
|
{
|
||||||
|
// Host code with no import in flight: the thread is parked by the
|
||||||
|
// emulator's own scheduler. The cooperative block records why, which
|
||||||
|
// is the part that actually identifies what the frame is waiting on.
|
||||||
|
var blockReason = thread.BlockReason;
|
||||||
|
return string.IsNullOrEmpty(blockReason)
|
||||||
|
? "<idle-or-scheduler>"
|
||||||
|
: $"blocked:{blockReason}";
|
||||||
|
}
|
||||||
|
|
||||||
|
var entry = _importEntries[importIndex];
|
||||||
|
return entry.Export?.Name ?? entry.Nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClearActiveImportIndex()
|
||||||
|
{
|
||||||
|
if (!_profileGuestRip)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var context = ActiveCpuContext;
|
||||||
|
if (context is not null)
|
||||||
|
{
|
||||||
|
context.ActiveImportIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnsureGuestRipSampler()
|
||||||
|
{
|
||||||
|
if (!_profileGuestRip ||
|
||||||
|
!OperatingSystem.IsWindows() ||
|
||||||
|
Interlocked.Exchange(ref _guestRipSamplerStarted, 1) != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sampler = new Thread(GuestRipSampleLoop)
|
||||||
|
{
|
||||||
|
IsBackground = true,
|
||||||
|
Name = "SharpEmu guest RIP sampler",
|
||||||
|
// Sampling suspends guest threads briefly. Keep this diagnostic below
|
||||||
|
// the title workers so it observes them without becoming the bottleneck.
|
||||||
|
Priority = ThreadPriority.BelowNormal,
|
||||||
|
};
|
||||||
|
sampler.Start();
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[PERF][GUEST] RIP sampler started: interval={_profileGuestRipIntervalMs}ms " +
|
||||||
|
$"report={_profileGuestRipReportSeconds}s");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GuestRipSampleLoop()
|
||||||
|
{
|
||||||
|
var clock = Stopwatch.StartNew();
|
||||||
|
var lastReportMs = 0L;
|
||||||
|
var lastReportSamples = 0L;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var guestThreads = SnapshotGuestThreads();
|
||||||
|
var sampleIndex = guestThreads.Length == 0
|
||||||
|
? 0
|
||||||
|
: (int)((uint)Interlocked.Increment(ref _guestRipSampleCursor) % (uint)guestThreads.Length);
|
||||||
|
foreach (var thread in guestThreads.Skip(sampleIndex).Take(1))
|
||||||
|
{
|
||||||
|
var hostThreadId = Volatile.Read(ref thread.HostThreadId);
|
||||||
|
if (hostThreadId == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TryCaptureHostThreadContext(hostThreadId, out var snapshot) ||
|
||||||
|
!snapshot.IsValid)
|
||||||
|
{
|
||||||
|
Interlocked.Increment(ref _guestRipCaptureFailures);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_guestRipSamples.AddOrUpdate(snapshot.Rip, 1, static (_, value) => value + 1);
|
||||||
|
_guestRipThreadSamples.AddOrUpdate(
|
||||||
|
string.IsNullOrEmpty(thread.Name) ? "<unnamed>" : thread.Name,
|
||||||
|
1,
|
||||||
|
static (_, value) => value + 1);
|
||||||
|
Interlocked.Increment(ref _guestRipTotalSamples);
|
||||||
|
|
||||||
|
// A host RIP means the thread is inside the emulator rather
|
||||||
|
// than running translated code. DispatchImport parks the
|
||||||
|
// guest RIP on the import stub for the call being serviced,
|
||||||
|
// so the stub address names what the thread is waiting on —
|
||||||
|
// no hot-path bookkeeping needed to find out.
|
||||||
|
if (snapshot.Rip >= GuestImageBase && snapshot.Rip < GuestImageLimit)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_guestWaitSamples.AddOrUpdate(
|
||||||
|
ResolveWaitLabel(thread),
|
||||||
|
1,
|
||||||
|
static (_, value) => value + 1);
|
||||||
|
_guestThreadWaitSamples.AddOrUpdate(
|
||||||
|
string.IsNullOrEmpty(thread.Name) ? "<unnamed>" : thread.Name,
|
||||||
|
1,
|
||||||
|
static (_, value) => value + 1);
|
||||||
|
Interlocked.Increment(ref _guestWaitTotalSamples);
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(_profileGuestRipIntervalMs);
|
||||||
|
|
||||||
|
var elapsedMs = clock.ElapsedMilliseconds;
|
||||||
|
if (elapsedMs - lastReportMs < _profileGuestRipReportSeconds * 1000L)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var samples = Interlocked.Read(ref _guestRipTotalSamples);
|
||||||
|
ReportGuestRipSamples(samples - lastReportSamples, (elapsedMs - lastReportMs) / 1000.0);
|
||||||
|
lastReportMs = elapsedMs;
|
||||||
|
lastReportSamples = samples;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
// A title can tear down a thread or its context during a capture.
|
||||||
|
// The profiler must never silently die or affect guest execution.
|
||||||
|
if (Interlocked.Increment(ref _guestRipSamplerErrors) == 1)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"[PERF][GUEST] sampler recovery: {exception.GetType().Name}: {exception.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReportGuestRipSamples(long windowSamples, double windowSeconds)
|
||||||
|
{
|
||||||
|
var total = Interlocked.Read(ref _guestRipTotalSamples);
|
||||||
|
if (total == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var byRip = new List<KeyValuePair<ulong, long>>(_guestRipSamples.Count + 16);
|
||||||
|
foreach (var pair in _guestRipSamples)
|
||||||
|
{
|
||||||
|
byRip.Add(pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A tight spin lands on a handful of instructions; grouping by 4 KB page
|
||||||
|
// as well shows which routine those instructions belong to.
|
||||||
|
var byPage = new Dictionary<ulong, long>();
|
||||||
|
foreach (var pair in byRip)
|
||||||
|
{
|
||||||
|
var page = pair.Key & ~0xFFFUL;
|
||||||
|
byPage[page] = byPage.TryGetValue(page, out var existing)
|
||||||
|
? existing + pair.Value
|
||||||
|
: pair.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var byThread = new List<KeyValuePair<string, long>>(_guestRipThreadSamples.Count + 16);
|
||||||
|
foreach (var pair in _guestRipThreadSamples)
|
||||||
|
{
|
||||||
|
byThread.Add(pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[PERF][GUEST] samples={total} window={windowSamples} in {windowSeconds:F1}s " +
|
||||||
|
$"capture_failures={Interlocked.Read(ref _guestRipCaptureFailures)}");
|
||||||
|
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[PERF][GUEST] top_rip: " +
|
||||||
|
string.Join(
|
||||||
|
" | ",
|
||||||
|
byRip.OrderByDescending(pair => pair.Value)
|
||||||
|
.Take(12)
|
||||||
|
.Select(pair =>
|
||||||
|
$"0x{pair.Key:X}{DescribeGuestAddress(pair.Key)}={pair.Value * 100.0 / total:F1}%")));
|
||||||
|
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[PERF][GUEST] top_page: " +
|
||||||
|
string.Join(
|
||||||
|
" | ",
|
||||||
|
byPage.OrderByDescending(pair => pair.Value)
|
||||||
|
.Take(8)
|
||||||
|
.Select(pair =>
|
||||||
|
$"0x{pair.Key:X}{DescribeGuestAddress(pair.Key)}={pair.Value * 100.0 / total:F1}%")));
|
||||||
|
|
||||||
|
var byWait = new List<KeyValuePair<string, long>>(_guestWaitSamples.Count + 16);
|
||||||
|
foreach (var pair in _guestWaitSamples)
|
||||||
|
{
|
||||||
|
byWait.Add(pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
var waitTotal = Interlocked.Read(ref _guestWaitTotalSamples);
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[PERF][GUEST] waiting={waitTotal * 100.0 / total:F1}% of guest thread-time; top_wait: " +
|
||||||
|
string.Join(
|
||||||
|
" | ",
|
||||||
|
byWait.OrderByDescending(pair => pair.Value)
|
||||||
|
.Take(12)
|
||||||
|
.Select(pair => $"{pair.Key}={pair.Value * 100.0 / total:F1}%")));
|
||||||
|
|
||||||
|
// Per-thread spin/park split. The global wait share mixes the job pool in
|
||||||
|
// with a dozen dormant threads, which hides the number that matters:
|
||||||
|
// how much of a core each worker actually burns.
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[PERF][GUEST] thread_split (running/parked): " +
|
||||||
|
string.Join(
|
||||||
|
" | ",
|
||||||
|
byThread.OrderByDescending(pair => pair.Value)
|
||||||
|
.Take(10)
|
||||||
|
.Select(pair =>
|
||||||
|
{
|
||||||
|
var parked = _guestThreadWaitSamples.TryGetValue(pair.Key, out var wait) ? wait : 0;
|
||||||
|
var running = pair.Value - parked;
|
||||||
|
return $"{pair.Key}={running * 100.0 / pair.Value:F0}%/{parked * 100.0 / pair.Value:F0}%";
|
||||||
|
})));
|
||||||
|
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[PERF][GUEST] top_thread: " +
|
||||||
|
string.Join(
|
||||||
|
" | ",
|
||||||
|
byThread.OrderByDescending(pair => pair.Value)
|
||||||
|
.Take(10)
|
||||||
|
.Select(pair => $"{pair.Key}={pair.Value * 100.0 / total:F1}%")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tags a sampled address with the region it belongs to. Guest module code
|
||||||
|
/// lives above the image base; anything else is emulator or system code that
|
||||||
|
/// the managed profiler already covers.
|
||||||
|
/// </summary>
|
||||||
|
private string DescribeGuestAddress(ulong address)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (address >= GuestImageBase && address < GuestImageLimit)
|
||||||
|
{
|
||||||
|
return $"(app+0x{address - GuestImageBase:X})";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var index = 0; index < _importEntries.Length; index++)
|
||||||
|
{
|
||||||
|
if (_importEntries[index].Address == (address & ~0xFUL))
|
||||||
|
{
|
||||||
|
return $"(stub:{_importEntries[index].Nid})";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "(host)";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,10 +54,13 @@ public sealed partial class DirectExecutionBackend
|
|||||||
var startTicks = System.Diagnostics.Stopwatch.GetTimestamp();
|
var startTicks = System.Diagnostics.Stopwatch.GetTimestamp();
|
||||||
var r = directExecutionBackend.DispatchImport(importIndex, argPackPtr);
|
var r = directExecutionBackend.DispatchImport(importIndex, argPackPtr);
|
||||||
RecordPerfHleDispatchTime(System.Diagnostics.Stopwatch.GetTimestamp() - startTicks);
|
RecordPerfHleDispatchTime(System.Diagnostics.Stopwatch.GetTimestamp() - startTicks);
|
||||||
|
directExecutionBackend.ClearActiveImportIndex();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return directExecutionBackend.DispatchImport(importIndex, argPackPtr);
|
var result = directExecutionBackend.DispatchImport(importIndex, argPackPtr);
|
||||||
|
directExecutionBackend.ClearActiveImportIndex();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -69,9 +72,45 @@ public sealed partial class DirectExecutionBackend
|
|||||||
|
|
||||||
private unsafe static int RawVectoredHandlerManaged(void* exceptionInfo)
|
private unsafe static int RawVectoredHandlerManaged(void* exceptionInfo)
|
||||||
{
|
{
|
||||||
|
if (TryHandleGuestImageWriteFault(exceptionInfo))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return TryRecoverUnresolvedSentinel(exceptionInfo);
|
return TryRecoverUnresolvedSentinel(exceptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Windows counterpart of the POSIX SIGSEGV bridge into
|
||||||
|
/// <see cref="SharpEmu.HLE.GuestImageWriteTracker"/>. Guest code runs natively,
|
||||||
|
/// so a store into a surface the GPU backend has cached is an ordinary CPU
|
||||||
|
/// write with nothing to intercept — the page is write-protected instead and
|
||||||
|
/// the resulting fault is what tells the backend to re-upload. Without this
|
||||||
|
/// the cache serves the first upload forever, and anything the guest CPU
|
||||||
|
/// draws (a software-decoded movie frame, a memset fog layer) never reaches
|
||||||
|
/// the screen.
|
||||||
|
/// </summary>
|
||||||
|
private unsafe static bool TryHandleGuestImageWriteFault(void* exceptionInfo)
|
||||||
|
{
|
||||||
|
if (!SharpEmu.HLE.GuestImageWriteTracker.Enabled)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var exceptionRecord = ((EXCEPTION_POINTERS*)exceptionInfo)->ExceptionRecord;
|
||||||
|
// STATUS_ACCESS_VIOLATION, and only the write flavour: ExceptionInformation
|
||||||
|
// is [accessKind, address] with 0=read, 1=write, 8=DEP execute.
|
||||||
|
if (exceptionRecord->ExceptionCode != 3221225477u ||
|
||||||
|
exceptionRecord->NumberParameters < 2 ||
|
||||||
|
exceptionRecord->ExceptionInformation[0] != 1uL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SharpEmu.HLE.GuestImageWriteTracker.TryHandleWriteFault(
|
||||||
|
exceptionRecord->ExceptionInformation[1]);
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe static int RawUnhandledFilterManaged(void* exceptionInfo)
|
private unsafe static int RawUnhandledFilterManaged(void* exceptionInfo)
|
||||||
{
|
{
|
||||||
return TryRecoverUnresolvedSentinel(exceptionInfo);
|
return TryRecoverUnresolvedSentinel(exceptionInfo);
|
||||||
@@ -165,6 +204,10 @@ public sealed partial class DirectExecutionBackend
|
|||||||
{
|
{
|
||||||
RecordPerfHleCall(importStubEntry.Export?.Name ?? importStubEntry.Nid);
|
RecordPerfHleCall(importStubEntry.Export?.Name ?? importStubEntry.Nid);
|
||||||
}
|
}
|
||||||
|
if (_profileGuestRip)
|
||||||
|
{
|
||||||
|
EnsureGuestRipSampler();
|
||||||
|
}
|
||||||
int num2 = Volatile.Read(in _rawSentinelRecoveries);
|
int num2 = Volatile.Read(in _rawSentinelRecoveries);
|
||||||
if (num2 != _lastReportedRawSentinelRecoveries)
|
if (num2 != _lastReportedRawSentinelRecoveries)
|
||||||
{
|
{
|
||||||
@@ -178,6 +221,10 @@ public sealed partial class DirectExecutionBackend
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpuContext.Rip = importStubEntry.Address;
|
cpuContext.Rip = importStubEntry.Address;
|
||||||
|
if (_profileGuestRip)
|
||||||
|
{
|
||||||
|
cpuContext.ActiveImportIndex = importIndex;
|
||||||
|
}
|
||||||
LoadImportVolatileArguments(cpuContext, argPackPtr);
|
LoadImportVolatileArguments(cpuContext, argPackPtr);
|
||||||
cpuContext[CpuRegister.Rdi] = *(ulong*)argPackPtr;
|
cpuContext[CpuRegister.Rdi] = *(ulong*)argPackPtr;
|
||||||
cpuContext[CpuRegister.Rsi] = *(ulong*)(argPackPtr + 8);
|
cpuContext[CpuRegister.Rsi] = *(ulong*)(argPackPtr + 8);
|
||||||
@@ -1444,11 +1491,14 @@ public sealed partial class DirectExecutionBackend
|
|||||||
string.Equals(nid, "fzyMKs9kim0", StringComparison.Ordinal) &&
|
string.Equals(nid, "fzyMKs9kim0", StringComparison.Ordinal) &&
|
||||||
result == OrbisGen2Result.ORBIS_GEN2_ERROR_TIMED_OUT;
|
result == OrbisGen2Result.ORBIS_GEN2_ERROR_TIMED_OUT;
|
||||||
var expectedMutexTrylockBusy =
|
var expectedMutexTrylockBusy =
|
||||||
string.Equals(nid, "K-jXhbt2gn4", StringComparison.Ordinal) &&
|
(nid is "K-jXhbt2gn4" or "upoVrzMHFeE") &&
|
||||||
result == OrbisGen2Result.ORBIS_GEN2_ERROR_BUSY;
|
result == OrbisGen2Result.ORBIS_GEN2_ERROR_BUSY;
|
||||||
var expectedSemaphoreTrywaitAgain =
|
var expectedSemaphoreTrywaitAgain =
|
||||||
string.Equals(nid, "H2a+IN9TP0E", StringComparison.Ordinal) &&
|
string.Equals(nid, "H2a+IN9TP0E", StringComparison.Ordinal) &&
|
||||||
result == OrbisGen2Result.ORBIS_GEN2_ERROR_TRY_AGAIN;
|
result == OrbisGen2Result.ORBIS_GEN2_ERROR_TRY_AGAIN;
|
||||||
|
var expectedPollSemaBusy =
|
||||||
|
string.Equals(nid, "12wOHk8ywb0", StringComparison.Ordinal) &&
|
||||||
|
result == OrbisGen2Result.ORBIS_GEN2_ERROR_BUSY;
|
||||||
var expectedNetAcceptWouldBlock =
|
var expectedNetAcceptWouldBlock =
|
||||||
string.Equals(nid, "PIWqhn9oSxc", StringComparison.Ordinal) &&
|
string.Equals(nid, "PIWqhn9oSxc", StringComparison.Ordinal) &&
|
||||||
resultValue == unchecked((int)0x80410123);
|
resultValue == unchecked((int)0x80410123);
|
||||||
@@ -1458,14 +1508,19 @@ public sealed partial class DirectExecutionBackend
|
|||||||
var expectedPrivacyInvalidParameter =
|
var expectedPrivacyInvalidParameter =
|
||||||
string.Equals(nid, "D-CzAxQL0XI", StringComparison.Ordinal) &&
|
string.Equals(nid, "D-CzAxQL0XI", StringComparison.Ordinal) &&
|
||||||
resultValue == unchecked((int)0x80960009);
|
resultValue == unchecked((int)0x80960009);
|
||||||
|
var expectedPlayGoChunkEnumerationEnd =
|
||||||
|
string.Equals(nid, "uWIYLFkkwqk", StringComparison.Ordinal) &&
|
||||||
|
resultValue == unchecked((int)0x80B2000C);
|
||||||
if (!expectedFileProbeMiss &&
|
if (!expectedFileProbeMiss &&
|
||||||
!expectedTimedWaitTimeout &&
|
!expectedTimedWaitTimeout &&
|
||||||
!expectedEqueueTimeout &&
|
!expectedEqueueTimeout &&
|
||||||
!expectedMutexTrylockBusy &&
|
!expectedMutexTrylockBusy &&
|
||||||
!expectedSemaphoreTrywaitAgain &&
|
!expectedSemaphoreTrywaitAgain &&
|
||||||
|
!expectedPollSemaBusy &&
|
||||||
!expectedNetAcceptWouldBlock &&
|
!expectedNetAcceptWouldBlock &&
|
||||||
!expectedUserServiceNoEvent &&
|
!expectedUserServiceNoEvent &&
|
||||||
!expectedPrivacyInvalidParameter)
|
!expectedPrivacyInvalidParameter &&
|
||||||
|
!expectedPlayGoChunkEnumerationEnd)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,29 @@ public sealed partial class DirectExecutionBackend
|
|||||||
private static readonly bool NativeGuestWorkersDisabled =
|
private static readonly bool NativeGuestWorkersDisabled =
|
||||||
string.Equals(Environment.GetEnvironmentVariable("SHARPEMU_DISABLE_NATIVE_GUEST_WORKERS"), "1", StringComparison.Ordinal);
|
string.Equals(Environment.GetEnvironmentVariable("SHARPEMU_DISABLE_NATIVE_GUEST_WORKERS"), "1", StringComparison.Ordinal);
|
||||||
|
|
||||||
|
// Cap concurrent native-worker Runs. Astro's tbb_thead burst overlaps many
|
||||||
|
// UnmanagedCallersOnly prologues; a large prewarm + unbounded concurrency
|
||||||
|
// FailFasts (0xC0000409) mid-storm with no VEH breadcrumb. Pool size and
|
||||||
|
// in-flight Runs are separate knobs.
|
||||||
|
private static readonly int NativeWorkerMaxConcurrent = ReadNativeWorkerMaxConcurrent();
|
||||||
|
|
||||||
|
private static int ReadNativeWorkerMaxConcurrent()
|
||||||
|
{
|
||||||
|
if (int.TryParse(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_NATIVE_WORKER_MAX_CONCURRENT"),
|
||||||
|
out var parsed) &&
|
||||||
|
parsed > 0)
|
||||||
|
{
|
||||||
|
return Math.Clamp(parsed, 1, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly object _nativeWorkerGate = new();
|
private readonly object _nativeWorkerGate = new();
|
||||||
private readonly List<NativeGuestExecutor> _allNativeWorkers = new();
|
private readonly List<NativeGuestExecutor> _allNativeWorkers = new();
|
||||||
private readonly Stack<NativeGuestExecutor> _idleNativeWorkers = new();
|
private readonly Stack<NativeGuestExecutor> _idleNativeWorkers = new();
|
||||||
|
private readonly SemaphoreSlim _nativeWorkerRunLimiter = new(NativeWorkerMaxConcurrent);
|
||||||
private bool _nativeWorkersDisposed;
|
private bool _nativeWorkersDisposed;
|
||||||
private int _nativeWorkerCreationFailedLogged;
|
private int _nativeWorkerCreationFailedLogged;
|
||||||
|
|
||||||
@@ -49,6 +69,9 @@ public sealed partial class DirectExecutionBackend
|
|||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
private static extern uint WaitForSingleObject(nint hHandle, uint dwMilliseconds);
|
private static extern uint WaitForSingleObject(nint hHandle, uint dwMilliseconds);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern bool TerminateThread(nint hThread, uint dwExitCode);
|
||||||
|
|
||||||
// Runs an emitted guest entry stub. Preferred path is a pooled native worker
|
// Runs an emitted guest entry stub. Preferred path is a pooled native worker
|
||||||
// thread; falls back to the historical inline calli (guest frames above this
|
// thread; falls back to the historical inline calli (guest frames above this
|
||||||
// thread's managed frames) when workers are disabled or unavailable.
|
// thread's managed frames) when workers are disabled or unavailable.
|
||||||
@@ -56,40 +79,148 @@ public sealed partial class DirectExecutionBackend
|
|||||||
// Callers set the Active* thread-statics before emitting the stub and read the
|
// Callers set the Active* thread-statics before emitting the stub and read the
|
||||||
// yield/forced-exit flags right after this returns, so the worker outcome is
|
// yield/forced-exit flags right after this returns, so the worker outcome is
|
||||||
// copied back into this thread's statics before returning.
|
// copied back into this thread's statics before returning.
|
||||||
private unsafe int RunGuestEntryStub(void* entryStub, ulong hostRspSlot)
|
private unsafe int RunGuestEntryStub(void* entryStub, ulong hostRspSlot, bool requireNativeWorker = false)
|
||||||
{
|
{
|
||||||
var worker = RentNativeGuestExecutor();
|
// Limit in-flight native Runs before renting so the idle pool is not
|
||||||
if (worker is null)
|
// drained by threads blocked on the concurrency gate.
|
||||||
{
|
_nativeWorkerRunLimiter.Wait();
|
||||||
TlsSetValue(_hostRspSlotTlsIndex, (nint)hostRspSlot);
|
NativeGuestExecutor? worker = null;
|
||||||
return CallNativeEntry(entryStub);
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = _activeGuestThreadState;
|
// Astro can spawn a burst of tbb_thead while workers are still in
|
||||||
var nativeReturn = worker.Run(
|
// TerminateThread+respawn. Wait for a native worker — never fall back
|
||||||
_activeCpuContext!,
|
// to managed inline (FailFast) and never throw (uncaught throw mid-
|
||||||
state,
|
// storm was a silent process die).
|
||||||
GuestThreadExecution.CurrentGuestThreadHandle,
|
var maxAttempts = requireNativeWorker ? 500 : 48;
|
||||||
_activeEntryReturnSentinelRip,
|
for (var attempt = 0; attempt < maxAttempts; attempt++)
|
||||||
_activeGuestReturnSlotAddress,
|
{
|
||||||
(nint)hostRspSlot,
|
worker = RentNativeGuestExecutor();
|
||||||
(nint)entryStub,
|
if (worker is not null)
|
||||||
state?.AffinityMask ?? 0,
|
{
|
||||||
out var yieldRequested,
|
break;
|
||||||
out var yieldReason,
|
}
|
||||||
out var forcedExit);
|
|
||||||
_activeGuestThreadYieldRequested = yieldRequested;
|
if (!requireNativeWorker)
|
||||||
_activeGuestThreadYieldReason = yieldReason;
|
{
|
||||||
_activeForcedGuestExit = forcedExit;
|
break;
|
||||||
return nativeReturn;
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(attempt < 32 ? 1 : 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worker is null)
|
||||||
|
{
|
||||||
|
if (requireNativeWorker)
|
||||||
|
{
|
||||||
|
var n = Interlocked.Increment(ref _tbbNativeWorkerRefuseCount);
|
||||||
|
if (n <= 8 || n % 32 == 0)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][ERROR] tbb_native_worker unavailable #{n} after {maxAttempts} attempts; " +
|
||||||
|
"skipping run (no managed inline, no throw)");
|
||||||
|
Console.Error.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
_activeGuestThreadYieldRequested = true;
|
||||||
|
_activeGuestThreadYieldReason = "tbb_native_worker_unavailable";
|
||||||
|
_activeForcedGuestExit = true;
|
||||||
|
return unchecked((int)0x80020012);
|
||||||
|
}
|
||||||
|
|
||||||
|
TlsSetValue(_hostRspSlotTlsIndex, (nint)hostRspSlot);
|
||||||
|
return CallNativeEntry(entryStub);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var state = _activeGuestThreadState;
|
||||||
|
if (state is { Name: "tbb_thead" })
|
||||||
|
{
|
||||||
|
var n = Interlocked.Increment(ref _tbbNativeRunEnterCount);
|
||||||
|
if (n <= 12 || n % 64 == 0)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][INFO] tbb_run_enter #{n} native_tid_pending handle=0x{state.ThreadHandle:X16} " +
|
||||||
|
$"max_concurrent={NativeWorkerMaxConcurrent}");
|
||||||
|
Console.Error.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var nativeReturn = worker.Run(
|
||||||
|
_activeCpuContext!,
|
||||||
|
state,
|
||||||
|
GuestThreadExecution.CurrentGuestThreadHandle,
|
||||||
|
_activeEntryReturnSentinelRip,
|
||||||
|
_activeGuestReturnSlotAddress,
|
||||||
|
(nint)hostRspSlot,
|
||||||
|
(nint)entryStub,
|
||||||
|
state?.AffinityMask ?? 0,
|
||||||
|
out var yieldRequested,
|
||||||
|
out var yieldReason,
|
||||||
|
out var forcedExit);
|
||||||
|
_activeGuestThreadYieldRequested = yieldRequested;
|
||||||
|
_activeGuestThreadYieldReason = yieldReason;
|
||||||
|
_activeForcedGuestExit = forcedExit;
|
||||||
|
return nativeReturn;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ReturnNativeGuestExecutor(worker);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ReturnNativeGuestExecutor(worker);
|
_nativeWorkerRunLimiter.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int _tbbNativeRunEnterCount;
|
||||||
|
private static int _tbbNativeWorkerRefuseCount;
|
||||||
|
internal static int _tbbWorkerPrologueFaultCount;
|
||||||
|
|
||||||
|
private void PrewarmNativeGuestWorkers(int count)
|
||||||
|
{
|
||||||
|
if (!OperatingSystem.IsWindows() || NativeGuestWorkersDisabled || count <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var warmed = new List<NativeGuestExecutor>(count);
|
||||||
|
for (var i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var worker = NativeGuestExecutor.TryCreate(this);
|
||||||
|
if (worker is null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
warmed.Add(worker);
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_nativeWorkerGate)
|
||||||
|
{
|
||||||
|
if (_nativeWorkersDisposed)
|
||||||
|
{
|
||||||
|
foreach (var worker in warmed)
|
||||||
|
{
|
||||||
|
worker.Dispose();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var worker in warmed)
|
||||||
|
{
|
||||||
|
_allNativeWorkers.Add(worker);
|
||||||
|
_idleNativeWorkers.Push(worker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][INFO] Native guest workers prewarmed: {warmed.Count}/{count} " +
|
||||||
|
$"max_concurrent={NativeWorkerMaxConcurrent}");
|
||||||
|
Console.Error.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
private NativeGuestExecutor? RentNativeGuestExecutor()
|
private NativeGuestExecutor? RentNativeGuestExecutor()
|
||||||
{
|
{
|
||||||
// NativeGuestExecutor emits a Win32 wait loop and creates it with
|
// NativeGuestExecutor emits a Win32 wait loop and creates it with
|
||||||
@@ -400,6 +531,22 @@ public sealed partial class DirectExecutionBackend
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FlushInstructionCache(GetCurrentProcess(), _loopStub, LoopStubSize);
|
FlushInstructionCache(GetCurrentProcess(), _loopStub, LoopStubSize);
|
||||||
|
return StartWorkerThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool RestartWorkerThread()
|
||||||
|
{
|
||||||
|
if (_loopStub == null || _controlBlock == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(int*)_controlBlock = 0;
|
||||||
|
return StartWorkerThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool StartWorkerThread()
|
||||||
|
{
|
||||||
_threadHandle = CreateThread(
|
_threadHandle = CreateThread(
|
||||||
0,
|
0,
|
||||||
WorkerStackReservation,
|
WorkerStackReservation,
|
||||||
@@ -445,6 +592,49 @@ public sealed partial class DirectExecutionBackend
|
|||||||
_runForcedExit = false;
|
_runForcedExit = false;
|
||||||
SignalWorkAvailable();
|
SignalWorkAvailable();
|
||||||
WaitWorkCompleted();
|
WaitWorkCompleted();
|
||||||
|
|
||||||
|
// Normal path: RunEpilogue/ExitRun clears _entered before SetEvent(done).
|
||||||
|
// TBB abort stub SetEvent's without ExitRun — _entered stays true.
|
||||||
|
if (_entered)
|
||||||
|
{
|
||||||
|
var waitRc = WaitForSingleObject(_threadHandle, 500u);
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][WARN] Native guest worker tid={_nativeThreadId} aborted during run; " +
|
||||||
|
$"wait_rc=0x{waitRc:X8} respawning");
|
||||||
|
Console.Error.Flush();
|
||||||
|
if (_runState is { } abortedState)
|
||||||
|
{
|
||||||
|
_ = GuestThreadExecution.NotifyGuestThreadAbandoned(
|
||||||
|
abortedState.ThreadHandle,
|
||||||
|
"tbb_worker_abort");
|
||||||
|
Volatile.Write(ref abortedState.HostThreadId, _prevHostThreadId);
|
||||||
|
}
|
||||||
|
_entered = false;
|
||||||
|
if (_threadHandle != 0)
|
||||||
|
{
|
||||||
|
// Abort stub parks (no ExitThread). Force-kill the parked OS
|
||||||
|
// thread so we can recreate the loop without process teardown.
|
||||||
|
if (waitRc != 0u)
|
||||||
|
{
|
||||||
|
_ = TerminateThread(_threadHandle, unchecked((uint)(-1)));
|
||||||
|
_ = WaitForSingleObject(_threadHandle, 1000u);
|
||||||
|
}
|
||||||
|
CloseHandle(_threadHandle);
|
||||||
|
_threadHandle = 0;
|
||||||
|
_nativeThreadId = 0;
|
||||||
|
}
|
||||||
|
if (!RestartWorkerThread())
|
||||||
|
{
|
||||||
|
_runPrologueFailed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_runPrologueFailed = false;
|
||||||
|
_runForcedExit = true;
|
||||||
|
_runNativeResult = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_runContext = null;
|
_runContext = null;
|
||||||
_runState = null;
|
_runState = null;
|
||||||
yieldRequested = _runYieldRequested;
|
yieldRequested = _runYieldRequested;
|
||||||
@@ -452,7 +642,22 @@ public sealed partial class DirectExecutionBackend
|
|||||||
forcedExit = _runForcedExit;
|
forcedExit = _runForcedExit;
|
||||||
if (_runPrologueFailed)
|
if (_runPrologueFailed)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Native guest worker failed to bind the run ambient (prologue fault)");
|
// Never throw out of the native-worker rent path: an uncaught
|
||||||
|
// exception mid-TBB storm kills the process with no FailFast
|
||||||
|
// breadcrumb.
|
||||||
|
var n = Interlocked.Increment(ref _tbbWorkerPrologueFaultCount);
|
||||||
|
if (n <= 8 || n % 32 == 0)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][ERROR] tbb_worker prologue fault #{n}; soft-fail run " +
|
||||||
|
$"(tid={_nativeThreadId})");
|
||||||
|
Console.Error.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
yieldRequested = true;
|
||||||
|
yieldReason = "tbb_worker_prologue_fault";
|
||||||
|
forcedExit = true;
|
||||||
|
return unchecked((int)0x80020012);
|
||||||
}
|
}
|
||||||
return _runNativeResult;
|
return _runNativeResult;
|
||||||
}
|
}
|
||||||
@@ -546,6 +751,18 @@ public sealed partial class DirectExecutionBackend
|
|||||||
_activeGuestThreadState = _runState;
|
_activeGuestThreadState = _runState;
|
||||||
backend.BindTlsBase(_runContext!);
|
backend.BindTlsBase(_runContext!);
|
||||||
TlsSetValue(backend._hostRspSlotTlsIndex, _runHostRspSlot);
|
TlsSetValue(backend._hostRspSlotTlsIndex, _runHostRspSlot);
|
||||||
|
if (backend._workerDoneEventTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
nint doneHandle = OperatingSystem.IsWindows()
|
||||||
|
? _workCompleted!.SafeWaitHandle.DangerousGetHandle()
|
||||||
|
: _doneSemaphore;
|
||||||
|
TlsSetValue(backend._workerDoneEventTlsIndex, doneHandle);
|
||||||
|
}
|
||||||
|
if (backend._tbbAbortEligibleTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
nint eligible = _runState is { Name: "tbb_thead" } ? 1 : 0;
|
||||||
|
TlsSetValue(backend._tbbAbortEligibleTlsIndex, eligible);
|
||||||
|
}
|
||||||
if (_runState is { } state)
|
if (_runState is { } state)
|
||||||
{
|
{
|
||||||
_prevHostThreadId = Volatile.Read(ref state.HostThreadId);
|
_prevHostThreadId = Volatile.Read(ref state.HostThreadId);
|
||||||
@@ -580,6 +797,14 @@ public sealed partial class DirectExecutionBackend
|
|||||||
Volatile.Write(ref state.HostThreadId, _prevHostThreadId);
|
Volatile.Write(ref state.HostThreadId, _prevHostThreadId);
|
||||||
}
|
}
|
||||||
TlsSetValue(_backend._hostRspSlotTlsIndex, _prevHostRspSlot);
|
TlsSetValue(_backend._hostRspSlotTlsIndex, _prevHostRspSlot);
|
||||||
|
if (_backend._workerDoneEventTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
TlsSetValue(_backend._workerDoneEventTlsIndex, 0);
|
||||||
|
}
|
||||||
|
if (_backend._tbbAbortEligibleTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
TlsSetValue(_backend._tbbAbortEligibleTlsIndex, 0);
|
||||||
|
}
|
||||||
GuestThreadExecution.RestoreGuestThread(_prevGuestThreadHandle);
|
GuestThreadExecution.RestoreGuestThread(_prevGuestThreadHandle);
|
||||||
_activeExecutionBackend = _prevBackend;
|
_activeExecutionBackend = _prevBackend;
|
||||||
_activeCpuContext = _prevContext;
|
_activeCpuContext = _prevContext;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using SharpEmu.Core.Cpu.Debugging;
|
|||||||
using SharpEmu.Core.Loader;
|
using SharpEmu.Core.Loader;
|
||||||
using SharpEmu.Core.Memory;
|
using SharpEmu.Core.Memory;
|
||||||
using SharpEmu.HLE;
|
using SharpEmu.HLE;
|
||||||
|
using SharpEmu.Libs.Diagnostics;
|
||||||
|
|
||||||
namespace SharpEmu.Core.Cpu.Native;
|
namespace SharpEmu.Core.Cpu.Native;
|
||||||
|
|
||||||
@@ -214,6 +215,15 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
|
|
||||||
private nint _guestReturnStub;
|
private nint _guestReturnStub;
|
||||||
|
|
||||||
|
private nint _workerAbortStub;
|
||||||
|
private nint _vehManagedEntryLock;
|
||||||
|
|
||||||
|
private uint _workerDoneEventTlsIndex = uint.MaxValue;
|
||||||
|
|
||||||
|
private uint _tbbAbortEligibleTlsIndex = uint.MaxValue;
|
||||||
|
|
||||||
|
private nint _setEventAddress;
|
||||||
|
|
||||||
private nint _rawExceptionHandler;
|
private nint _rawExceptionHandler;
|
||||||
|
|
||||||
private nint _rawExceptionHandlerStub;
|
private nint _rawExceptionHandlerStub;
|
||||||
@@ -1041,6 +1051,8 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
_selfHandlePtr = GCHandle.ToIntPtr(_selfHandle);
|
_selfHandlePtr = GCHandle.ToIntPtr(_selfHandle);
|
||||||
_guestTlsBaseTlsIndex = TlsAlloc();
|
_guestTlsBaseTlsIndex = TlsAlloc();
|
||||||
_hostRspSlotTlsIndex = TlsAlloc();
|
_hostRspSlotTlsIndex = TlsAlloc();
|
||||||
|
_workerDoneEventTlsIndex = OperatingSystem.IsWindows() ? TlsAlloc() : uint.MaxValue;
|
||||||
|
_tbbAbortEligibleTlsIndex = OperatingSystem.IsWindows() ? TlsAlloc() : uint.MaxValue;
|
||||||
if (_guestTlsBaseTlsIndex == uint.MaxValue || _hostRspSlotTlsIndex == uint.MaxValue)
|
if (_guestTlsBaseTlsIndex == uint.MaxValue || _hostRspSlotTlsIndex == uint.MaxValue)
|
||||||
{
|
{
|
||||||
throw new OutOfMemoryException("Failed to allocate native TLS slots");
|
throw new OutOfMemoryException("Failed to allocate native TLS slots");
|
||||||
@@ -1064,6 +1076,7 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
{
|
{
|
||||||
throw new InvalidOperationException("Failed to resolve kernel32 thread timing functions");
|
throw new InvalidOperationException("Failed to resolve kernel32 thread timing functions");
|
||||||
}
|
}
|
||||||
|
_setEventAddress = kernel32 != 0 ? GetProcAddress(kernel32, "SetEvent") : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1087,13 +1100,29 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
{
|
{
|
||||||
throw new OutOfMemoryException("Failed to allocate host stack slot storage");
|
throw new OutOfMemoryException("Failed to allocate host stack slot storage");
|
||||||
}
|
}
|
||||||
|
_vehManagedEntryLock = (nint)VirtualAlloc(null, 64u, 12288u, 4u);
|
||||||
|
if (_vehManagedEntryLock == 0)
|
||||||
|
{
|
||||||
|
throw new OutOfMemoryException("Failed to allocate VEH managed-entry lock");
|
||||||
|
}
|
||||||
|
// owner (nint) + depth (int); recursive — nested VEH on same thread must reenter.
|
||||||
|
*(nint*)_vehManagedEntryLock = 0;
|
||||||
|
*(int*)(_vehManagedEntryLock + sizeof(nint)) = 0;
|
||||||
_unresolvedReturnStub = CreateUnresolvedReturnStub();
|
_unresolvedReturnStub = CreateUnresolvedReturnStub();
|
||||||
_guestReturnStub = CreateGuestReturnStub();
|
_guestReturnStub = CreateGuestReturnStub();
|
||||||
if (_guestReturnStub == 0)
|
if (_guestReturnStub == 0)
|
||||||
{
|
{
|
||||||
throw new OutOfMemoryException("Failed to allocate guest return stub");
|
throw new OutOfMemoryException("Failed to allocate guest return stub");
|
||||||
}
|
}
|
||||||
|
_workerAbortStub = CreateWorkerAbortStub();
|
||||||
|
if (_workerAbortStub == 0 && OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
"[LOADER][WARN] Worker abort stub unavailable; TBB execute-fault recover will use host_exit");
|
||||||
|
}
|
||||||
SetupExceptionHandler();
|
SetupExceptionHandler();
|
||||||
|
// Cover the Astro TBB spawn storm (often 8–12 concurrent tbb_thead).
|
||||||
|
PrewarmNativeGuestWorkers(Math.Max(NativeWorkerMaxConcurrent, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryExecute(CpuContext context, ulong entryPoint, Generation generation, IReadOnlyDictionary<ulong, string> importStubs, IReadOnlyDictionary<string, ulong> runtimeSymbols, CpuExecutionOptions executionOptions, out OrbisGen2Result result)
|
public bool TryExecute(CpuContext context, ulong entryPoint, Generation generation, IReadOnlyDictionary<ulong, string> importStubs, IReadOnlyDictionary<string, ulong> runtimeSymbols, CpuExecutionOptions executionOptions, out OrbisGen2Result result)
|
||||||
@@ -2409,9 +2438,147 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
return (nint)ptr;
|
return (nint)ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// After a TBB execute-fault, VEH redirects here on a host stack.
|
||||||
|
/// SetEvent(done) then park forever — ExitThread from VEH CONTINUE_EXECUTION
|
||||||
|
/// was taking down the whole process (recover logged, no respawning). The
|
||||||
|
/// renter TerminateThread's the parked worker and respawns a clean loop.
|
||||||
|
/// </summary>
|
||||||
|
private unsafe nint CreateWorkerAbortStub()
|
||||||
|
{
|
||||||
|
if (!OperatingSystem.IsWindows() ||
|
||||||
|
_workerDoneEventTlsIndex == uint.MaxValue ||
|
||||||
|
_tlsGetValueAddress == 0 ||
|
||||||
|
_setEventAddress == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nint kernel32 = GetModuleHandle("kernel32.dll");
|
||||||
|
nint getStdHandle = kernel32 != 0 ? GetProcAddress(kernel32, "GetStdHandle") : 0;
|
||||||
|
nint writeFile = kernel32 != 0 ? GetProcAddress(kernel32, "WriteFile") : 0;
|
||||||
|
nint flushFileBuffers = kernel32 != 0 ? GetProcAddress(kernel32, "FlushFileBuffers") : 0;
|
||||||
|
|
||||||
|
const uint stubSize = 256u;
|
||||||
|
void* ptr = VirtualAlloc(null, stubSize, 12288u, 4u);
|
||||||
|
if (ptr == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte* code = (byte*)ptr;
|
||||||
|
int offset = 0;
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28); // sub rsp, 0x28
|
||||||
|
EmitByte(code, ref offset, 0xB9);
|
||||||
|
EmitUInt32(code, ref offset, _workerDoneEventTlsIndex); // mov ecx, tls
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = _tlsGetValueAddress;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0); // call TlsGetValue
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x85);
|
||||||
|
EmitByte(code, ref offset, 0xC0); // test rax, rax
|
||||||
|
EmitByte(code, ref offset, 0x74); EmitByte(code, ref offset, 0x0F); // jz skip SetEvent (15 bytes)
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0xC1); // mov rcx, rax
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = _setEventAddress;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0); // call SetEvent
|
||||||
|
|
||||||
|
// Breadcrumb on host stack (survives silent teardown better than managed log).
|
||||||
|
int msgAbsSlot = -1;
|
||||||
|
if (getStdHandle != 0 && writeFile != 0)
|
||||||
|
{
|
||||||
|
ReadOnlySpan<byte> msg = "[LOADER][WARN] tbb_abort_stub SetEvent+park\n"u8;
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x20); // extra shadow for WriteFile args
|
||||||
|
EmitByte(code, ref offset, 0xB9); EmitUInt32(code, ref offset, unchecked((uint)-12));
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = getStdHandle;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0xC1); // mov rcx, handle
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0xC3); // mov rbx, handle (nonvolatile for flush)
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
msgAbsSlot = offset;
|
||||||
|
*(nint*)(code + offset) = 0;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0xC2); // mov rdx, msg
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xB8);
|
||||||
|
EmitUInt32(code, ref offset, (uint)msg.Length);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20); // lea r9, [rsp+0x20]
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x28); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = writeFile;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
if (flushFileBuffers != 0)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0xD9); // mov rcx, rbx
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = flushFileBuffers;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
}
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Park: do not ExitThread (process-wide silent die after VEH redirect).
|
||||||
|
int parkOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0xF3); EmitByte(code, ref offset, 0x90); // pause
|
||||||
|
EmitByte(code, ref offset, 0xEB);
|
||||||
|
EmitByte(code, ref offset, unchecked((byte)(parkOffset - (offset + 1)))); // jmp park
|
||||||
|
|
||||||
|
if (msgAbsSlot >= 0)
|
||||||
|
{
|
||||||
|
ReadOnlySpan<byte> msgEmbed = "[LOADER][WARN] tbb_abort_stub SetEvent+park\n"u8;
|
||||||
|
*(nint*)(code + msgAbsSlot) = (nint)ptr + offset;
|
||||||
|
for (int i = 0; i < msgEmbed.Length; i++)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, msgEmbed[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset > (int)stubSize)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][ERROR] Worker abort stub overflow: used={offset} cap={stubSize}");
|
||||||
|
VirtualFree(ptr, 0u, 32768u);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint oldProtect = default;
|
||||||
|
if (!VirtualProtect(ptr, stubSize, 32u, &oldProtect))
|
||||||
|
{
|
||||||
|
VirtualFree(ptr, 0u, 32768u);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FlushInstructionCache(GetCurrentProcess(), ptr, (nuint)offset);
|
||||||
|
return (nint)ptr;
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe nint CreateExceptionHandlerTrampoline(nint managedHandler)
|
private unsafe nint CreateExceptionHandlerTrampoline(nint managedHandler)
|
||||||
{
|
{
|
||||||
const uint stubSize = 256u;
|
// Live VEH trampoline used by SetupExceptionHandler. Must pre-filter
|
||||||
|
// FastFail / CLR / MSVC C++ / stack-overflow the same way as
|
||||||
|
// WindowsFaultHandling.CreateHandlerThunk: entering managed VEH while
|
||||||
|
// the thread is in cooperative GC mode fail-fasts with
|
||||||
|
// "UnmanagedCallersOnly method from managed code" (tLT18–22).
|
||||||
|
// Extra headroom for native tbb abort + recursive managed-entry spinlock.
|
||||||
|
const uint stubSize = 2048u;
|
||||||
void* ptr = VirtualAlloc(null, stubSize, 12288u, 64u);
|
void* ptr = VirtualAlloc(null, stubSize, 12288u, 64u);
|
||||||
if (ptr == null)
|
if (ptr == null)
|
||||||
{
|
{
|
||||||
@@ -2420,10 +2587,305 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
|
|
||||||
byte* code = (byte*)ptr;
|
byte* code = (byte*)ptr;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
|
ReadOnlySpan<uint> nonManagedExceptionCodes =
|
||||||
|
[
|
||||||
|
0xE0434352u, // CLR managed exception
|
||||||
|
0xE06D7363u, // MSVC C++ exception
|
||||||
|
0xC0000409u, // STATUS_STACK_BUFFER_OVERRUN / FailFast
|
||||||
|
0xC00000FDu, // STATUS_STACK_OVERFLOW
|
||||||
|
];
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x01); // mov rax, [rcx]
|
||||||
|
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x00); // mov eax, [rax] ExceptionCode
|
||||||
|
var passJumpOffsets = stackalloc int[nonManagedExceptionCodes.Length];
|
||||||
|
int fastFailJumpSlot = -1;
|
||||||
|
for (int i = 0; i < nonManagedExceptionCodes.Length; i++)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, 0x3D);
|
||||||
|
EmitUInt32(code, ref offset, nonManagedExceptionCodes[i]);
|
||||||
|
EmitByte(code, ref offset, 0x74);
|
||||||
|
passJumpOffsets[i] = offset;
|
||||||
|
EmitByte(code, ref offset, 0x00);
|
||||||
|
if (nonManagedExceptionCodes[i] == 0xC0000409u)
|
||||||
|
{
|
||||||
|
fastFailJumpSlot = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0xE9); // jmp mainBody (rel32; FastFail breadcrumb sits between)
|
||||||
|
var mainBodyJumpSlot = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
|
||||||
|
int passOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0x31); EmitByte(code, ref offset, 0xC0); // xor eax, eax
|
||||||
|
EmitByte(code, ref offset, 0xC3);
|
||||||
|
|
||||||
|
int fastFailPassOffset = offset;
|
||||||
|
var fastFailLogInstalled = false;
|
||||||
|
nint kernel32 = GetModuleHandle("kernel32.dll");
|
||||||
|
nint getStdHandle = kernel32 != 0 ? GetProcAddress(kernel32, "GetStdHandle") : 0;
|
||||||
|
nint writeFile = kernel32 != 0 ? GetProcAddress(kernel32, "WriteFile") : 0;
|
||||||
|
if (fastFailJumpSlot >= 0 && getStdHandle != 0 && writeFile != 0)
|
||||||
|
{
|
||||||
|
// Prefix + Context.Rip hex (AMD64 CONTEXT.Rip @ 0xF8) + newline.
|
||||||
|
// Keep in sync with WindowsFaultHandling.CreateHandlerThunk.
|
||||||
|
ReadOnlySpan<byte> msg =
|
||||||
|
"[LOADER][FATAL] VEH_PASS FastFail 0xC0000409 (live trampoline; skip managed VEH) rip=0x"u8;
|
||||||
|
ReadOnlySpan<byte> hexDigits = "0123456789ABCDEF"u8;
|
||||||
|
// rcx=EXCEPTION_POINTERS*: capture Rip into r10 before clobbering.
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x41);
|
||||||
|
EmitByte(code, ref offset, 0x08); // mov rax, [rcx+8] ContextRecord*
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x90);
|
||||||
|
EmitUInt32(code, ref offset, 0xF8u); // mov r10, [rax+0xF8] Rip
|
||||||
|
EmitByte(code, ref offset, 0x50);
|
||||||
|
EmitByte(code, ref offset, 0x51);
|
||||||
|
EmitByte(code, ref offset, 0x52);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x50);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x51);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x52); // push r10 (Rip)
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x40); // sub rsp, 0x40 (hex buf @ +0x30)
|
||||||
|
EmitByte(code, ref offset, 0xB9); EmitUInt32(code, ref offset, unchecked((uint)-12));
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = getStdHandle;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x28); // mov [rsp+0x28], rax stderr handle
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xC1);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
var msgAbsSlot = offset;
|
||||||
|
*(nint*)(code + offset) = 0;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xC2);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xB8);
|
||||||
|
EmitUInt32(code, ref offset, (uint)msg.Length);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x38); EmitUInt32(code, ref offset, 0); // lpOverlapped slot
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = writeFile;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
|
||||||
|
// Hex-encode Rip. Stack after sub 0x40: [rsp+0x40]=saved Rip (push r10).
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x54); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x40); // mov r10, [rsp+0x40]
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xB8);
|
||||||
|
var hexDigitsAbsSlot = offset;
|
||||||
|
*(nint*)(code + offset) = 0;
|
||||||
|
offset += sizeof(nint); // mov r8, hexDigits
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x5C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x30); // lea r11, [rsp+0x30] hex out
|
||||||
|
EmitByte(code, ref offset, 0xB9); EmitUInt32(code, ref offset, 16u); // ecx = 16 nibbles
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xD0); // mov rax, r10
|
||||||
|
int hexLoopOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC1); EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0x04); // rol rax, 4
|
||||||
|
EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xC2); // mov edx, eax
|
||||||
|
EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xE2); EmitByte(code, ref offset, 0x0F); // and edx, 0xF
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0xB6);
|
||||||
|
EmitByte(code, ref offset, 0x14); EmitByte(code, ref offset, 0x10); // movzx edx, byte [r8+rdx]
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x88); EmitByte(code, ref offset, 0x13); // mov [r11], dl
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xC3); // inc r11
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xC9); // dec ecx
|
||||||
|
EmitByte(code, ref offset, 0x75);
|
||||||
|
EmitByte(code, ref offset, unchecked((byte)(hexLoopOffset - (offset + 1)))); // jnz hexLoop (rel8)
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xC6); EmitByte(code, ref offset, 0x03);
|
||||||
|
EmitByte(code, ref offset, 0x0A); // mov byte [r11], '\n'
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x28); // mov rcx, [rsp+0x28] stderr
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x54); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x30); // lea rdx, [rsp+0x30]
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xB8);
|
||||||
|
EmitUInt32(code, ref offset, 17u); // 16 hex + newline
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x38); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = writeFile;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
|
||||||
|
// Flush redirected stderr so FastFail rip survives process teardown.
|
||||||
|
nint flushFileBuffers = kernel32 != 0 ? GetProcAddress(kernel32, "FlushFileBuffers") : 0;
|
||||||
|
if (flushFileBuffers != 0)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x28); // mov rcx, stderr
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = flushFileBuffers;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
}
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x40);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x5A); // pop r10
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x59);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x58);
|
||||||
|
EmitByte(code, ref offset, 0x5A);
|
||||||
|
EmitByte(code, ref offset, 0x59);
|
||||||
|
EmitByte(code, ref offset, 0x58);
|
||||||
|
EmitByte(code, ref offset, 0x31); EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0xC3);
|
||||||
|
|
||||||
|
var msgOffset = offset;
|
||||||
|
for (int i = 0; i < msg.Length; i++)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, msg[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var hexDigitsOffset = offset;
|
||||||
|
for (int i = 0; i < hexDigits.Length; i++)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, hexDigits[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(nint*)(code + msgAbsSlot) = (nint)ptr + msgOffset;
|
||||||
|
*(nint*)(code + hexDigitsAbsSlot) = (nint)ptr + hexDigitsOffset;
|
||||||
|
code[passJumpOffsets[fastFailJumpSlot]] =
|
||||||
|
checked((byte)(fastFailPassOffset - (passJumpOffsets[fastFailJumpSlot] + 1)));
|
||||||
|
fastFailLogInstalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mainBodyOffset = offset;
|
||||||
|
*(int*)(code + mainBodyJumpSlot) = mainBodyOffset - (mainBodyJumpSlot + sizeof(int));
|
||||||
|
for (int i = 0; i < nonManagedExceptionCodes.Length; i++)
|
||||||
|
{
|
||||||
|
if (i == fastFailJumpSlot && fastFailLogInstalled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
code[passJumpOffsets[i]] = checked((byte)(passOffset - (passJumpOffsets[i] + 1)));
|
||||||
|
}
|
||||||
|
|
||||||
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x54); // push r12
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x54); // push r12
|
||||||
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x55); // push r13
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x55); // push r13
|
||||||
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xE4); // mov r12, rsp
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xE4); // mov r12, rsp
|
||||||
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xCD); // mov r13, rcx
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xCD); // mov r13, rcx
|
||||||
|
|
||||||
|
// Native worker EXECUTE-AV abort without managed VEH.
|
||||||
|
// Do NOT catch read/write AVs — workers need managed lazy-commit (tLTJ
|
||||||
|
// silent-die when every worker AV was aborted). Execute faults on
|
||||||
|
// tbb_thead are the concurrent-managed FailFast case (tLTC).
|
||||||
|
int tbbFallthroughJump = -1;
|
||||||
|
if (_workerAbortStub != 0 &&
|
||||||
|
_tlsGetValueAddress != 0 &&
|
||||||
|
_hostRspSlotTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x45); EmitByte(code, ref offset, 0x00); // mov rax, [r13]
|
||||||
|
EmitByte(code, ref offset, 0x81); EmitByte(code, ref offset, 0x38);
|
||||||
|
EmitUInt32(code, ref offset, 0xC0000005u); // cmp dword [rax], AV
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
tbbFallthroughJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u); // jne fallthrough
|
||||||
|
|
||||||
|
// ExceptionInformation[0] == 8 → EXECUTE (DEP). Offset 32 on x64 RECORD.
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xB8); EmitUInt32(code, ref offset, 32u);
|
||||||
|
EmitByte(code, ref offset, 0x08); // cmp qword [rax+32], 8
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
var tbbNotExecuteJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
|
||||||
|
int tbbNotEligibleJump = -1;
|
||||||
|
if (_tbbAbortEligibleTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28);
|
||||||
|
EmitByte(code, ref offset, 0xB9);
|
||||||
|
EmitUInt32(code, ref offset, _tbbAbortEligibleTlsIndex);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = _tlsGetValueAddress;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x28);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x85);
|
||||||
|
EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x84);
|
||||||
|
tbbNotEligibleJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
}
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28);
|
||||||
|
EmitByte(code, ref offset, 0xB9);
|
||||||
|
EmitUInt32(code, ref offset, _hostRspSlotTlsIndex);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = _tlsGetValueAddress;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x28);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x85);
|
||||||
|
EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x84);
|
||||||
|
var tbbNoHostRspJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x00); // mov r8, [rax] hostRsp
|
||||||
|
EmitByte(code, ref offset, 0x4D); EmitByte(code, ref offset, 0x85);
|
||||||
|
EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x84);
|
||||||
|
var tbbZeroRspJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xE0); EmitByte(code, ref offset, 0xF0); // and r8, ~0xF
|
||||||
|
EmitByte(code, ref offset, 0x4D); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x4D); EmitByte(code, ref offset, 0x08); // mov r9, [r13+8]
|
||||||
|
EmitByte(code, ref offset, 0x4D); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0x81); EmitUInt32(code, ref offset, 0x98u); // Context.Rsp
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = _workerAbortStub;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0x81); EmitUInt32(code, ref offset, 0xF8u); // Context.Rip
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x78);
|
||||||
|
EmitUInt32(code, ref offset, 0u); // Context.Rax = 0
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0xB8); EmitUInt32(code, ref offset, unchecked((uint)-1));
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0xE4); // mov rsp, r12
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x5D);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x5C);
|
||||||
|
EmitByte(code, ref offset, 0xC3);
|
||||||
|
|
||||||
|
int tbbFallthroughOffset = offset;
|
||||||
|
*(int*)(code + tbbFallthroughJump) = tbbFallthroughOffset - (tbbFallthroughJump + sizeof(int));
|
||||||
|
*(int*)(code + tbbNotExecuteJump) = tbbFallthroughOffset - (tbbNotExecuteJump + sizeof(int));
|
||||||
|
if (tbbNotEligibleJump >= 0)
|
||||||
|
{
|
||||||
|
*(int*)(code + tbbNotEligibleJump) = tbbFallthroughOffset - (tbbNotEligibleJump + sizeof(int));
|
||||||
|
}
|
||||||
|
*(int*)(code + tbbNoHostRspJump) = tbbFallthroughOffset - (tbbNoHostRspJump + sizeof(int));
|
||||||
|
*(int*)(code + tbbZeroRspJump) = tbbFallthroughOffset - (tbbZeroRspJump + sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
EmitByte(code, ref offset, 0x65); EmitByte(code, ref offset, 0x48); // mov rax, gs:[8]
|
EmitByte(code, ref offset, 0x65); EmitByte(code, ref offset, 0x48); // mov rax, gs:[8]
|
||||||
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x04); EmitByte(code, ref offset, 0x25);
|
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x04); EmitByte(code, ref offset, 0x25);
|
||||||
EmitUInt32(code, ref offset, 8u);
|
EmitUInt32(code, ref offset, 8u);
|
||||||
@@ -2440,11 +2902,67 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
EmitUInt32(code, ref offset, 0u);
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28);
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28);
|
||||||
|
// Serialize managed VEH entry (recursive spinlock). Concurrent UnmanagedCallersOnly
|
||||||
|
// FailFast was the tLTQ silent mid-TBB pattern (enter without abort breadcrumb).
|
||||||
|
// Lock layout: [0]=owner UniqueThread (nint), [8]=depth (int).
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xB9);
|
||||||
|
*(nint*)(code + offset) = _vehManagedEntryLock;
|
||||||
|
offset += sizeof(nint); // mov r9, lock*
|
||||||
|
EmitByte(code, ref offset, 0x65); EmitByte(code, ref offset, 0x4C);
|
||||||
|
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x14);
|
||||||
|
EmitByte(code, ref offset, 0x25); EmitUInt32(code, ref offset, 0x48u); // mov r10, gs:[0x48]
|
||||||
|
int hostAcquireSpin = offset;
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x01); // mov rax, [r9]
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x39); EmitByte(code, ref offset, 0xD0); // cmp rax, r10
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x84);
|
||||||
|
int hostMineJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x85); EmitByte(code, ref offset, 0xC0); // test rax, rax
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
int hostPauseJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0xF0); EmitByte(code, ref offset, 0x4C);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0xB1); EmitByte(code, ref offset, 0x11); // lock cmpxchg [r9], r10
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
int hostRetryJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x08);
|
||||||
|
EmitUInt32(code, ref offset, 1u); // mov dword [r9+8], 1
|
||||||
|
EmitByte(code, ref offset, 0xE9);
|
||||||
|
int hostGotJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
int hostPauseOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0xF3); EmitByte(code, ref offset, 0x90); // pause
|
||||||
|
EmitByte(code, ref offset, 0xE9);
|
||||||
|
int hostPauseBackJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
int hostMineOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xFF);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x08); // inc dword [r9+8]
|
||||||
|
int hostGotOffset = offset;
|
||||||
|
*(int*)(code + hostMineJump) = hostMineOffset - (hostMineJump + sizeof(int));
|
||||||
|
*(int*)(code + hostPauseJump) = hostPauseOffset - (hostPauseJump + sizeof(int));
|
||||||
|
*(int*)(code + hostRetryJump) = hostAcquireSpin - (hostRetryJump + sizeof(int));
|
||||||
|
*(int*)(code + hostGotJump) = hostGotOffset - (hostGotJump + sizeof(int));
|
||||||
|
*(int*)(code + hostPauseBackJump) = hostAcquireSpin - (hostPauseBackJump + sizeof(int));
|
||||||
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xE9); // mov rcx, r13
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xE9); // mov rcx, r13
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
*(nint*)(code + offset) = managedHandler;
|
*(nint*)(code + offset) = managedHandler;
|
||||||
offset += sizeof(nint);
|
offset += sizeof(nint);
|
||||||
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xB9);
|
||||||
|
*(nint*)(code + offset) = _vehManagedEntryLock;
|
||||||
|
offset += sizeof(nint); // mov r9, lock*
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xFF);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x08); // dec dword [r9+8]
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
int hostStillJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x01); EmitUInt32(code, ref offset, 0u); // mov qword [r9], 0
|
||||||
|
int hostStillOffset = offset;
|
||||||
|
*(int*)(code + hostStillJump) = hostStillOffset - (hostStillJump + sizeof(int));
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x28);
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x28);
|
||||||
EmitByte(code, ref offset, 0xE9);
|
EmitByte(code, ref offset, 0xE9);
|
||||||
int hostRestoreJump = offset;
|
int hostRestoreJump = offset;
|
||||||
@@ -2470,11 +2988,64 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
EmitUInt32(code, ref offset, 0u);
|
EmitUInt32(code, ref offset, 0u);
|
||||||
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xDC); // mov rsp, r11
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xDC); // mov rsp, r11
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28);
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x28);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xB9);
|
||||||
|
*(nint*)(code + offset) = _vehManagedEntryLock;
|
||||||
|
offset += sizeof(nint); // mov r9, lock*
|
||||||
|
EmitByte(code, ref offset, 0x65); EmitByte(code, ref offset, 0x4C);
|
||||||
|
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x14);
|
||||||
|
EmitByte(code, ref offset, 0x25); EmitUInt32(code, ref offset, 0x48u); // mov r10, gs:[0x48]
|
||||||
|
int guestAcquireSpin = offset;
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x01); // mov rax, [r9]
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x39); EmitByte(code, ref offset, 0xD0); // cmp rax, r10
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x84);
|
||||||
|
int guestMineJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x85); EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
int guestPauseJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0xF0); EmitByte(code, ref offset, 0x4C);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0xB1); EmitByte(code, ref offset, 0x11);
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
int guestRetryJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x08);
|
||||||
|
EmitUInt32(code, ref offset, 1u);
|
||||||
|
EmitByte(code, ref offset, 0xE9);
|
||||||
|
int guestGotJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
int guestPauseOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0xF3); EmitByte(code, ref offset, 0x90);
|
||||||
|
EmitByte(code, ref offset, 0xE9);
|
||||||
|
int guestPauseBackJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
int guestMineOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xFF);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x08);
|
||||||
|
int guestGotOffset = offset;
|
||||||
|
*(int*)(code + guestMineJump) = guestMineOffset - (guestMineJump + sizeof(int));
|
||||||
|
*(int*)(code + guestPauseJump) = guestPauseOffset - (guestPauseJump + sizeof(int));
|
||||||
|
*(int*)(code + guestRetryJump) = guestAcquireSpin - (guestRetryJump + sizeof(int));
|
||||||
|
*(int*)(code + guestGotJump) = guestGotOffset - (guestGotJump + sizeof(int));
|
||||||
|
*(int*)(code + guestPauseBackJump) = guestAcquireSpin - (guestPauseBackJump + sizeof(int));
|
||||||
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xE9); // mov rcx, r13
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xE9); // mov rcx, r13
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
*(nint*)(code + offset) = managedHandler;
|
*(nint*)(code + offset) = managedHandler;
|
||||||
offset += sizeof(nint);
|
offset += sizeof(nint);
|
||||||
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xB9);
|
||||||
|
*(nint*)(code + offset) = _vehManagedEntryLock;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xFF);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0x08); // dec dword [r9+8]
|
||||||
|
EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0x85);
|
||||||
|
int guestStillJump = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x01); EmitUInt32(code, ref offset, 0u);
|
||||||
|
int guestStillOffset = offset;
|
||||||
|
*(int*)(code + guestStillJump) = guestStillOffset - (guestStillJump + sizeof(int));
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x28);
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x28);
|
||||||
EmitByte(code, ref offset, 0xE9);
|
EmitByte(code, ref offset, 0xE9);
|
||||||
int guestRestoreJump = offset;
|
int guestRestoreJump = offset;
|
||||||
@@ -2495,6 +3066,18 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
*(int*)(code + missingHostStackJump) = passThroughOffset - (missingHostStackJump + sizeof(int));
|
*(int*)(code + missingHostStackJump) = passThroughOffset - (missingHostStackJump + sizeof(int));
|
||||||
*(int*)(code + guestRestoreJump) = restoreOffset - (guestRestoreJump + sizeof(int));
|
*(int*)(code + guestRestoreJump) = restoreOffset - (guestRestoreJump + sizeof(int));
|
||||||
|
|
||||||
|
if (offset > (int)stubSize)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][ERROR] Exception handler trampoline overflow: used={offset} cap={stubSize}");
|
||||||
|
VirtualFree(ptr, 0, 0x8000u);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[LOADER][INFO] VEH trampoline built: bytes={offset} native_worker_abort=" +
|
||||||
|
$"{(_workerAbortStub != 0 && _hostRspSlotTlsIndex != uint.MaxValue)}");
|
||||||
|
|
||||||
uint oldProtect = default;
|
uint oldProtect = default;
|
||||||
VirtualProtect(ptr, stubSize, 32u, &oldProtect);
|
VirtualProtect(ptr, stubSize, 32u, &oldProtect);
|
||||||
FlushInstructionCache(GetCurrentProcess(), ptr, (nuint)offset);
|
FlushInstructionCache(GetCurrentProcess(), ptr, (nuint)offset);
|
||||||
@@ -3069,6 +3652,7 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
$"[LOADER][INFO] Scheduled guest thread '{thread.Name}' handle=0x{thread.ThreadHandle:X16} " +
|
$"[LOADER][INFO] Scheduled guest thread '{thread.Name}' handle=0x{thread.ThreadHandle:X16} " +
|
||||||
$"entry=0x{thread.EntryPoint:X16} arg=0x{thread.Argument:X16} priority={thread.Priority} " +
|
$"entry=0x{thread.EntryPoint:X16} arg=0x{thread.Argument:X16} priority={thread.Priority} " +
|
||||||
$"host_priority={MapGuestThreadPriority(thread.Priority)} affinity=0x{thread.AffinityMask:X}");
|
$"host_priority={MapGuestThreadPriority(thread.Priority)} affinity=0x{thread.AffinityMask:X}");
|
||||||
|
LoadProgressDiagnostics.ArmIfNorthAudioThread(thread.Name);
|
||||||
Pump(creatorContext, "pthread_create");
|
Pump(creatorContext, "pthread_create");
|
||||||
// Pump is suppressed while another cooperative dispatch is active. The
|
// Pump is suppressed while another cooperative dispatch is active. The
|
||||||
// background dispatcher would eventually observe this thread, but an
|
// background dispatcher would eventually observe this thread, but an
|
||||||
@@ -4730,7 +5314,7 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
var hostCpu = processorCount < 8
|
var hostCpu = processorCount < 8
|
||||||
? guestCpu % processorCount
|
? guestCpu % processorCount
|
||||||
: processorCount >= 16
|
: processorCount >= 16
|
||||||
? guestCpu * 2
|
? MapGuestCpuAcrossSmtLanes(guestCpu, processorCount)
|
||||||
: guestCpu;
|
: guestCpu;
|
||||||
if (hostCpu < processorCount)
|
if (hostCpu < processorCount)
|
||||||
{
|
{
|
||||||
@@ -4741,6 +5325,45 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
return hostAffinityMask;
|
return hostAffinityMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Places guest CPUs on distinct physical cores first, then wraps onto the
|
||||||
|
/// SMT siblings. Doubling the index alone only works while the title stays
|
||||||
|
/// inside the first half of the guest CPU set: beyond that every mapped lane
|
||||||
|
/// lands past the host's processor count and gets dropped, which silently
|
||||||
|
/// leaves those threads unpinned. Demon's Souls asks for CPUs 0-12 and keeps
|
||||||
|
/// its renderer on 9 and 11, so dropping the overflow un-pinned both the
|
||||||
|
/// renderer and a third of its job pool onto every core at once.
|
||||||
|
/// </summary>
|
||||||
|
private static int MapGuestCpuAcrossSmtLanes(int guestCpu, int processorCount)
|
||||||
|
{
|
||||||
|
// Reserve the top lanes for the emulator itself. A title sized for a
|
||||||
|
// console's dedicated cores will happily keep a worker per guest CPU
|
||||||
|
// spinning on an empty queue — Demon's Souls' job pool runs ~90% busy
|
||||||
|
// doing nothing — and spreading those across every host lane leaves the
|
||||||
|
// GPU translation and present threads fighting them for a slice. Packing
|
||||||
|
// near-idle spinners tighter costs them almost nothing and buys back
|
||||||
|
// whole cores for the work that actually produces frames.
|
||||||
|
var usableLanes = Math.Max(processorCount - EmulatorReservedLanes, 2);
|
||||||
|
var physicalCores = usableLanes / 2;
|
||||||
|
var lane = guestCpu % usableLanes;
|
||||||
|
return lane < physicalCores
|
||||||
|
? lane * 2
|
||||||
|
: ((lane - physicalCores) * 2) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Host lanes kept away from guest threads. Measured on a 16-lane host with
|
||||||
|
/// Demon's Souls: reserving 0/4/6/8 lanes gave 6.08/6.78/7.20/5.62 fps, so
|
||||||
|
/// the useful range is a bit over a third of the machine — too few and the
|
||||||
|
/// emulator is crowded out, too many and the guest cannot make progress.
|
||||||
|
/// </summary>
|
||||||
|
private static readonly int EmulatorReservedLanes =
|
||||||
|
int.TryParse(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_RESERVED_HOST_LANES"),
|
||||||
|
out var reserved) && reserved >= 0
|
||||||
|
? reserved
|
||||||
|
: Math.Max(2, Environment.ProcessorCount * 3 / 8);
|
||||||
|
|
||||||
public bool TrySetGuestThreadPriority(ulong guestThreadHandle, int guestPriority)
|
public bool TrySetGuestThreadPriority(ulong guestThreadHandle, int guestPriority)
|
||||||
{
|
{
|
||||||
lock (_guestThreadGate)
|
lock (_guestThreadGate)
|
||||||
@@ -5149,16 +5772,27 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
return GuestNativeCallExitReason.Exception;
|
return GuestNativeCallExitReason.Exception;
|
||||||
}
|
}
|
||||||
FlushInstructionCache(GetCurrentProcess(), ptr, stubSize);
|
FlushInstructionCache(GetCurrentProcess(), ptr, stubSize);
|
||||||
if (!TlsSetValue(_hostRspSlotTlsIndex, (nint)hostRspSlot))
|
|
||||||
{
|
|
||||||
reason = "failed to bind host-RSP storage for guest thread stub";
|
|
||||||
return GuestNativeCallExitReason.Exception;
|
|
||||||
}
|
|
||||||
ActiveGuestThreadYieldRequested = false;
|
ActiveGuestThreadYieldRequested = false;
|
||||||
ActiveGuestThreadYieldReason = null;
|
ActiveGuestThreadYieldReason = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var nativeReturn = CallNativeEntry(ptr);
|
// TBB execute-AV recover needs native-worker TLS (eligible/done).
|
||||||
|
// Other guests stay on CallNativeEntry — full native-worker migration
|
||||||
|
// increased splash hangs / UnmanagedCallersOnly (tLTN/tLTO).
|
||||||
|
int nativeReturn;
|
||||||
|
if (name == "tbb_thead")
|
||||||
|
{
|
||||||
|
nativeReturn = RunGuestEntryStub(ptr, hostRspSlot, requireNativeWorker: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!TlsSetValue(_hostRspSlotTlsIndex, (nint)hostRspSlot))
|
||||||
|
{
|
||||||
|
reason = "failed to bind host-RSP storage for guest thread stub";
|
||||||
|
return GuestNativeCallExitReason.Exception;
|
||||||
|
}
|
||||||
|
nativeReturn = CallNativeEntry(ptr);
|
||||||
|
}
|
||||||
if (ActiveGuestThreadYieldRequested)
|
if (ActiveGuestThreadYieldRequested)
|
||||||
{
|
{
|
||||||
reason = ActiveGuestThreadYieldReason ?? "guest thread blocked";
|
reason = ActiveGuestThreadYieldReason ?? "guest thread blocked";
|
||||||
@@ -5304,16 +5938,24 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
return GuestNativeCallExitReason.Exception;
|
return GuestNativeCallExitReason.Exception;
|
||||||
}
|
}
|
||||||
FlushInstructionCache(GetCurrentProcess(), ptr, stubSize);
|
FlushInstructionCache(GetCurrentProcess(), ptr, stubSize);
|
||||||
if (!TlsSetValue(_hostRspSlotTlsIndex, (nint)hostRspSlot))
|
|
||||||
{
|
|
||||||
reason = "failed to bind host-RSP storage for guest continuation stub";
|
|
||||||
return GuestNativeCallExitReason.Exception;
|
|
||||||
}
|
|
||||||
ActiveGuestThreadYieldRequested = false;
|
ActiveGuestThreadYieldRequested = false;
|
||||||
ActiveGuestThreadYieldReason = null;
|
ActiveGuestThreadYieldReason = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var nativeReturn = CallNativeEntry(ptr);
|
int nativeReturn;
|
||||||
|
if (name == "tbb_thead")
|
||||||
|
{
|
||||||
|
nativeReturn = RunGuestEntryStub(ptr, hostRspSlot, requireNativeWorker: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!TlsSetValue(_hostRspSlotTlsIndex, (nint)hostRspSlot))
|
||||||
|
{
|
||||||
|
reason = "failed to bind host-RSP storage for guest continuation stub";
|
||||||
|
return GuestNativeCallExitReason.Exception;
|
||||||
|
}
|
||||||
|
nativeReturn = CallNativeEntry(ptr);
|
||||||
|
}
|
||||||
if (ActiveGuestThreadYieldRequested)
|
if (ActiveGuestThreadYieldRequested)
|
||||||
{
|
{
|
||||||
reason = ActiveGuestThreadYieldReason ?? "guest thread blocked";
|
reason = ActiveGuestThreadYieldReason ?? "guest thread blocked";
|
||||||
@@ -6446,6 +7088,16 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
VirtualFree((void*)_hostRspSlotStorage, 0u, 32768u);
|
VirtualFree((void*)_hostRspSlotStorage, 0u, 32768u);
|
||||||
_hostRspSlotStorage = 0;
|
_hostRspSlotStorage = 0;
|
||||||
}
|
}
|
||||||
|
if (_vehManagedEntryLock != 0)
|
||||||
|
{
|
||||||
|
VirtualFree((void*)_vehManagedEntryLock, 0u, 32768u);
|
||||||
|
_vehManagedEntryLock = 0;
|
||||||
|
}
|
||||||
|
if (_workerAbortStack != 0)
|
||||||
|
{
|
||||||
|
VirtualFree((void*)_workerAbortStack, 0u, 32768u);
|
||||||
|
_workerAbortStack = 0;
|
||||||
|
}
|
||||||
if (_guestTlsBaseTlsIndex != uint.MaxValue)
|
if (_guestTlsBaseTlsIndex != uint.MaxValue)
|
||||||
{
|
{
|
||||||
TlsFree(_guestTlsBaseTlsIndex);
|
TlsFree(_guestTlsBaseTlsIndex);
|
||||||
@@ -6456,6 +7108,11 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
TlsFree(_hostRspSlotTlsIndex);
|
TlsFree(_hostRspSlotTlsIndex);
|
||||||
_hostRspSlotTlsIndex = uint.MaxValue;
|
_hostRspSlotTlsIndex = uint.MaxValue;
|
||||||
}
|
}
|
||||||
|
if (_workerDoneEventTlsIndex != uint.MaxValue)
|
||||||
|
{
|
||||||
|
TlsFree(_workerDoneEventTlsIndex);
|
||||||
|
_workerDoneEventTlsIndex = uint.MaxValue;
|
||||||
|
}
|
||||||
if (_unresolvedReturnStub != 0)
|
if (_unresolvedReturnStub != 0)
|
||||||
{
|
{
|
||||||
VirtualFree((void*)_unresolvedReturnStub, 0u, 32768u);
|
VirtualFree((void*)_unresolvedReturnStub, 0u, 32768u);
|
||||||
@@ -6466,6 +7123,11 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
|||||||
VirtualFree((void*)_guestReturnStub, 0u, 32768u);
|
VirtualFree((void*)_guestReturnStub, 0u, 32768u);
|
||||||
_guestReturnStub = 0;
|
_guestReturnStub = 0;
|
||||||
}
|
}
|
||||||
|
if (_workerAbortStub != 0)
|
||||||
|
{
|
||||||
|
VirtualFree((void*)_workerAbortStub, 0u, 32768u);
|
||||||
|
_workerAbortStub = 0;
|
||||||
|
}
|
||||||
if (_guestContextTransferStub != 0)
|
if (_guestContextTransferStub != 0)
|
||||||
{
|
{
|
||||||
VirtualFree((void*)_guestContextTransferStub, 0u, 32768u);
|
VirtualFree((void*)_guestContextTransferStub, 0u, 32768u);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ internal sealed unsafe partial class WindowsFaultHandling : IHostFaultHandling
|
|||||||
|
|
||||||
public nint CreateHandlerThunk(nint managedCallback, uint hostRspSwitchTlsSlot, nint tlsGetValueAddress)
|
public nint CreateHandlerThunk(nint managedCallback, uint hostRspSwitchTlsSlot, nint tlsGetValueAddress)
|
||||||
{
|
{
|
||||||
const uint stubSize = 256u;
|
const uint stubSize = 1024u;
|
||||||
void* ptr = (void*)_memory.Allocate(0, stubSize, HostPageProtection.ReadWriteExecute);
|
void* ptr = (void*)_memory.Allocate(0, stubSize, HostPageProtection.ReadWriteExecute);
|
||||||
if (ptr == null)
|
if (ptr == null)
|
||||||
{
|
{
|
||||||
@@ -43,11 +43,15 @@ internal sealed unsafe partial class WindowsFaultHandling : IHostFaultHandling
|
|||||||
// managed code; the CLR's own VEH handles its exceptions. MSVC C++ exceptions
|
// managed code; the CLR's own VEH handles its exceptions. MSVC C++ exceptions
|
||||||
// (Vulkan drivers, host CRT) are excluded too: the managed handler only ever
|
// (Vulkan drivers, host CRT) are excluded too: the managed handler only ever
|
||||||
// returned CONTINUE_SEARCH for them.
|
// returned CONTINUE_SEARCH for them.
|
||||||
|
//
|
||||||
|
// FastFail (0xC0000409) is logged from this native path only: managed VEH never
|
||||||
|
// sees it (tLT18–21 silent exits after TBB AV recovery).
|
||||||
ReadOnlySpan<uint> nonManagedExceptionCodes =
|
ReadOnlySpan<uint> nonManagedExceptionCodes =
|
||||||
[WindowsFaultCodes.ClrManagedException, 0xE06D7363u, WindowsFaultCodes.FastFail, WindowsFaultCodes.StackOverflow];
|
[WindowsFaultCodes.ClrManagedException, 0xE06D7363u, WindowsFaultCodes.FastFail, WindowsFaultCodes.StackOverflow];
|
||||||
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x01); // mov rax, [rcx] (ExceptionRecord*)
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x01); // mov rax, [rcx] (ExceptionRecord*)
|
||||||
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x00); // mov eax, [rax] (ExceptionCode)
|
EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x00); // mov eax, [rax] (ExceptionCode)
|
||||||
var passJumpOffsets = stackalloc int[nonManagedExceptionCodes.Length];
|
var passJumpOffsets = stackalloc int[nonManagedExceptionCodes.Length];
|
||||||
|
int fastFailJumpSlot = -1;
|
||||||
for (int i = 0; i < nonManagedExceptionCodes.Length; i++)
|
for (int i = 0; i < nonManagedExceptionCodes.Length; i++)
|
||||||
{
|
{
|
||||||
EmitByte(code, ref offset, 0x3D); // cmp eax, imm32
|
EmitByte(code, ref offset, 0x3D); // cmp eax, imm32
|
||||||
@@ -55,13 +59,162 @@ internal sealed unsafe partial class WindowsFaultHandling : IHostFaultHandling
|
|||||||
EmitByte(code, ref offset, 0x74); // je pass
|
EmitByte(code, ref offset, 0x74); // je pass
|
||||||
passJumpOffsets[i] = offset;
|
passJumpOffsets[i] = offset;
|
||||||
EmitByte(code, ref offset, 0x00);
|
EmitByte(code, ref offset, 0x00);
|
||||||
|
if (nonManagedExceptionCodes[i] == WindowsFaultCodes.FastFail)
|
||||||
|
{
|
||||||
|
fastFailJumpSlot = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EmitByte(code, ref offset, 0xEB); EmitByte(code, ref offset, 0x03); // jmp over pass block
|
EmitByte(code, ref offset, 0xE9); // jmp mainBody rel32 (FastFail breadcrumb sits between)
|
||||||
|
var mainBodyJumpSlot = offset;
|
||||||
|
EmitUInt32(code, ref offset, 0u);
|
||||||
|
|
||||||
int passOffset = offset;
|
int passOffset = offset;
|
||||||
EmitByte(code, ref offset, 0x31); EmitByte(code, ref offset, 0xC0); // pass: xor eax, eax (EXCEPTION_CONTINUE_SEARCH)
|
EmitByte(code, ref offset, 0x31); EmitByte(code, ref offset, 0xC0); // pass: xor eax, eax (EXCEPTION_CONTINUE_SEARCH)
|
||||||
EmitByte(code, ref offset, 0xC3); // ret
|
EmitByte(code, ref offset, 0xC3); // ret
|
||||||
|
|
||||||
|
// FastFail: native stderr breadcrumb with Context.Rip (no managed entry), then CONTINUE_SEARCH.
|
||||||
|
// Keep in sync with DirectExecutionBackend.CreateExceptionHandlerTrampoline.
|
||||||
|
int fastFailPassOffset = offset;
|
||||||
|
var fastFailLogInstalled = false;
|
||||||
|
if (fastFailJumpSlot >= 0 &&
|
||||||
|
NativeLibrary.TryLoad("kernel32.dll", out var kernel32) &&
|
||||||
|
NativeLibrary.TryGetExport(kernel32, "GetStdHandle", out var getStdHandle) &&
|
||||||
|
NativeLibrary.TryGetExport(kernel32, "WriteFile", out var writeFile))
|
||||||
|
{
|
||||||
|
ReadOnlySpan<byte> msg =
|
||||||
|
"[LOADER][FATAL] VEH_PASS FastFail 0xC0000409 (native; no managed VEH) rip=0x"u8;
|
||||||
|
ReadOnlySpan<byte> hexDigits = "0123456789ABCDEF"u8;
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x41);
|
||||||
|
EmitByte(code, ref offset, 0x08); // mov rax, [rcx+8]
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8B); EmitByte(code, ref offset, 0x90);
|
||||||
|
EmitUInt32(code, ref offset, 0xF8u); // mov r10, [rax+0xF8]
|
||||||
|
EmitByte(code, ref offset, 0x50); // push rax
|
||||||
|
EmitByte(code, ref offset, 0x51); // push rcx
|
||||||
|
EmitByte(code, ref offset, 0x52); // push rdx
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x50); // push r8
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x51); // push r9
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x52); // push r10
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xEC); EmitByte(code, ref offset, 0x40); // sub rsp, 0x40
|
||||||
|
EmitByte(code, ref offset, 0xB9); EmitUInt32(code, ref offset, unchecked((uint)-12));
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = getStdHandle;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x28); // mov [rsp+0x28], rax
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xC1);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
var msgAbsSlot = offset;
|
||||||
|
*(nint*)(code + offset) = 0;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xC2);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xB8);
|
||||||
|
EmitUInt32(code, ref offset, (uint)msg.Length);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x38); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = writeFile;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x54); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x40); // mov r10, [rsp+0x40]
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xB8);
|
||||||
|
var hexDigitsAbsSlot = offset;
|
||||||
|
*(nint*)(code + offset) = 0;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x5C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x30); // lea r11, [rsp+0x30]
|
||||||
|
EmitByte(code, ref offset, 0xB9); EmitUInt32(code, ref offset, 16u);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xD0);
|
||||||
|
int hexLoopOffset = offset;
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC1); EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0x04);
|
||||||
|
EmitByte(code, ref offset, 0x89); EmitByte(code, ref offset, 0xC2);
|
||||||
|
EmitByte(code, ref offset, 0x83); EmitByte(code, ref offset, 0xE2); EmitByte(code, ref offset, 0x0F);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x0F); EmitByte(code, ref offset, 0xB6);
|
||||||
|
EmitByte(code, ref offset, 0x14); EmitByte(code, ref offset, 0x10);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x88); EmitByte(code, ref offset, 0x13);
|
||||||
|
EmitByte(code, ref offset, 0x49); EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xC3);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xC9);
|
||||||
|
EmitByte(code, ref offset, 0x75);
|
||||||
|
EmitByte(code, ref offset, unchecked((byte)(hexLoopOffset - (offset + 1)))); // jnz rel8
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xC6); EmitByte(code, ref offset, 0x03);
|
||||||
|
EmitByte(code, ref offset, 0x0A);
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8B);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x28);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x54); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x30);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0xB8);
|
||||||
|
EmitUInt32(code, ref offset, 17u);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x8D);
|
||||||
|
EmitByte(code, ref offset, 0x4C); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x20); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xC7);
|
||||||
|
EmitByte(code, ref offset, 0x44); EmitByte(code, ref offset, 0x24);
|
||||||
|
EmitByte(code, ref offset, 0x38); EmitUInt32(code, ref offset, 0);
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0xB8);
|
||||||
|
*(nint*)(code + offset) = writeFile;
|
||||||
|
offset += sizeof(nint);
|
||||||
|
EmitByte(code, ref offset, 0xFF); EmitByte(code, ref offset, 0xD0);
|
||||||
|
|
||||||
|
EmitByte(code, ref offset, 0x48); EmitByte(code, ref offset, 0x83);
|
||||||
|
EmitByte(code, ref offset, 0xC4); EmitByte(code, ref offset, 0x40);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x5A);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x59);
|
||||||
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x58);
|
||||||
|
EmitByte(code, ref offset, 0x5A);
|
||||||
|
EmitByte(code, ref offset, 0x59);
|
||||||
|
EmitByte(code, ref offset, 0x58);
|
||||||
|
EmitByte(code, ref offset, 0x31); EmitByte(code, ref offset, 0xC0);
|
||||||
|
EmitByte(code, ref offset, 0xC3);
|
||||||
|
|
||||||
|
var msgOffset = offset;
|
||||||
|
for (int i = 0; i < msg.Length; i++)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, msg[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var hexDigitsOffset = offset;
|
||||||
|
for (int i = 0; i < hexDigits.Length; i++)
|
||||||
|
{
|
||||||
|
EmitByte(code, ref offset, hexDigits[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(nint*)(code + msgAbsSlot) = (nint)ptr + msgOffset;
|
||||||
|
*(nint*)(code + hexDigitsAbsSlot) = (nint)ptr + hexDigitsOffset;
|
||||||
|
code[passJumpOffsets[fastFailJumpSlot]] =
|
||||||
|
checked((byte)(fastFailPassOffset - (passJumpOffsets[fastFailJumpSlot] + 1)));
|
||||||
|
fastFailLogInstalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mainBodyOffset = offset;
|
||||||
|
*(int*)(code + mainBodyJumpSlot) = mainBodyOffset - (mainBodyJumpSlot + sizeof(int));
|
||||||
|
|
||||||
for (int i = 0; i < nonManagedExceptionCodes.Length; i++)
|
for (int i = 0; i < nonManagedExceptionCodes.Length; i++)
|
||||||
{
|
{
|
||||||
|
if (i == fastFailJumpSlot && fastFailLogInstalled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
code[passJumpOffsets[i]] = checked((byte)(passOffset - (passJumpOffsets[i] + 1)));
|
code[passJumpOffsets[i]] = checked((byte)(passOffset - (passJumpOffsets[i] + 1)));
|
||||||
}
|
}
|
||||||
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x54); // push r12
|
EmitByte(code, ref offset, 0x41); EmitByte(code, ref offset, 0x54); // push r12
|
||||||
|
|||||||
@@ -238,7 +238,22 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
var alignedSize = (size + 0xFFF) & ~0xFFFUL;
|
var alignedSize = (size + 0xFFF) & ~0xFFFUL;
|
||||||
var protection = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
var protection = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
||||||
var hostProtection = executable ? HostPageProtection.ReadWriteExecute : HostPageProtection.ReadWrite;
|
var hostProtection = executable ? HostPageProtection.ReadWriteExecute : HostPageProtection.ReadWrite;
|
||||||
|
var allowLazyReserve = !executable &&
|
||||||
|
alignedSize >= LargeDataReserveThreshold &&
|
||||||
|
alignedSize > FullCommitRegionLimit;
|
||||||
|
|
||||||
|
// Commit first so titles that walk guest memory via raw host pointers
|
||||||
|
// (GTA post-RenderThread workers) keep fully backed pages. Fall back to
|
||||||
|
// reserve-only + lazy commit only when a huge non-exec commit fails —
|
||||||
|
// that is the Poppy / large-reservation path #608 was aiming for.
|
||||||
|
var reservedOnly = false;
|
||||||
var result = _hostMemory.Allocate(desiredAddress, alignedSize, hostProtection);
|
var result = _hostMemory.Allocate(desiredAddress, alignedSize, hostProtection);
|
||||||
|
if (result == 0 && allowLazyReserve)
|
||||||
|
{
|
||||||
|
result = _hostMemory.Reserve(desiredAddress, alignedSize, HostPageProtection.ReadWrite);
|
||||||
|
reservedOnly = result != 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -252,6 +267,8 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lazyPrimeState = reservedOnly ? PrimeLazyReserveRegion(actualAddress, alignedSize) : "n/a";
|
||||||
|
|
||||||
_gate.EnterWriteLock();
|
_gate.EnterWriteLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -260,7 +277,7 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
VirtualAddress = actualAddress,
|
VirtualAddress = actualAddress,
|
||||||
Size = alignedSize,
|
Size = alignedSize,
|
||||||
IsExecutable = executable,
|
IsExecutable = executable,
|
||||||
IsReservedOnly = false,
|
IsReservedOnly = reservedOnly,
|
||||||
Protection = protection
|
Protection = protection
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -269,8 +286,12 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
_gate.ExitWriteLock();
|
_gate.ExitWriteLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
var allocationKind = executable ? "executable memory" : "data memory";
|
var allocationKind = reservedOnly
|
||||||
TraceVmem($"Allocated exact {allocationKind}: 0x{actualAddress:X16} - 0x{actualAddress + alignedSize:X16} ({alignedSize} bytes)");
|
? "reserved data memory (lazy commit)"
|
||||||
|
: (executable ? "executable memory" : "data memory");
|
||||||
|
TraceVmem(
|
||||||
|
$"Allocated exact {allocationKind}: 0x{actualAddress:X16} - 0x{actualAddress + alignedSize:X16} " +
|
||||||
|
$"({alignedSize} bytes) lazy_prime={lazyPrimeState}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,55 +322,44 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
|
|
||||||
var protection = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
var protection = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
||||||
var hostProtection = executable ? HostPageProtection.ReadWriteExecute : HostPageProtection.ReadWrite;
|
var hostProtection = executable ? HostPageProtection.ReadWriteExecute : HostPageProtection.ReadWrite;
|
||||||
var reservedOnly = false;
|
var allowLazyReserve = !executable &&
|
||||||
var preferReserveOnly = !executable &&
|
|
||||||
alignedSize >= LargeDataReserveThreshold &&
|
alignedSize >= LargeDataReserveThreshold &&
|
||||||
alignedSize > FullCommitRegionLimit;
|
alignedSize > FullCommitRegionLimit;
|
||||||
|
var reservedOnly = false;
|
||||||
|
|
||||||
ulong result = 0;
|
// Prefer a full commit. Only fall back to reserve-only when a large
|
||||||
if (preferReserveOnly)
|
// non-executable commit cannot be satisfied (see TryAllocateAtExact).
|
||||||
{
|
ulong result = _hostMemory.Allocate(desiredAddress, alignedSize, hostProtection);
|
||||||
result = _hostMemory.Reserve(desiredAddress, alignedSize, HostPageProtection.ReadWrite);
|
|
||||||
if (result == 0 && allowAlternative)
|
|
||||||
{
|
|
||||||
result = _hostMemory.Reserve(0, alignedSize, HostPageProtection.ReadWrite);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != 0)
|
|
||||||
{
|
|
||||||
reservedOnly = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 0)
|
|
||||||
{
|
|
||||||
result = _hostMemory.Allocate(desiredAddress, alignedSize, hostProtection);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
if (!allowAlternative)
|
if (!allowAlternative)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"Failed to allocate exact mapping at 0x{desiredAddress:X16} ({alignedSize} bytes)");
|
if (allowLazyReserve)
|
||||||
}
|
|
||||||
|
|
||||||
TraceVmem($"Could not allocate at 0x{desiredAddress:X16}, trying any address...");
|
|
||||||
result = _hostMemory.Allocate(0, alignedSize, hostProtection);
|
|
||||||
|
|
||||||
if (result == 0)
|
|
||||||
{
|
|
||||||
if (!executable)
|
|
||||||
{
|
{
|
||||||
result = _hostMemory.Reserve(desiredAddress, alignedSize, HostPageProtection.ReadWrite);
|
result = _hostMemory.Reserve(desiredAddress, alignedSize, HostPageProtection.ReadWrite);
|
||||||
if (result == 0 && allowAlternative)
|
reservedOnly = result != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Failed to allocate exact mapping at 0x{desiredAddress:X16} ({alignedSize} bytes)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TraceVmem($"Could not allocate at 0x{desiredAddress:X16}, trying any address...");
|
||||||
|
result = _hostMemory.Allocate(0, alignedSize, hostProtection);
|
||||||
|
|
||||||
|
if (result == 0 && allowLazyReserve)
|
||||||
|
{
|
||||||
|
result = _hostMemory.Reserve(desiredAddress, alignedSize, HostPageProtection.ReadWrite);
|
||||||
|
if (result == 0)
|
||||||
{
|
{
|
||||||
result = _hostMemory.Reserve(0, alignedSize, HostPageProtection.ReadWrite);
|
result = _hostMemory.Reserve(0, alignedSize, HostPageProtection.ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0)
|
reservedOnly = result != 0;
|
||||||
{
|
|
||||||
reservedOnly = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
@@ -360,45 +370,7 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
}
|
}
|
||||||
|
|
||||||
var actualAddress = result;
|
var actualAddress = result;
|
||||||
|
var lazyPrimeState = reservedOnly ? PrimeLazyReserveRegion(actualAddress, alignedSize) : "n/a";
|
||||||
var lazyPrimeState = "n/a";
|
|
||||||
if (reservedOnly)
|
|
||||||
{
|
|
||||||
var primeBytes = Math.Min(alignedSize, LazyReservePrimeBytes);
|
|
||||||
if (primeBytes != 0)
|
|
||||||
{
|
|
||||||
ulong committedBytes = 0;
|
|
||||||
while (committedBytes < primeBytes)
|
|
||||||
{
|
|
||||||
var remaining = primeBytes - committedBytes;
|
|
||||||
var chunkBytes = Math.Min(remaining, LazyReservePrimeChunkBytes);
|
|
||||||
var commitAddress = actualAddress + committedBytes;
|
|
||||||
if (!_hostMemory.Commit(commitAddress, chunkBytes, HostPageProtection.ReadWrite))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
committedBytes += chunkBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (committedBytes != 0)
|
|
||||||
{
|
|
||||||
lazyPrimeState = committedBytes == primeBytes
|
|
||||||
? $"ok:{committedBytes:X}"
|
|
||||||
: $"partial:{committedBytes:X}/{primeBytes:X}";
|
|
||||||
TraceVmem($"Primed lazy region: 0x{actualAddress:X16} - 0x{actualAddress + committedBytes:X16} ({committedBytes} bytes)");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lazyPrimeState = $"fail:{primeBytes:X}";
|
|
||||||
TraceVmem($"Failed to prime lazy region at 0x{actualAddress:X16} ({primeBytes} bytes), continuing with on-demand commit");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lazyPrimeState = "skip:0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_gate.EnterWriteLock();
|
_gate.EnterWriteLock();
|
||||||
try
|
try
|
||||||
@@ -425,6 +397,45 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
return actualAddress;
|
return actualAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commits the leading slice of a reserve-only region so early guest touches
|
||||||
|
/// succeed before on-demand <see cref="EnsureRangeCommitted"/> runs.
|
||||||
|
/// </summary>
|
||||||
|
private string PrimeLazyReserveRegion(ulong actualAddress, ulong alignedSize)
|
||||||
|
{
|
||||||
|
var primeBytes = Math.Min(alignedSize, LazyReservePrimeBytes);
|
||||||
|
if (primeBytes == 0)
|
||||||
|
{
|
||||||
|
return "skip:0";
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong committedBytes = 0;
|
||||||
|
while (committedBytes < primeBytes)
|
||||||
|
{
|
||||||
|
var remaining = primeBytes - committedBytes;
|
||||||
|
var chunkBytes = Math.Min(remaining, LazyReservePrimeChunkBytes);
|
||||||
|
var commitAddress = actualAddress + committedBytes;
|
||||||
|
if (!_hostMemory.Commit(commitAddress, chunkBytes, HostPageProtection.ReadWrite))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
committedBytes += chunkBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (committedBytes != 0)
|
||||||
|
{
|
||||||
|
var state = committedBytes == primeBytes
|
||||||
|
? $"ok:{committedBytes:X}"
|
||||||
|
: $"partial:{committedBytes:X}/{primeBytes:X}";
|
||||||
|
TraceVmem($"Primed lazy region: 0x{actualAddress:X16} - 0x{actualAddress + committedBytes:X16} ({committedBytes} bytes)");
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
TraceVmem($"Failed to prime lazy region at 0x{actualAddress:X16} ({primeBytes} bytes), continuing with on-demand commit");
|
||||||
|
return $"fail:{primeBytes:X}";
|
||||||
|
}
|
||||||
|
|
||||||
public bool TryBackFixedRange(ulong address, ulong size, bool executable)
|
public bool TryBackFixedRange(ulong address, ulong size, bool executable)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
@@ -1307,12 +1318,26 @@ public sealed unsafe class PhysicalVirtualMemory : IVirtualMemory, IGuestMemoryA
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var region = FindRegion(virtualAddress, 1);
|
var region = FindRegion(virtualAddress, 1);
|
||||||
if (region is null ||
|
if (region is null)
|
||||||
(region.IsReservedOnly && !EnsureRangeCommitted(virtualAddress, 1, region)))
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Raw host pointers are walked by native/JIT code without further
|
||||||
|
// EnsureRangeCommitted calls. For reserve-only regions, commit a
|
||||||
|
// leading working-set chunk from this address so the common case
|
||||||
|
// does not immediately AV on the next page.
|
||||||
|
if (region.IsReservedOnly)
|
||||||
|
{
|
||||||
|
var regionEnd = region.VirtualAddress + region.Size;
|
||||||
|
var remaining = regionEnd > virtualAddress ? regionEnd - virtualAddress : 0;
|
||||||
|
var commitBytes = Math.Min(remaining, LazyReservePrimeChunkBytes);
|
||||||
|
if (commitBytes == 0 || !EnsureRangeCommitted(virtualAddress, commitBytes, region))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (void*)virtualAddress;
|
return (void*)virtualAddress;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public sealed class SharpEmuRuntime : ISharpEmuRuntime
|
|||||||
KernelModuleRegistry.Reset();
|
KernelModuleRegistry.Reset();
|
||||||
var image = LoadImage(normalizedEbootPath);
|
var image = LoadImage(normalizedEbootPath);
|
||||||
VideoOutExports.ConfigureApplicationInfo(image.Title, image.TitleId, image.Version);
|
VideoOutExports.ConfigureApplicationInfo(image.Title, image.TitleId, image.Version);
|
||||||
|
KernelMemoryCompatExports.ConfigureApplicationInfo(image.TitleId);
|
||||||
SaveDataExports.ConfigureApplicationInfo(image.TitleId);
|
SaveDataExports.ConfigureApplicationInfo(image.TitleId);
|
||||||
SystemServiceExports.ConfigureApplicationInfo(image.TitleId);
|
SystemServiceExports.ConfigureApplicationInfo(image.TitleId);
|
||||||
_ = RegisterLoadedModule(normalizedEbootPath, image, isMain: true, isSystemModule: false);
|
_ = RegisterLoadedModule(normalizedEbootPath, image, isMain: true, isSystemModule: false);
|
||||||
|
|||||||
+15
-249
@@ -1,267 +1,33 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (C) 2026 SharpEmu Emulator Project
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
SPDX-License-Identifier: GPL-2.0-or-later
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Application composition root. Shared resources and styles are included in
|
||||||
|
cascade order so individual launcher views do not redefine global visuals.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:SharpEmu.GUI"
|
|
||||||
x:Class="SharpEmu.GUI.App"
|
x:Class="SharpEmu.GUI.App"
|
||||||
RequestedThemeVariant="Dark">
|
RequestedThemeVariant="Dark">
|
||||||
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<Color x:Key="SystemAccentColor">#7C5CFC</Color>
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<LinearGradientBrush x:Key="BgBrush" StartPoint="0%,0%" EndPoint="100%,100%">
|
<ResourceInclude Source="avares://SharpEmu.GUI/Themes/Tokens.axaml" />
|
||||||
<GradientStop Offset="0" Color="#12151F" />
|
<ResourceInclude Source="avares://SharpEmu.GUI/Themes/Templates/SettingRow.axaml" />
|
||||||
<GradientStop Offset="0.55" Color="#0D1017" />
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<GradientStop Offset="1" Color="#0B0D14" />
|
</ResourceDictionary>
|
||||||
</LinearGradientBrush>
|
|
||||||
|
|
||||||
<SolidColorBrush x:Key="ChromeBrush" Color="#090C12" />
|
|
||||||
<SolidColorBrush x:Key="CardBrush" Color="#141924" />
|
|
||||||
<SolidColorBrush x:Key="CardBorderBrush" Color="#232B3A" />
|
|
||||||
<SolidColorBrush x:Key="ElevatedBrush" Color="#1B2230" />
|
|
||||||
<SolidColorBrush x:Key="TextBrush" Color="#E8ECF4" />
|
|
||||||
<SolidColorBrush x:Key="MutedBrush" Color="#8B94A7" />
|
|
||||||
<SolidColorBrush x:Key="FaintBrush" Color="#5A6478" />
|
|
||||||
<SolidColorBrush x:Key="AccentBrush" Color="#7C5CFC" />
|
|
||||||
<SolidColorBrush x:Key="AccentHoverBrush" Color="#8F73FF" />
|
|
||||||
<SolidColorBrush x:Key="DangerBrush" Color="#E5484D" />
|
|
||||||
<SolidColorBrush x:Key="DangerHoverBrush" Color="#F2555A" />
|
|
||||||
<SolidColorBrush x:Key="SuccessBrush" Color="#46C46B" />
|
|
||||||
<SolidColorBrush x:Key="InfoBrush" Color="#58A6FF" />
|
|
||||||
<SolidColorBrush x:Key="TileHoverBrush" Color="#1A2130" />
|
|
||||||
<SolidColorBrush x:Key="TileSelectedBrush" Color="#212A3F" />
|
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type local:SettingRow}" TargetType="local:SettingRow">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate>
|
|
||||||
<Grid ColumnDefinitions="*,Auto">
|
|
||||||
<StackPanel VerticalAlignment="Center" Spacing="2" Margin="0,0,16,0">
|
|
||||||
<TextBlock x:Name="PART_Label" Text="{TemplateBinding Label}" FontSize="13" />
|
|
||||||
<TextBlock Text="{TemplateBinding Description}" FontSize="11"
|
|
||||||
Foreground="{StaticResource MutedBrush}" TextWrapping="Wrap"
|
|
||||||
IsVisible="{Binding Description, RelativeSource={RelativeSource TemplatedParent},
|
|
||||||
Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="10" VerticalAlignment="Center">
|
|
||||||
<ToggleSwitch OnContent="Override" OffContent="Override" MinWidth="0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
IsVisible="{TemplateBinding ShowOverride}"
|
|
||||||
IsChecked="{Binding IsOverridden, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
|
|
||||||
<ContentPresenter x:Name="PART_Slot" Content="{TemplateBinding Content}" VerticalAlignment="Center" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
</ControlTheme>
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
|
|
||||||
<Style Selector="Window">
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Base.axaml" />
|
||||||
<Setter Property="FontFamily" Value="Inter, Segoe UI, sans-serif" />
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Surfaces.axaml" />
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Buttons.axaml" />
|
||||||
</Style>
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Chrome.axaml" />
|
||||||
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Inputs.axaml" />
|
||||||
<Style Selector="Border.card">
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Console.axaml" />
|
||||||
<Setter Property="Background" Value="{StaticResource CardBrush}" />
|
<StyleInclude Source="avares://SharpEmu.GUI/Themes/Styles/Library.axaml" />
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="CornerRadius" Value="12" />
|
|
||||||
<Setter Property="Padding" Value="16" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="Border.pill">
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
<Setter Property="CornerRadius" Value="999" />
|
|
||||||
<Setter Property="Padding" Value="10,3" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Session status/hotkey badges: the title-id pill geometry with a
|
|
||||||
tinted fill so state (RUNNING) and keys (F11) read at a glance. -->
|
|
||||||
<Style Selector="Border.badge">
|
|
||||||
<Setter Property="CornerRadius" Value="999" />
|
|
||||||
<Setter Property="Padding" Value="8,2" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Border.badge.running">
|
|
||||||
<Setter Property="Background" Value="#1E46C46B" />
|
|
||||||
<Setter Property="BorderBrush" Value="#5546C46B" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Border.badge.key">
|
|
||||||
<Setter Property="Background" Value="#1E58A6FF" />
|
|
||||||
<Setter Property="BorderBrush" Value="#5558A6FF" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="TextBlock.sectionTitle">
|
|
||||||
<Setter Property="FontSize" Value="11" />
|
|
||||||
<Setter Property="FontWeight" Value="SemiBold" />
|
|
||||||
<Setter Property="LetterSpacing" Value="1.5" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource MutedBrush}" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="TextBlock.fieldLabel">
|
|
||||||
<Setter Property="FontSize" Value="12" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource MutedBrush}" />
|
|
||||||
<Setter Property="Margin" Value="0,0,0,6" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="TextBox">
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="Button.accent">
|
|
||||||
<Setter Property="Background" Value="{StaticResource AccentBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="White" />
|
|
||||||
<Setter Property="FontWeight" Value="SemiBold" />
|
|
||||||
<Setter Property="Padding" Value="22,10" />
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Button.accent:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource AccentHoverBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="White" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="Button.danger">
|
|
||||||
<Setter Property="Background" Value="{StaticResource DangerBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="White" />
|
|
||||||
<Setter Property="FontWeight" Value="SemiBold" />
|
|
||||||
<Setter Property="Padding" Value="22,10" />
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Button.danger:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource DangerHoverBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="White" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="Button.ghost">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
<Setter Property="Padding" Value="12,7" />
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Button.ghost:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="ToggleButton.ghost">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
<Setter Property="Padding" Value="12,7" />
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ToggleButton.ghost:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ToggleButton.ghost:checked /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Top-level page switcher (Library / Options): plain transparent
|
|
||||||
buttons, not TabItem, so there is no Fluent selected-tab underline.
|
|
||||||
The active page is conveyed by brightness alone; LB/RB gamepad
|
|
||||||
hints flank the pair. -->
|
|
||||||
<Style Selector="Button.segment">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderThickness" Value="0" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource MutedBrush}" />
|
|
||||||
<Setter Property="FontSize" Value="22" />
|
|
||||||
<Setter Property="FontWeight" Value="Bold" />
|
|
||||||
<Setter Property="Padding" Value="6,4" />
|
|
||||||
<Setter Property="CornerRadius" Value="8" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Button.segment:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Button.segment.active">
|
|
||||||
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Gamepad shoulder-button hint chip (LB/RB, L1/R1). -->
|
|
||||||
<Style Selector="Border.padHint">
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
<Setter Property="CornerRadius" Value="6" />
|
|
||||||
<Setter Property="Padding" Value="8,3" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="ContextMenu">
|
|
||||||
<Setter Property="Background" Value="{StaticResource CardBrush}" />
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="CornerRadius" Value="10" />
|
|
||||||
<Setter Property="Padding" Value="6" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ContextMenu MenuItem">
|
|
||||||
<Setter Property="Padding" Value="10,7" />
|
|
||||||
<Setter Property="CornerRadius" Value="7" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ContextMenu Separator">
|
|
||||||
<Setter Property="Background" Value="{StaticResource CardBorderBrush}" />
|
|
||||||
<Setter Property="Height" Value="1" />
|
|
||||||
<Setter Property="Margin" Value="8,4" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="ListBox.console">
|
|
||||||
<Setter Property="Background" Value="#0B0E14" />
|
|
||||||
<Setter Property="FontFamily" Value="Cascadia Mono, Consolas, Courier New, monospace" />
|
|
||||||
<Setter Property="FontSize" Value="12" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBox.console ListBoxItem">
|
|
||||||
<Setter Property="Padding" Value="10,1" />
|
|
||||||
<Setter Property="MinHeight" Value="0" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Cover-art library grid -->
|
|
||||||
<Style Selector="ListBox.tileGrid ListBoxItem">
|
|
||||||
<Setter Property="Padding" Value="10" />
|
|
||||||
<Setter Property="Margin" Value="5" />
|
|
||||||
<Setter Property="CornerRadius" Value="14" />
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
<Setter Property="RenderTransform" Value="translateY(0px)" />
|
|
||||||
<Setter Property="Transitions">
|
|
||||||
<Transitions>
|
|
||||||
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.12" />
|
|
||||||
</Transitions>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBox.tileGrid ListBoxItem:pointerover">
|
|
||||||
<Setter Property="RenderTransform" Value="translateY(-3px)" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBox.tileGrid ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource TileHoverBrush}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBox.tileGrid ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource TileSelectedBrush}" />
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBox.tileGrid ListBoxItem:selected:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="{StaticResource TileSelectedBrush}" />
|
|
||||||
<Setter Property="BorderBrush" Value="{StaticResource AccentHoverBrush}" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="Border.coverShadow">
|
|
||||||
<Setter Property="CornerRadius" Value="10" />
|
|
||||||
<Setter Property="BoxShadow" Value="0 6 14 0 #55000000" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="Border.coverClip">
|
|
||||||
<Setter Property="CornerRadius" Value="10" />
|
|
||||||
<Setter Property="ClipToBounds" Value="True" />
|
|
||||||
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
|
||||||
</Style>
|
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Avalonia.Collections;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Templates;
|
using Avalonia.Controls.Templates;
|
||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
|
using Avalonia.Input.Platform;
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
@@ -40,7 +41,7 @@ public sealed class ConsoleWindow : Window
|
|||||||
|
|
||||||
_searchBox = new TextBox
|
_searchBox = new TextBox
|
||||||
{
|
{
|
||||||
Watermark = loc.Get("Console.SearchWatermark"),
|
PlaceholderText = loc.Get("Console.SearchWatermark"),
|
||||||
Width = 320,
|
Width = 320,
|
||||||
Margin = new Thickness(0, 0, 12, 0),
|
Margin = new Thickness(0, 0, 12, 0),
|
||||||
};
|
};
|
||||||
|
|||||||
+124
-12
@@ -8,6 +8,15 @@ using Avalonia.Media.Imaging;
|
|||||||
|
|
||||||
namespace SharpEmu.GUI;
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
internal enum GameEntryChanges
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Metadata = 1,
|
||||||
|
Cover = 2,
|
||||||
|
Background = 4,
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class GameEntry : INotifyPropertyChanged
|
public sealed class GameEntry : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
// Placeholder gradients for games without cover art, picked
|
// Placeholder gradients for games without cover art, picked
|
||||||
@@ -27,29 +36,39 @@ public sealed class GameEntry : INotifyPropertyChanged
|
|||||||
private Bitmap? _cover;
|
private Bitmap? _cover;
|
||||||
private IBrush? _placeholderBrush;
|
private IBrush? _placeholderBrush;
|
||||||
private long _sizeBytes;
|
private long _sizeBytes;
|
||||||
|
private string _name;
|
||||||
|
private string? _titleId;
|
||||||
|
private string? _version;
|
||||||
|
private string? _coverPath;
|
||||||
|
private string? _backgroundPath;
|
||||||
|
private string _initials;
|
||||||
|
private FileStamp _coverStamp;
|
||||||
|
private FileStamp _backgroundStamp;
|
||||||
|
|
||||||
public GameEntry(
|
public GameEntry(
|
||||||
string name, string? titleId, string? version, string path, long sizeBytes,
|
string name, string? titleId, string? version, string path, long sizeBytes,
|
||||||
string? coverPath, string? backgroundPath)
|
string? coverPath, string? backgroundPath)
|
||||||
{
|
{
|
||||||
Name = name;
|
_name = name;
|
||||||
TitleId = titleId;
|
_titleId = titleId;
|
||||||
Version = version;
|
_version = version;
|
||||||
Path = path;
|
Path = path;
|
||||||
_sizeBytes = sizeBytes;
|
_sizeBytes = sizeBytes;
|
||||||
CoverPath = coverPath;
|
_coverPath = coverPath;
|
||||||
BackgroundPath = backgroundPath;
|
_backgroundPath = backgroundPath;
|
||||||
Initials = ComputeInitials(name);
|
_initials = ComputeInitials(name);
|
||||||
|
_coverStamp = FileStamp.Read(coverPath);
|
||||||
|
_backgroundStamp = FileStamp.Read(backgroundPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name => _name;
|
||||||
|
|
||||||
public string? TitleId { get; }
|
public string? TitleId => _titleId;
|
||||||
|
|
||||||
/// <summary>Content version from sce_sys/param.json, e.g. "01.000.000".</summary>
|
/// <summary>Content version from sce_sys/param.json, e.g. "01.000.000".</summary>
|
||||||
public string? Version { get; }
|
public string? Version => _version;
|
||||||
|
|
||||||
public string Path { get; }
|
public string Path { get; }
|
||||||
|
|
||||||
@@ -75,10 +94,10 @@ public sealed class GameEntry : INotifyPropertyChanged
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Path to the cover art image shipped with the game, if found.</summary>
|
/// <summary>Path to the cover art image shipped with the game, if found.</summary>
|
||||||
public string? CoverPath { get; }
|
public string? CoverPath => _coverPath;
|
||||||
|
|
||||||
/// <summary>Path to the key art (pic0/pic1) shipped with the game, if found.</summary>
|
/// <summary>Path to the key art (pic0/pic1) shipped with the game, if found.</summary>
|
||||||
public string? BackgroundPath { get; }
|
public string? BackgroundPath => _backgroundPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decoded key art used as the window backdrop while this game is
|
/// Decoded key art used as the window backdrop while this game is
|
||||||
@@ -86,7 +105,7 @@ public sealed class GameEntry : INotifyPropertyChanged
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Bitmap? Background { get; set; }
|
public Bitmap? Background { get; set; }
|
||||||
|
|
||||||
public string Initials { get; }
|
public string Initials => _initials;
|
||||||
|
|
||||||
// Built lazily: brushes are AvaloniaObjects that must be created on the
|
// Built lazily: brushes are AvaloniaObjects that must be created on the
|
||||||
// UI thread, while GameEntry itself is constructed on the scan thread.
|
// UI thread, while GameEntry itself is constructed on the scan thread.
|
||||||
@@ -121,6 +140,74 @@ public sealed class GameEntry : INotifyPropertyChanged
|
|||||||
/// <summary>Formatted install size badge shown in the launch bar.</summary>
|
/// <summary>Formatted install size badge shown in the launch bar.</summary>
|
||||||
public string SizeText => FormatSize(SizeBytes);
|
public string SizeText => FormatSize(SizeBytes);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a fresh filesystem scan to this presentation object so its
|
||||||
|
/// ListBox container and selection remain stable
|
||||||
|
/// </summary>
|
||||||
|
internal GameEntryChanges UpdateFrom(GameEntry scanned)
|
||||||
|
{
|
||||||
|
if (!Path.Equals(scanned.Path, GameLibraryPath.Comparison))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Only matching game paths can be reconciled", nameof(scanned));
|
||||||
|
}
|
||||||
|
|
||||||
|
var changes = GameEntryChanges.None;
|
||||||
|
if (!string.Equals(_name, scanned.Name, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
_name = scanned.Name;
|
||||||
|
_initials = ComputeInitials(scanned.Name);
|
||||||
|
_placeholderBrush = null;
|
||||||
|
RaisePropertyChanged(nameof(Name));
|
||||||
|
RaisePropertyChanged(nameof(Initials));
|
||||||
|
RaisePropertyChanged(nameof(PlaceholderBrush));
|
||||||
|
changes |= GameEntryChanges.Metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.Equals(_titleId, scanned.TitleId, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
_titleId = scanned.TitleId;
|
||||||
|
RaisePropertyChanged(nameof(TitleId));
|
||||||
|
RaisePropertyChanged(nameof(HasTitleId));
|
||||||
|
changes |= GameEntryChanges.Metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.Equals(_version, scanned.Version, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
_version = scanned.Version;
|
||||||
|
RaisePropertyChanged(nameof(Version));
|
||||||
|
RaisePropertyChanged(nameof(VersionText));
|
||||||
|
RaisePropertyChanged(nameof(HasVersion));
|
||||||
|
changes |= GameEntryChanges.Metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.Equals(_coverPath, scanned.CoverPath, StringComparison.Ordinal)
|
||||||
|
|| _coverStamp != scanned._coverStamp)
|
||||||
|
{
|
||||||
|
_coverPath = scanned.CoverPath;
|
||||||
|
_coverStamp = scanned._coverStamp;
|
||||||
|
var previousCover = Cover;
|
||||||
|
Cover = null;
|
||||||
|
previousCover?.Dispose();
|
||||||
|
changes |= GameEntryChanges.Cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.Equals(_backgroundPath, scanned.BackgroundPath, StringComparison.Ordinal)
|
||||||
|
|| _backgroundStamp != scanned._backgroundStamp)
|
||||||
|
{
|
||||||
|
_backgroundPath = scanned.BackgroundPath;
|
||||||
|
_backgroundStamp = scanned._backgroundStamp;
|
||||||
|
var previousBackground = Background;
|
||||||
|
Background = null;
|
||||||
|
previousBackground?.Dispose();
|
||||||
|
changes |= GameEntryChanges.Background;
|
||||||
|
}
|
||||||
|
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RaisePropertyChanged(string propertyName) =>
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
|
||||||
private static string ComputeInitials(string name)
|
private static string ComputeInitials(string name)
|
||||||
{
|
{
|
||||||
var initials = name
|
var initials = name
|
||||||
@@ -164,4 +251,29 @@ public sealed class GameEntry : INotifyPropertyChanged
|
|||||||
_ => $"{bytes} B",
|
_ => $"{bytes} B",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly record struct FileStamp(long Length, long LastWriteTimeUtcTicks)
|
||||||
|
{
|
||||||
|
public static FileStamp Read(string? path)
|
||||||
|
{
|
||||||
|
if (path is null)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var file = new FileInfo(path);
|
||||||
|
return file.Exists
|
||||||
|
? new FileStamp(file.Length, file.LastWriteTimeUtc.Ticks)
|
||||||
|
: default;
|
||||||
|
}
|
||||||
|
catch (Exception exception) when (
|
||||||
|
exception is IOException
|
||||||
|
or UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
internal static class GameLibraryPath
|
||||||
|
{
|
||||||
|
public static StringComparer Comparer { get; } =
|
||||||
|
OperatingSystem.IsWindows() || OperatingSystem.IsMacOS()
|
||||||
|
? StringComparer.OrdinalIgnoreCase
|
||||||
|
: StringComparer.Ordinal;
|
||||||
|
|
||||||
|
public static StringComparison Comparison { get; } =
|
||||||
|
OperatingSystem.IsWindows() || OperatingSystem.IsMacOS()
|
||||||
|
? StringComparison.OrdinalIgnoreCase
|
||||||
|
: StringComparison.Ordinal;
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
internal sealed record GameLibraryReconciliation(
|
||||||
|
IReadOnlyList<GameEntry> Games,
|
||||||
|
IReadOnlyList<GameEntry> CoversToLoad,
|
||||||
|
IReadOnlySet<GameEntry> BackgroundsChanged);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies filesystem scan results while preserving presentation object
|
||||||
|
/// identity for games that remain in the library
|
||||||
|
/// </summary>
|
||||||
|
internal static class GameLibraryReconciler
|
||||||
|
{
|
||||||
|
public static GameLibraryReconciliation Reconcile(
|
||||||
|
IReadOnlyList<GameEntry> current,
|
||||||
|
IReadOnlyList<GameEntry> scanned)
|
||||||
|
{
|
||||||
|
var existingByPath = current.ToDictionary(game => game.Path, GameLibraryPath.Comparer);
|
||||||
|
var merged = new List<GameEntry>(scanned.Count);
|
||||||
|
var coversToLoad = new List<GameEntry>();
|
||||||
|
var backgroundsChanged = new HashSet<GameEntry>();
|
||||||
|
|
||||||
|
foreach (var scannedGame in scanned)
|
||||||
|
{
|
||||||
|
if (!existingByPath.TryGetValue(scannedGame.Path, out var existing))
|
||||||
|
{
|
||||||
|
merged.Add(scannedGame);
|
||||||
|
if (scannedGame.CoverPath is not null)
|
||||||
|
{
|
||||||
|
coversToLoad.Add(scannedGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var changes = existing.UpdateFrom(scannedGame);
|
||||||
|
merged.Add(existing);
|
||||||
|
if ((changes & GameEntryChanges.Cover) != 0 && existing.CoverPath is not null)
|
||||||
|
{
|
||||||
|
coversToLoad.Add(existing);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((changes & GameEntryChanges.Background) != 0)
|
||||||
|
{
|
||||||
|
backgroundsChanged.Add(existing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GameLibraryReconciliation(merged, coversToLoad, backgroundsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reorders, inserts and removes only the items needed to reach the desired
|
||||||
|
/// visible sequence
|
||||||
|
/// </summary>
|
||||||
|
public static void ReconcileVisibleGames(
|
||||||
|
IList<GameEntry> visible,
|
||||||
|
IReadOnlyList<GameEntry> desired)
|
||||||
|
{
|
||||||
|
for (var index = 0; index < desired.Count; index++)
|
||||||
|
{
|
||||||
|
var game = desired[index];
|
||||||
|
if (index < visible.Count && ReferenceEquals(visible[index], game))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var existingIndex = -1;
|
||||||
|
for (var candidate = index + 1; candidate < visible.Count; candidate++)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(visible[candidate], game))
|
||||||
|
{
|
||||||
|
existingIndex = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingIndex >= 0)
|
||||||
|
{
|
||||||
|
var existing = visible[existingIndex];
|
||||||
|
visible.RemoveAt(existingIndex);
|
||||||
|
visible.Insert(index, existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
visible.Insert(index, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (visible.Count > desired.Count)
|
||||||
|
{
|
||||||
|
visible.RemoveAt(visible.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Watches configured game folders and collapses filesystem bursts into one
|
||||||
|
/// library refresh request
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class GameLibraryWatcher : IDisposable
|
||||||
|
{
|
||||||
|
private static readonly TimeSpan DefaultDebounceInterval = TimeSpan.FromMilliseconds(600);
|
||||||
|
|
||||||
|
private readonly object _sync = new();
|
||||||
|
private readonly TimeSpan _debounceInterval;
|
||||||
|
private readonly List<FileSystemWatcher> _watchers = [];
|
||||||
|
private Timer? _debounceTimer;
|
||||||
|
private bool _disposed;
|
||||||
|
|
||||||
|
internal GameLibraryWatcher(TimeSpan? debounceInterval = null)
|
||||||
|
{
|
||||||
|
_debounceInterval = debounceInterval ?? DefaultDebounceInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler? RefreshRequested;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces the watched roots with the current configured game folders
|
||||||
|
/// </summary>
|
||||||
|
public void Watch(IReadOnlyList<string> folders)
|
||||||
|
{
|
||||||
|
lock (_sync)
|
||||||
|
{
|
||||||
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
||||||
|
foreach (var watcher in _watchers)
|
||||||
|
{
|
||||||
|
watcher.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
_watchers.Clear();
|
||||||
|
_debounceTimer?.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
|
||||||
|
foreach (var folder in folders.Distinct(GameLibraryPath.Comparer))
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(folder) || !Directory.Exists(folder))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var watcher = new FileSystemWatcher(folder)
|
||||||
|
{
|
||||||
|
IncludeSubdirectories = true,
|
||||||
|
NotifyFilter = NotifyFilters.FileName
|
||||||
|
| NotifyFilters.DirectoryName
|
||||||
|
| NotifyFilters.LastWrite
|
||||||
|
| NotifyFilters.Size,
|
||||||
|
};
|
||||||
|
watcher.Created += OnFileSystemChanged;
|
||||||
|
watcher.Changed += OnFileSystemChanged;
|
||||||
|
watcher.Deleted += OnFileSystemChanged;
|
||||||
|
watcher.Renamed += OnFileSystemChanged;
|
||||||
|
watcher.Error += OnWatcherError;
|
||||||
|
watcher.EnableRaisingEvents = true;
|
||||||
|
_watchers.Add(watcher);
|
||||||
|
}
|
||||||
|
catch (Exception exception) when (
|
||||||
|
exception is ArgumentException
|
||||||
|
or IOException
|
||||||
|
or UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[GUI][WARN] Could not watch game folder '{folder}': {exception.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFileSystemChanged(object sender, FileSystemEventArgs args)
|
||||||
|
=> ScheduleRefresh();
|
||||||
|
|
||||||
|
private void OnWatcherError(object sender, ErrorEventArgs args)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[GUI][WARN] Game library watcher reported an error: {args.GetException().Message}");
|
||||||
|
ScheduleRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ScheduleRefresh()
|
||||||
|
{
|
||||||
|
lock (_sync)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_debounceTimer is null)
|
||||||
|
{
|
||||||
|
_debounceTimer = new Timer(
|
||||||
|
static state => ((GameLibraryWatcher)state!).RaiseRefreshRequested(),
|
||||||
|
this,
|
||||||
|
_debounceInterval,
|
||||||
|
Timeout.InfiniteTimeSpan);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_debounceTimer.Change(_debounceInterval, Timeout.InfiniteTimeSpan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RaiseRefreshRequested()
|
||||||
|
{
|
||||||
|
lock (_sync)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshRequested?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
lock (_sync)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_disposed = true;
|
||||||
|
_debounceTimer?.Dispose();
|
||||||
|
_debounceTimer = null;
|
||||||
|
foreach (var watcher in _watchers)
|
||||||
|
{
|
||||||
|
watcher.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
_watchers.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,620 +0,0 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Platform;
|
|
||||||
using Avalonia.Threading;
|
|
||||||
using SharpEmu.Libs.VideoOut;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace SharpEmu.GUI;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Native child surface owned by Avalonia. The isolated emulator process uses
|
|
||||||
/// its platform handle to create the Vulkan presentation surface, keeping the
|
|
||||||
/// guest address space out of the GUI process.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class GameSurfaceHost : NativeControlHost
|
|
||||||
{
|
|
||||||
private const uint SwpNoSize = 0x0001;
|
|
||||||
private const uint SwpNoMove = 0x0002;
|
|
||||||
private const uint SwpNoZOrder = 0x0004;
|
|
||||||
private const uint SwpNoActivate = 0x0010;
|
|
||||||
private const uint SwpShowWindow = 0x0040;
|
|
||||||
private const uint SwpHideWindow = 0x0080;
|
|
||||||
private const uint WsChild = 0x40000000;
|
|
||||||
private const uint WsVisible = 0x10000000;
|
|
||||||
private const uint WsClipSiblings = 0x04000000;
|
|
||||||
private const uint WsClipChildren = 0x02000000;
|
|
||||||
private const uint CsOwnDc = 0x0020;
|
|
||||||
private const uint WmSetCursor = 0x0020;
|
|
||||||
private const uint WmMouseMove = 0x0200;
|
|
||||||
private const int IdcArrow = 32512;
|
|
||||||
private const int CursorHideDelayMs = 2500;
|
|
||||||
|
|
||||||
private VulkanHostSurface? _surface;
|
|
||||||
private nint _windowHandle;
|
|
||||||
private nint _x11Display;
|
|
||||||
private string? _win32ClassName;
|
|
||||||
private WindowProcedure? _windowProcedure;
|
|
||||||
private nint _metalLayer;
|
|
||||||
private bool _presentationVisible = true;
|
|
||||||
private DispatcherTimer? _cursorIdleTimer;
|
|
||||||
private bool _cursorAutoHide;
|
|
||||||
private bool _cursorHidden;
|
|
||||||
private long _lastPointerActivity;
|
|
||||||
|
|
||||||
public GameSurfaceHost()
|
|
||||||
{
|
|
||||||
PropertyChanged += (_, change) =>
|
|
||||||
{
|
|
||||||
if (change.Property == BoundsProperty)
|
|
||||||
{
|
|
||||||
UpdateSurfaceSize();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
LayoutUpdated += (_, _) =>
|
|
||||||
{
|
|
||||||
// Fullscreen can change a monitor's DPI scale without changing
|
|
||||||
// the logical Bounds. Refresh the native child from physical size.
|
|
||||||
UpdateSurfaceSize();
|
|
||||||
|
|
||||||
// NativeControlHost may make its HWND visible again as part of a
|
|
||||||
// later arrange pass. Keep a loading surface hidden until its
|
|
||||||
// child process reports a real first frame.
|
|
||||||
if (!_presentationVisible)
|
|
||||||
{
|
|
||||||
ApplyPresentationVisibility();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler<VulkanHostSurface>? SurfaceAvailable;
|
|
||||||
|
|
||||||
public event EventHandler<VulkanHostSurface>? SurfaceDestroyed;
|
|
||||||
|
|
||||||
public VulkanHostSurface? Surface => _surface;
|
|
||||||
|
|
||||||
public void RefreshSurfaceSize() => UpdateSurfaceSize();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Hides the platform child without detaching the Vulkan surface. This
|
|
||||||
/// allows the launcher to return to its library while guest teardown is
|
|
||||||
/// still finishing on the render thread.
|
|
||||||
/// </summary>
|
|
||||||
public void SetPresentationVisible(bool visible)
|
|
||||||
{
|
|
||||||
_presentationVisible = visible;
|
|
||||||
ApplyPresentationVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Auto-hides the mouse cursor over the game surface after a short idle
|
|
||||||
/// period; any pointer movement brings it back. Enabling (again) restarts
|
|
||||||
/// the idle countdown, so both "first frame presented" and "entered
|
|
||||||
/// fullscreen" can arm it. Windows-only; a no-op elsewhere.
|
|
||||||
/// </summary>
|
|
||||||
public void SetCursorAutoHide(bool enabled)
|
|
||||||
{
|
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cursorAutoHide = enabled;
|
|
||||||
_lastPointerActivity = System.Diagnostics.Stopwatch.GetTimestamp();
|
|
||||||
if (enabled)
|
|
||||||
{
|
|
||||||
_cursorIdleTimer ??= CreateCursorIdleTimer();
|
|
||||||
_cursorIdleTimer.Start();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cursorIdleTimer?.Stop();
|
|
||||||
ShowCursorNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
private DispatcherTimer CreateCursorIdleTimer()
|
|
||||||
{
|
|
||||||
var timer = new DispatcherTimer
|
|
||||||
{
|
|
||||||
Interval = TimeSpan.FromMilliseconds(250),
|
|
||||||
};
|
|
||||||
timer.Tick += (_, _) => HideCursorWhenIdle();
|
|
||||||
return timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HideCursorWhenIdle()
|
|
||||||
{
|
|
||||||
if (!_cursorAutoHide || _cursorHidden || _windowHandle == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var idleMs = (System.Diagnostics.Stopwatch.GetTimestamp() - _lastPointerActivity) *
|
|
||||||
1000 / System.Diagnostics.Stopwatch.Frequency;
|
|
||||||
if (idleMs < CursorHideDelayMs)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only swallow the cursor while it is actually over the game surface;
|
|
||||||
// hovering launcher chrome (console, toolbar) must keep the arrow.
|
|
||||||
if (!GetCursorPos(out var point) || WindowFromPoint(point) != _windowHandle)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cursorHidden = true;
|
|
||||||
_ = SetCursor(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ShowCursorNow()
|
|
||||||
{
|
|
||||||
if (!_cursorHidden)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_cursorHidden = false;
|
|
||||||
_ = SetCursor(LoadCursorW(0, IdcArrow));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ApplyPresentationVisibility()
|
|
||||||
{
|
|
||||||
if (_windowHandle == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var visible = _presentationVisible;
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
// SW_HIDE can be ignored for a window's initial show state. Force
|
|
||||||
// the state through SetWindowPos so an old child swapchain cannot
|
|
||||||
// remain composed while the next game is loading.
|
|
||||||
var flags = SwpNoSize | SwpNoMove | SwpNoZOrder | SwpNoActivate |
|
|
||||||
(visible ? SwpShowWindow : SwpHideWindow);
|
|
||||||
_ = SetWindowPos(_windowHandle, 0, 0, 0, 0, 0, flags);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsLinux() && _x11Display != 0)
|
|
||||||
{
|
|
||||||
_ = visible
|
|
||||||
? XMapWindow(_x11Display, _windowHandle)
|
|
||||||
: XUnmapWindow(_x11Display, _windowHandle);
|
|
||||||
_ = XFlush(_x11Display);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
SendBool(_windowHandle, "setHidden:", !visible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle control)
|
|
||||||
{
|
|
||||||
PlatformHandle handle;
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
handle = CreateWin32(control);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsLinux())
|
|
||||||
{
|
|
||||||
handle = CreateX11(control);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
handle = CreateMacOS();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new PlatformNotSupportedException("SharpEmu's embedded Vulkan surface is unsupported on this platform.");
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateSurfaceSize();
|
|
||||||
if (_surface is { } surface)
|
|
||||||
{
|
|
||||||
SurfaceAvailable?.Invoke(this, surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void DestroyNativeControlCore(IPlatformHandle control)
|
|
||||||
{
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
SetCursorAutoHide(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var surface = _surface;
|
|
||||||
_surface = null;
|
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
DestroyWin32();
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsLinux())
|
|
||||||
{
|
|
||||||
DestroyX11();
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsMacOS())
|
|
||||||
{
|
|
||||||
DestroyMacOS();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surface is not null)
|
|
||||||
{
|
|
||||||
SurfaceDestroyed?.Invoke(this, surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlatformHandle CreateWin32(IPlatformHandle control)
|
|
||||||
{
|
|
||||||
_win32ClassName = $"SharpEmuGameSurface-{Guid.NewGuid():N}";
|
|
||||||
_windowProcedure = WindowProcedureImpl;
|
|
||||||
var classInfo = new WndClassEx
|
|
||||||
{
|
|
||||||
Size = (uint)Marshal.SizeOf<WndClassEx>(),
|
|
||||||
Style = CsOwnDc,
|
|
||||||
WindowProcedure = Marshal.GetFunctionPointerForDelegate(_windowProcedure),
|
|
||||||
Instance = GetModuleHandleW(null),
|
|
||||||
ClassName = _win32ClassName,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (RegisterClassExW(ref classInfo) == 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Could not register the embedded game window class (Win32 error {Marshal.GetLastWin32Error()}).");
|
|
||||||
}
|
|
||||||
|
|
||||||
_windowHandle = CreateWindowExW(
|
|
||||||
0,
|
|
||||||
_win32ClassName,
|
|
||||||
"SharpEmu Game Surface",
|
|
||||||
WsChild | (_presentationVisible ? WsVisible : 0) | WsClipSiblings | WsClipChildren,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
control.Handle,
|
|
||||||
0,
|
|
||||||
classInfo.Instance,
|
|
||||||
0);
|
|
||||||
if (_windowHandle == 0)
|
|
||||||
{
|
|
||||||
var error = Marshal.GetLastWin32Error();
|
|
||||||
_ = UnregisterClassW(_win32ClassName, classInfo.Instance);
|
|
||||||
throw new InvalidOperationException($"Could not create the embedded game window (Win32 error {error}).");
|
|
||||||
}
|
|
||||||
|
|
||||||
_surface = new VulkanHostSurface(
|
|
||||||
VulkanHostSurfaceKind.Win32,
|
|
||||||
_windowHandle,
|
|
||||||
classInfo.Instance);
|
|
||||||
return new PlatformHandle(_windowHandle, "HWND");
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlatformHandle CreateX11(IPlatformHandle control)
|
|
||||||
{
|
|
||||||
_x11Display = XOpenDisplay(0);
|
|
||||||
if (_x11Display == 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Could not connect to the X11 server for the embedded game surface.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_windowHandle = XCreateSimpleWindow(
|
|
||||||
_x11Display,
|
|
||||||
control.Handle,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if (_windowHandle == 0)
|
|
||||||
{
|
|
||||||
XCloseDisplay(_x11Display);
|
|
||||||
_x11Display = 0;
|
|
||||||
throw new InvalidOperationException("Could not create the X11 embedded game surface.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_presentationVisible)
|
|
||||||
{
|
|
||||||
_ = XMapWindow(_x11Display, _windowHandle);
|
|
||||||
}
|
|
||||||
_ = XFlush(_x11Display);
|
|
||||||
_surface = new VulkanHostSurface(VulkanHostSurfaceKind.Xlib, _windowHandle, _x11Display);
|
|
||||||
return new PlatformHandle(_windowHandle, "X11");
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlatformHandle CreateMacOS()
|
|
||||||
{
|
|
||||||
_metalLayer = CreateObjectiveCObject("CAMetalLayer");
|
|
||||||
_windowHandle = CreateObjectiveCObject("NSView");
|
|
||||||
SendBool(_windowHandle, "setWantsLayer:", true);
|
|
||||||
SendPointer(_windowHandle, "setLayer:", _metalLayer);
|
|
||||||
SendBool(_windowHandle, "setHidden:", !_presentationVisible);
|
|
||||||
|
|
||||||
_surface = new VulkanHostSurface(VulkanHostSurfaceKind.Metal, _windowHandle, metalLayerHandle: _metalLayer);
|
|
||||||
return new PlatformHandle(_windowHandle, "NSView");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateSurfaceSize()
|
|
||||||
{
|
|
||||||
if (_surface is null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var renderScale = (VisualRoot as TopLevel)?.RenderScaling ?? 1.0;
|
|
||||||
var width = Math.Max(1, (int)Math.Round(Bounds.Width * renderScale));
|
|
||||||
var height = Math.Max(1, (int)Math.Round(Bounds.Height * renderScale));
|
|
||||||
var sizeChanged = _surface.PixelWidth != width || _surface.PixelHeight != height;
|
|
||||||
if (Environment.GetEnvironmentVariable("SHARPEMU_TRACE_SURFACE_SIZE") == "1")
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine(
|
|
||||||
$"[GUI][TRACE] GameSurfaceHost.UpdateSurfaceSize bounds={Bounds.Width}x{Bounds.Height} " +
|
|
||||||
$"scale={renderScale} computed={width}x{height} changed={sizeChanged} " +
|
|
||||||
$"prevSurface={_surface.PixelWidth}x{_surface.PixelHeight}");
|
|
||||||
}
|
|
||||||
_surface.UpdatePixelSize(width, height);
|
|
||||||
|
|
||||||
if (!sizeChanged)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows() && _windowHandle != 0)
|
|
||||||
{
|
|
||||||
_ = SetWindowPos(
|
|
||||||
_windowHandle,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
SwpNoMove | SwpNoZOrder | SwpNoActivate);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsLinux() && _x11Display != 0 && _windowHandle != 0)
|
|
||||||
{
|
|
||||||
_ = XResizeWindow(_x11Display, _windowHandle, (uint)width, (uint)height);
|
|
||||||
_ = XFlush(_x11Display);
|
|
||||||
}
|
|
||||||
else if (OperatingSystem.IsMacOS() && _metalLayer != 0)
|
|
||||||
{
|
|
||||||
SendDouble(_metalLayer, "setContentsScale:", renderScale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DestroyWin32()
|
|
||||||
{
|
|
||||||
if (_windowHandle != 0)
|
|
||||||
{
|
|
||||||
_ = DestroyWindow(_windowHandle);
|
|
||||||
_windowHandle = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(_win32ClassName))
|
|
||||||
{
|
|
||||||
_ = UnregisterClassW(_win32ClassName, GetModuleHandleW(null));
|
|
||||||
_win32ClassName = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_windowProcedure = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DestroyX11()
|
|
||||||
{
|
|
||||||
if (_x11Display != 0 && _windowHandle != 0)
|
|
||||||
{
|
|
||||||
_ = XDestroyWindow(_x11Display, _windowHandle);
|
|
||||||
}
|
|
||||||
if (_x11Display != 0)
|
|
||||||
{
|
|
||||||
_ = XCloseDisplay(_x11Display);
|
|
||||||
}
|
|
||||||
|
|
||||||
_windowHandle = 0;
|
|
||||||
_x11Display = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DestroyMacOS()
|
|
||||||
{
|
|
||||||
if (_windowHandle != 0)
|
|
||||||
{
|
|
||||||
SendVoid(_windowHandle, "release");
|
|
||||||
}
|
|
||||||
if (_metalLayer != 0)
|
|
||||||
{
|
|
||||||
SendVoid(_metalLayer, "release");
|
|
||||||
}
|
|
||||||
|
|
||||||
_windowHandle = 0;
|
|
||||||
_metalLayer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private nint WindowProcedureImpl(nint window, uint message, nint wParam, nint lParam)
|
|
||||||
{
|
|
||||||
if (message == WmMouseMove)
|
|
||||||
{
|
|
||||||
_lastPointerActivity = System.Diagnostics.Stopwatch.GetTimestamp();
|
|
||||||
ShowCursorNow();
|
|
||||||
}
|
|
||||||
else if (message == WmSetCursor && _cursorHidden)
|
|
||||||
{
|
|
||||||
// Win32 re-resolves the cursor on every mouse message; returning
|
|
||||||
// TRUE here keeps the parent chain from restoring the arrow.
|
|
||||||
_ = SetCursor(0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProcW(window, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static nint CreateObjectiveCObject(string className)
|
|
||||||
{
|
|
||||||
var classHandle = objc_getClass(className);
|
|
||||||
if (classHandle == 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Objective-C class '{className}' is unavailable.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var instance = objc_msgSend_id(classHandle, sel_registerName("alloc"));
|
|
||||||
instance = objc_msgSend_id(instance, sel_registerName("init"));
|
|
||||||
if (instance == 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Could not create Objective-C '{className}'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SendVoid(nint receiver, string selector) =>
|
|
||||||
objc_msgSend_void(receiver, sel_registerName(selector));
|
|
||||||
|
|
||||||
private static void SendBool(nint receiver, string selector, bool value) =>
|
|
||||||
objc_msgSend_bool(receiver, sel_registerName(selector), value ? (byte)1 : (byte)0);
|
|
||||||
|
|
||||||
private static void SendPointer(nint receiver, string selector, nint value) =>
|
|
||||||
objc_msgSend_pointer(receiver, sel_registerName(selector), value);
|
|
||||||
|
|
||||||
private static void SendDouble(nint receiver, string selector, double value) =>
|
|
||||||
objc_msgSend_double(receiver, sel_registerName(selector), value);
|
|
||||||
|
|
||||||
private delegate nint WindowProcedure(nint window, uint message, nint wParam, nint lParam);
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
private struct WndClassEx
|
|
||||||
{
|
|
||||||
public uint Size;
|
|
||||||
public uint Style;
|
|
||||||
public nint WindowProcedure;
|
|
||||||
public int ClassExtra;
|
|
||||||
public int WindowExtra;
|
|
||||||
public nint Instance;
|
|
||||||
public nint Icon;
|
|
||||||
public nint Cursor;
|
|
||||||
public nint Background;
|
|
||||||
public string? MenuName;
|
|
||||||
public string? ClassName;
|
|
||||||
public nint IconSmall;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("kernel32.dll", EntryPoint = "GetModuleHandleW", CharSet = CharSet.Unicode)]
|
|
||||||
private static extern nint GetModuleHandleW(string? moduleName);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "RegisterClassExW", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
||||||
private static extern ushort RegisterClassExW(ref WndClassEx classInfo);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "UnregisterClassW", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
private static extern bool UnregisterClassW(string className, nint instance);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "CreateWindowExW", SetLastError = true, CharSet = CharSet.Unicode)]
|
|
||||||
private static extern nint CreateWindowExW(
|
|
||||||
uint extendedStyle,
|
|
||||||
string className,
|
|
||||||
string windowName,
|
|
||||||
uint style,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
nint parent,
|
|
||||||
nint menu,
|
|
||||||
nint instance,
|
|
||||||
nint parameter);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "DestroyWindow", SetLastError = true)]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
private static extern bool DestroyWindow(nint window);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos", SetLastError = true)]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
private static extern bool SetWindowPos(
|
|
||||||
nint window,
|
|
||||||
nint insertAfter,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
uint flags);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "DefWindowProcW", CharSet = CharSet.Unicode)]
|
|
||||||
private static extern nint DefWindowProcW(nint window, uint message, nint wParam, nint lParam);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "SetCursor")]
|
|
||||||
private static extern nint SetCursor(nint cursor);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "LoadCursorW", CharSet = CharSet.Unicode)]
|
|
||||||
private static extern nint LoadCursorW(nint instance, nint cursorName);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "GetCursorPos")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
private static extern bool GetCursorPos(out NativePoint point);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", EntryPoint = "WindowFromPoint")]
|
|
||||||
private static extern nint WindowFromPoint(NativePoint point);
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
private struct NativePoint
|
|
||||||
{
|
|
||||||
public int X;
|
|
||||||
public int Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XOpenDisplay")]
|
|
||||||
private static extern nint XOpenDisplay(nint displayName);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XCreateSimpleWindow")]
|
|
||||||
private static extern nint XCreateSimpleWindow(
|
|
||||||
nint display,
|
|
||||||
nint parent,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
uint width,
|
|
||||||
uint height,
|
|
||||||
uint borderWidth,
|
|
||||||
ulong border,
|
|
||||||
ulong background);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XMapWindow")]
|
|
||||||
private static extern int XMapWindow(nint display, nint window);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XUnmapWindow")]
|
|
||||||
private static extern int XUnmapWindow(nint display, nint window);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XResizeWindow")]
|
|
||||||
private static extern int XResizeWindow(nint display, nint window, uint width, uint height);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XDestroyWindow")]
|
|
||||||
private static extern int XDestroyWindow(nint display, nint window);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XCloseDisplay")]
|
|
||||||
private static extern int XCloseDisplay(nint display);
|
|
||||||
|
|
||||||
[DllImport("libX11.so.6", EntryPoint = "XFlush")]
|
|
||||||
private static extern int XFlush(nint display);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib")]
|
|
||||||
private static extern nint objc_getClass(string name);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib")]
|
|
||||||
private static extern nint sel_registerName(string name);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib", EntryPoint = "objc_msgSend")]
|
|
||||||
private static extern nint objc_msgSend_id(nint receiver, nint selector);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib", EntryPoint = "objc_msgSend")]
|
|
||||||
private static extern void objc_msgSend_void(nint receiver, nint selector);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib", EntryPoint = "objc_msgSend")]
|
|
||||||
private static extern void objc_msgSend_bool(nint receiver, nint selector, byte value);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib", EntryPoint = "objc_msgSend")]
|
|
||||||
private static extern void objc_msgSend_pointer(nint receiver, nint selector, nint value);
|
|
||||||
|
|
||||||
[DllImport("/usr/lib/libobjc.A.dylib", EntryPoint = "objc_msgSend")]
|
|
||||||
private static extern void objc_msgSend_double(nint receiver, nint selector, double value);
|
|
||||||
}
|
|
||||||
@@ -50,6 +50,20 @@ public sealed class GuiSettings
|
|||||||
|
|
||||||
public bool CheckForUpdatesOnStartup { get; set; } = true;
|
public bool CheckForUpdatesOnStartup { get; set; } = true;
|
||||||
|
|
||||||
|
public string WindowMode { get; set; } = "Windowed";
|
||||||
|
|
||||||
|
public string Resolution { get; set; } = "1920x1080";
|
||||||
|
|
||||||
|
public int DisplayIndex { get; set; }
|
||||||
|
|
||||||
|
public int RefreshRate { get; set; }
|
||||||
|
|
||||||
|
public string ScalingMode { get; set; } = "Fit";
|
||||||
|
|
||||||
|
public bool VSync { get; set; } = true;
|
||||||
|
|
||||||
|
public string HdrMode { get; set; } = "Auto";
|
||||||
|
|
||||||
/// <summary>Names of SHARPEMU_* switches set to "1" in the emulator's environment at launch.</summary>
|
/// <summary>Names of SHARPEMU_* switches set to "1" in the emulator's environment at launch.</summary>
|
||||||
public List<string> EnvironmentToggles { get; set; } = new();
|
public List<string> EnvironmentToggles { get; set; } = new();
|
||||||
|
|
||||||
@@ -103,6 +117,12 @@ public sealed class GuiSettings
|
|||||||
{
|
{
|
||||||
settings.RenderResolutionScale = 1.0;
|
settings.RenderResolutionScale = 1.0;
|
||||||
}
|
}
|
||||||
|
settings.WindowMode = NormalizeChoice(settings.WindowMode, "Windowed", "Borderless", "Exclusive");
|
||||||
|
settings.Resolution = NormalizeResolution(settings.Resolution);
|
||||||
|
settings.ScalingMode = NormalizeChoice(settings.ScalingMode, "Fit", "Cover", "Stretch", "Integer");
|
||||||
|
settings.HdrMode = NormalizeChoice(settings.HdrMode, "Auto", "On", "Off");
|
||||||
|
settings.DisplayIndex = Math.Max(0, settings.DisplayIndex);
|
||||||
|
settings.RefreshRate = Math.Clamp(settings.RefreshRate, 0, 1000);
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
@@ -118,6 +138,20 @@ public sealed class GuiSettings
|
|||||||
return source.Where(entry => !string.IsNullOrEmpty(entry)).ToList();
|
return source.Where(entry => !string.IsNullOrEmpty(entry)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string NormalizeChoice(string? value, string fallback, params string[] choices) =>
|
||||||
|
choices.Prepend(fallback).FirstOrDefault(
|
||||||
|
choice => string.Equals(choice, value, StringComparison.OrdinalIgnoreCase)) ?? fallback;
|
||||||
|
|
||||||
|
private static string NormalizeResolution(string? value)
|
||||||
|
{
|
||||||
|
if (!HostDisplayOptions.TryParseResolution(value, out var width, out var height))
|
||||||
|
{
|
||||||
|
return "1920x1080";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"{width}x{height}";
|
||||||
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using SharpEmu.Libs.VideoOut;
|
||||||
|
|
||||||
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
internal sealed record HostDisplayOption(HostDisplayInfo Display)
|
||||||
|
{
|
||||||
|
public int Index => Display.Index;
|
||||||
|
|
||||||
|
public IReadOnlyList<HostDisplayMode> Modes => Display.Modes;
|
||||||
|
|
||||||
|
public override string ToString() => $"{Index + 1}: {Display.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed record HostRefreshRateOption(int Value, string Label)
|
||||||
|
{
|
||||||
|
public override string ToString() => Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class HostDisplayOptions
|
||||||
|
{
|
||||||
|
public static IReadOnlyList<HostDisplayOption> BuildDisplays(
|
||||||
|
IReadOnlyList<HostDisplayInfo> detected,
|
||||||
|
int selectedIndex)
|
||||||
|
{
|
||||||
|
selectedIndex = Math.Max(0, selectedIndex);
|
||||||
|
var options = detected
|
||||||
|
.Select(display => new HostDisplayOption(display))
|
||||||
|
.ToList();
|
||||||
|
if (options.Count == 0)
|
||||||
|
{
|
||||||
|
options.Add(new HostDisplayOption(new HostDisplayInfo(
|
||||||
|
0,
|
||||||
|
"Display 1",
|
||||||
|
CreateFallbackModes())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.All(display => display.Index != selectedIndex))
|
||||||
|
{
|
||||||
|
options.Add(new HostDisplayOption(new HostDisplayInfo(
|
||||||
|
selectedIndex,
|
||||||
|
$"Display {selectedIndex + 1}",
|
||||||
|
options[0].Modes)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return options.OrderBy(display => display.Index).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HostDisplayOption SelectDisplay(
|
||||||
|
IReadOnlyList<HostDisplayOption> displays,
|
||||||
|
int selectedIndex) =>
|
||||||
|
displays.FirstOrDefault(display => display.Index == selectedIndex) ?? displays[0];
|
||||||
|
|
||||||
|
public static IReadOnlyList<string> BuildResolutions(
|
||||||
|
HostDisplayOption display,
|
||||||
|
string? selectedResolution)
|
||||||
|
{
|
||||||
|
var resolutions = display.Modes
|
||||||
|
.Where(mode => mode.Width > 0 && mode.Height > 0)
|
||||||
|
.Select(mode => $"{mode.Width}x{mode.Height}")
|
||||||
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
|
.ToList();
|
||||||
|
if (TryParseResolution(selectedResolution, out var selectedWidth, out var selectedHeight))
|
||||||
|
{
|
||||||
|
var selected = $"{selectedWidth}x{selectedHeight}";
|
||||||
|
if (!resolutions.Contains(selected, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
resolutions.Add(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resolutions.Count == 0)
|
||||||
|
{
|
||||||
|
resolutions.Add("1920x1080");
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolutions
|
||||||
|
.OrderByDescending(resolution => ResolutionArea(resolution))
|
||||||
|
.ThenByDescending(resolution => resolution, StringComparer.OrdinalIgnoreCase)
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IReadOnlyList<HostRefreshRateOption> BuildRefreshRates(
|
||||||
|
HostDisplayOption display,
|
||||||
|
string? resolution,
|
||||||
|
int selectedRefreshRate,
|
||||||
|
string automaticLabel)
|
||||||
|
{
|
||||||
|
TryParseResolution(resolution, out var width, out var height);
|
||||||
|
var rates = display.Modes
|
||||||
|
.Where(mode => mode.Width == width && mode.Height == height && mode.RefreshRate > 0)
|
||||||
|
.Select(mode => mode.RefreshRate)
|
||||||
|
.Distinct()
|
||||||
|
.OrderByDescending(rate => rate)
|
||||||
|
.ToList();
|
||||||
|
if (selectedRefreshRate > 0 && !rates.Contains(selectedRefreshRate))
|
||||||
|
{
|
||||||
|
rates.Add(selectedRefreshRate);
|
||||||
|
rates.Sort((left, right) => right.CompareTo(left));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new[] { new HostRefreshRateOption(0, automaticLabel) }
|
||||||
|
.Concat(rates.Select(rate => new HostRefreshRateOption(rate, $"{rate} Hz")))
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryParseResolution(string? value, out int width, out int height)
|
||||||
|
{
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var separator = value.IndexOf('x', StringComparison.OrdinalIgnoreCase);
|
||||||
|
return separator > 0 &&
|
||||||
|
int.TryParse(value.AsSpan(0, separator), out width) &&
|
||||||
|
int.TryParse(value.AsSpan(separator + 1), out height) &&
|
||||||
|
width > 0 &&
|
||||||
|
height > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long ResolutionArea(string resolution) =>
|
||||||
|
TryParseResolution(resolution, out var width, out var height)
|
||||||
|
? (long)width * height
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
private static IReadOnlyList<HostDisplayMode> CreateFallbackModes() =>
|
||||||
|
[
|
||||||
|
new HostDisplayMode(3840, 2160, 60),
|
||||||
|
new HostDisplayMode(2560, 1440, 60),
|
||||||
|
new HostDisplayMode(1920, 1080, 60),
|
||||||
|
new HostDisplayMode(1280, 720, 60),
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "ابحث في المكتبة...",
|
"Library.SearchWatermark": "ابحث في المكتبة...",
|
||||||
"Library.AddFolder": "+ إضافة مجلد",
|
"Library.AddFolder": "+ إضافة مجلد",
|
||||||
"Library.Rescan": "⟳ إعادة الفحص",
|
|
||||||
"Library.OpenFile": "فتح ملف...",
|
"Library.OpenFile": "فتح ملف...",
|
||||||
|
|
||||||
"Library.Context.Launch": "تشغيل",
|
"Library.Context.Launch": "تشغيل",
|
||||||
@@ -139,6 +138,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "تسجيل تخصيصات الذاكرة المباشرة وإخفاقاتها في وحدة التحكم.\nاستخدمه عندما تنهار لعبة أو تُغلق أثناء الإقلاع.",
|
"Options.Env.LogDirectMemory.Desc": "تسجيل تخصيصات الذاكرة المباشرة وإخفاقاتها في وحدة التحكم.\nاستخدمه عندما تنهار لعبة أو تُغلق أثناء الإقلاع.",
|
||||||
"Options.Env.LogIo.Desc": "تسجيل فتح الملفات وقراءتها وحلّ المسارات في وحدة التحكم.\nاستخدمه عندما لا تجد لعبة ملفات بياناتها أثناء الإقلاع.",
|
"Options.Env.LogIo.Desc": "تسجيل فتح الملفات وقراءتها وحلّ المسارات في وحدة التحكم.\nاستخدمه عندما لا تجد لعبة ملفات بياناتها أثناء الإقلاع.",
|
||||||
"Options.Env.LogNp.Desc": "تسجيل نداءات مكتبة NP (شبكة PlayStation) في وحدة التحكم.",
|
"Options.Env.LogNp.Desc": "تسجيل نداءات مكتبة NP (شبكة PlayStation) في وحدة التحكم.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "إعادة رفع أسطح الضيف التي تعيد كتابتها شيفرة المعالج الخاصة باللعبة.\nاتركه مغلقًا عادة. شغّله للألعاب التي لا تصل أسطحها المرسومة بالمعالج إلى الشاشة.\nيكلّف أداءً ويسبب مشاكل في بعض الألعاب مثل GTA V.",
|
||||||
"Common.Save": "حفظ",
|
"Common.Save": "حفظ",
|
||||||
"Common.Cancel": "إلغاء",
|
"Common.Cancel": "إلغاء",
|
||||||
"PerGame.Title": "إعدادات خاصة باللعبة — {0} ({1})",
|
"PerGame.Title": "إعدادات خاصة باللعبة — {0} ({1})",
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
"About.Discord.Label": "دسكورد",
|
"About.Discord.Label": "دسكورد",
|
||||||
"About.Discord.Desc": "انضم إلى المجتمع واحصل على الدعم وتابع التطوير.",
|
"About.Discord.Desc": "انضم إلى المجتمع واحصل على الدعم وتابع التطوير.",
|
||||||
"About.GithubButton": "ساهم على GitHub!",
|
"About.GithubButton": "ساهم على GitHub!",
|
||||||
"About.DiscordButton": "انضم إلى دسكوردنا!",
|
"About.DiscordComingSoon": "قريبًا",
|
||||||
"Updater.Auto.Label": "التحقق من التحديثات عند بدء التشغيل",
|
"Updater.Auto.Label": "التحقق من التحديثات عند بدء التشغيل",
|
||||||
"Updater.Auto.Desc": "يتحقق من GitHub دون تأخير بدء التشغيل.",
|
"Updater.Auto.Desc": "يتحقق من GitHub دون تأخير بدء التشغيل.",
|
||||||
"Updater.Label": "التحديثات",
|
"Updater.Label": "التحديثات",
|
||||||
@@ -168,5 +168,34 @@
|
|||||||
"Updater.Status.Timeout": "انتهت مهلة التحقق من التحديثات بعد 10 ثوانٍ.",
|
"Updater.Status.Timeout": "انتهت مهلة التحقق من التحديثات بعد 10 ثوانٍ.",
|
||||||
"Updater.Status.Failed": "تعذر التحقق من التحديثات.",
|
"Updater.Status.Failed": "تعذر التحقق من التحديثات.",
|
||||||
"Updater.Status.ChecksumFailed": "فشل التحديث المنزَّل في اجتياز تحقق SHA-256.",
|
"Updater.Status.ChecksumFailed": "فشل التحديث المنزَّل في اجتياز تحقق SHA-256.",
|
||||||
"Updater.Status.Unsupported": "يتطلب التحديث التلقائي إصدار x64 لنظام Windows أو Linux أو macOS."
|
"Updater.Status.Unsupported": "يتطلب التحديث التلقائي إصدار x64 لنظام Windows أو Linux أو macOS.",
|
||||||
|
"Options.Graphics": "الرسومات",
|
||||||
|
"Options.Section.Rendering": "التصيير",
|
||||||
|
"Options.Section.Display": "العرض",
|
||||||
|
"Options.RenderResolution.Label": "الدقة الداخلية",
|
||||||
|
"Options.RenderResolution.Desc": "تصيير الأهداف خارج الشاشة بدقة أقل من الدقة الأصلية ثم رفع دقتها عند العرض. تمنح القيم الأقل مساحة أكبر لوحدة معالجة الرسوميات مقابل جودة الصورة؛ يُطبق عند التشغيل التالي.",
|
||||||
|
"Options.RenderResolution.Native": "100% (أصلية)",
|
||||||
|
"Options.WindowMode.Label": "وضع النافذة",
|
||||||
|
"Options.WindowMode.Desc": "نافذة عادية، أو سطح مكتب بلا حدود، أو ملء شاشة حصري.",
|
||||||
|
"Options.WindowMode.Windowed": "نافذة",
|
||||||
|
"Options.WindowMode.Borderless": "بلا حدود",
|
||||||
|
"Options.WindowMode.Exclusive": "حصري",
|
||||||
|
"Options.Resolution.Label": "الدقة",
|
||||||
|
"Options.Resolution.Desc": "حجم النافذة الأولي أو دقة ملء الشاشة الحصرية.",
|
||||||
|
"Options.Display.Label": "الشاشة",
|
||||||
|
"Options.Display.Desc": "الشاشة المستخدمة للتوسيط وملء الشاشة.",
|
||||||
|
"Options.RefreshRate.Label": "معدل التحديث",
|
||||||
|
"Options.RefreshRate.Desc": "معدل تحديث ملء الشاشة الحصري. يختار الوضع التلقائي أقرب نمط.",
|
||||||
|
"Options.RefreshRate.Automatic": "تلقائي",
|
||||||
|
"Options.Scaling.Label": "التحجيم",
|
||||||
|
"Options.Scaling.Desc": "تحجيم صورة النظام الضيف الأصلية دون تغيير دقتها الداخلية.",
|
||||||
|
"Options.Scaling.Fit": "ملاءمة",
|
||||||
|
"Options.Scaling.Cover": "تغطية",
|
||||||
|
"Options.Scaling.Stretch": "تمديد",
|
||||||
|
"Options.Scaling.Integer": "عدد صحيح",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "استخدام عرض FIFO لإخراج خالٍ من تمزق الصورة.",
|
||||||
|
"Options.Hdr.Label": "إخراج HDR",
|
||||||
|
"Options.Hdr.Desc": "استخدام HDR عندما تدعمه الشاشة المحددة وواجهة الرسومات. يعود الوضع التلقائي إلى SDR.",
|
||||||
|
"Options.Hdr.Auto": "تلقائي"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Pesquisar na biblioteca…",
|
"Library.SearchWatermark": "Pesquisar na biblioteca…",
|
||||||
"Library.AddFolder": "+ Adicionar pasta",
|
"Library.AddFolder": "+ Adicionar pasta",
|
||||||
"Library.Rescan": "⟳ Atualizar biblioteca",
|
|
||||||
"Library.OpenFile": "Abrir arquivo…",
|
"Library.OpenFile": "Abrir arquivo…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Jogar",
|
"Library.Context.Launch": "Jogar",
|
||||||
@@ -35,6 +34,7 @@
|
|||||||
"Options.Env.DumpSpirv.Desc": "Extrai os shaders AGC e suas traduções SPIR-V para a pasta shader-dumps.\nUse ao reportar bugs de shader ou renderização.",
|
"Options.Env.DumpSpirv.Desc": "Extrai os shaders AGC e suas traduções SPIR-V para a pasta shader-dumps.\nUse ao reportar bugs de shader ou renderização.",
|
||||||
"Options.Env.LogDirectMemory.Desc": "Registra alocações de memória direta e falhas no console.\nUse quando um jogo aborta ou fecha durante a inicialização (boot).",
|
"Options.Env.LogDirectMemory.Desc": "Registra alocações de memória direta e falhas no console.\nUse quando um jogo aborta ou fecha durante a inicialização (boot).",
|
||||||
"Options.Env.LogNp.Desc": "Registra chamadas da biblioteca NP (PlayStation Network) no console.",
|
"Options.Env.LogNp.Desc": "Registra chamadas da biblioteca NP (PlayStation Network) no console.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Recarrega as superfícies do convidado que o próprio código de CPU do jogo reescreve.\nDeixe desativado normalmente. Ative para títulos cujas superfícies desenhadas pela CPU nunca chegam à tela.\nCusta desempenho e causa regressões em alguns títulos, como GTA V.",
|
||||||
"Options.Section.Emulation": "EMULAÇÃO",
|
"Options.Section.Emulation": "EMULAÇÃO",
|
||||||
"Options.Section.Logging": "LOGS",
|
"Options.Section.Logging": "LOGS",
|
||||||
"Options.Section.Launcher": "INICIALIZADOR",
|
"Options.Section.Launcher": "INICIALIZADOR",
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Participe da comunidade, obtenha suporte e acompanhe o desenvolvimento.",
|
"About.Discord.Desc": "Participe da comunidade, obtenha suporte e acompanhe o desenvolvimento.",
|
||||||
"About.GithubButton": "Contribua no GitHub!",
|
"About.GithubButton": "Contribua no GitHub!",
|
||||||
"About.DiscordButton": "Entre no nosso Discord!",
|
"About.DiscordComingSoon": "Em breve",
|
||||||
|
|
||||||
"Library.Context.GameSettings": "Configurações do jogo…",
|
"Library.Context.GameSettings": "Configurações do jogo…",
|
||||||
"Options.Env.WritableApp0.Desc": "Permite que os jogos criem e gravem arquivos dentro da própria pasta de instalação.\nNecessário para dumps não empacotados que gravam seus saves ou configurações em /app0.",
|
"Options.Env.WritableApp0.Desc": "Permite que os jogos criem e gravem arquivos dentro da própria pasta de instalação.\nNecessário para dumps não empacotados que gravam seus saves ou configurações em /app0.",
|
||||||
@@ -169,5 +169,34 @@
|
|||||||
"Updater.Status.Timeout": "A verificação de atualizações expirou após 10 segundos.",
|
"Updater.Status.Timeout": "A verificação de atualizações expirou após 10 segundos.",
|
||||||
"Updater.Status.Failed": "Não foi possível verificar as atualizações.",
|
"Updater.Status.Failed": "Não foi possível verificar as atualizações.",
|
||||||
"Updater.Status.ChecksumFailed": "A atualização baixada falhou na verificação SHA-256.",
|
"Updater.Status.ChecksumFailed": "A atualização baixada falhou na verificação SHA-256.",
|
||||||
"Updater.Status.Unsupported": "A atualização automática requer um build x64 para Windows, Linux ou macOS."
|
"Updater.Status.Unsupported": "A atualização automática requer um build x64 para Windows, Linux ou macOS.",
|
||||||
|
"Options.Graphics": "Gráficos",
|
||||||
|
"Options.Section.Rendering": "RENDERIZAÇÃO",
|
||||||
|
"Options.Section.Display": "TELA",
|
||||||
|
"Options.RenderResolution.Label": "Resolução interna",
|
||||||
|
"Options.RenderResolution.Desc": "Renderiza alvos fora da tela abaixo da resolução nativa e amplia na apresentação. Valores menores trocam qualidade de imagem por folga da GPU; entra em vigor na próxima inicialização.",
|
||||||
|
"Options.RenderResolution.Native": "100% (nativa)",
|
||||||
|
"Options.WindowMode.Label": "Modo de janela",
|
||||||
|
"Options.WindowMode.Desc": "Janela normal, área de trabalho sem bordas ou tela cheia exclusiva.",
|
||||||
|
"Options.WindowMode.Windowed": "Em janela",
|
||||||
|
"Options.WindowMode.Borderless": "Sem bordas",
|
||||||
|
"Options.WindowMode.Exclusive": "Exclusiva",
|
||||||
|
"Options.Resolution.Label": "Resolução",
|
||||||
|
"Options.Resolution.Desc": "Tamanho inicial da janela ou resolução de tela cheia exclusiva.",
|
||||||
|
"Options.Display.Label": "Tela",
|
||||||
|
"Options.Display.Desc": "Monitor usado para centralização e tela cheia.",
|
||||||
|
"Options.RefreshRate.Label": "Taxa de atualização",
|
||||||
|
"Options.RefreshRate.Desc": "Taxa de atualização da tela cheia exclusiva. O modo automático seleciona o modo mais próximo.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automática",
|
||||||
|
"Options.Scaling.Label": "Escala",
|
||||||
|
"Options.Scaling.Desc": "Dimensiona a imagem nativa do sistema convidado sem alterar sua resolução interna.",
|
||||||
|
"Options.Scaling.Fit": "Ajustar",
|
||||||
|
"Options.Scaling.Cover": "Preencher",
|
||||||
|
"Options.Scaling.Stretch": "Esticar",
|
||||||
|
"Options.Scaling.Integer": "Inteira",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Usa apresentação FIFO para evitar cortes na imagem.",
|
||||||
|
"Options.Hdr.Label": "Saída HDR",
|
||||||
|
"Options.Hdr.Desc": "Usa HDR quando a tela selecionada e o backend gráfico oferecem suporte. O modo automático retorna ao SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automático"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Bibliothek durchsuchen…",
|
"Library.SearchWatermark": "Bibliothek durchsuchen…",
|
||||||
"Library.AddFolder": "+ Spielordner hinzufügen",
|
"Library.AddFolder": "+ Spielordner hinzufügen",
|
||||||
"Library.Rescan": "⟳ Neu scannen",
|
|
||||||
"Library.OpenFile": "Datei öffnen…",
|
"Library.OpenFile": "Datei öffnen…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Starten",
|
"Library.Context.Launch": "Starten",
|
||||||
@@ -139,6 +138,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Direkte Speicherzuweisungen und Fehler in der Konsole protokollieren.\nVerwenden, wenn ein Spiel beim Start abbricht oder sich beendet.",
|
"Options.Env.LogDirectMemory.Desc": "Direkte Speicherzuweisungen und Fehler in der Konsole protokollieren.\nVerwenden, wenn ein Spiel beim Start abbricht oder sich beendet.",
|
||||||
"Options.Env.LogIo.Desc": "Datei-Öffnen, -Lesen und Pfadauflösung in der Konsole protokollieren.\nVerwenden, wenn ein Spiel beim Start seine Datendateien nicht findet.",
|
"Options.Env.LogIo.Desc": "Datei-Öffnen, -Lesen und Pfadauflösung in der Konsole protokollieren.\nVerwenden, wenn ein Spiel beim Start seine Datendateien nicht findet.",
|
||||||
"Options.Env.LogNp.Desc": "NP-Bibliotheksaufrufe (PlayStation Network) in der Konsole protokollieren.",
|
"Options.Env.LogNp.Desc": "NP-Bibliotheksaufrufe (PlayStation Network) in der Konsole protokollieren.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Gast-Oberflächen neu hochladen, die der eigene CPU-Code des Spiels überschreibt.\nNormalerweise aus lassen. Für Titel aktivieren, deren CPU-gezeichnete Oberflächen nie auf dem Bildschirm erscheinen.\nKostet Leistung und verursacht bei einigen Titeln wie GTA V Regressionen.",
|
||||||
"Common.Save": "Speichern",
|
"Common.Save": "Speichern",
|
||||||
"Common.Cancel": "Abbrechen",
|
"Common.Cancel": "Abbrechen",
|
||||||
"PerGame.Title": "Spielspezifische Einstellungen — {0} ({1})",
|
"PerGame.Title": "Spielspezifische Einstellungen — {0} ({1})",
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Tritt der Community bei, erhalte Support und verfolge die Entwicklung.",
|
"About.Discord.Desc": "Tritt der Community bei, erhalte Support und verfolge die Entwicklung.",
|
||||||
"About.GithubButton": "Auf GitHub mitwirken!",
|
"About.GithubButton": "Auf GitHub mitwirken!",
|
||||||
"About.DiscordButton": "Tritt unserem Discord bei!",
|
"About.DiscordComingSoon": "Demnächst verfügbar",
|
||||||
"Updater.Auto.Label": "Beim Start nach Updates suchen",
|
"Updater.Auto.Label": "Beim Start nach Updates suchen",
|
||||||
"Updater.Auto.Desc": "Fragt GitHub ab, ohne den Start zu verzögern.",
|
"Updater.Auto.Desc": "Fragt GitHub ab, ohne den Start zu verzögern.",
|
||||||
"Updater.Label": "Updates",
|
"Updater.Label": "Updates",
|
||||||
@@ -168,5 +168,34 @@
|
|||||||
"Updater.Status.Timeout": "Die Updateprüfung ist nach 10 Sekunden abgelaufen.",
|
"Updater.Status.Timeout": "Die Updateprüfung ist nach 10 Sekunden abgelaufen.",
|
||||||
"Updater.Status.Failed": "Updates konnten nicht geprüft werden.",
|
"Updater.Status.Failed": "Updates konnten nicht geprüft werden.",
|
||||||
"Updater.Status.ChecksumFailed": "Das heruntergeladene Update hat die SHA-256-Prüfung nicht bestanden.",
|
"Updater.Status.ChecksumFailed": "Das heruntergeladene Update hat die SHA-256-Prüfung nicht bestanden.",
|
||||||
"Updater.Status.Unsupported": "Automatische Updates erfordern einen x64-Build für Windows, Linux oder macOS."
|
"Updater.Status.Unsupported": "Automatische Updates erfordern einen x64-Build für Windows, Linux oder macOS.",
|
||||||
|
"Options.Graphics": "Grafik",
|
||||||
|
"Options.Section.Rendering": "DARSTELLUNG",
|
||||||
|
"Options.Section.Display": "ANZEIGE",
|
||||||
|
"Options.RenderResolution.Label": "Interne Auflösung",
|
||||||
|
"Options.RenderResolution.Desc": "Offscreen-Ziele unterhalb der nativen Auflösung rendern und bei der Ausgabe hochskalieren. Niedrigere Werte tauschen Bildqualität gegen GPU-Reserven; wird beim nächsten Start wirksam.",
|
||||||
|
"Options.RenderResolution.Native": "100 % (nativ)",
|
||||||
|
"Options.WindowMode.Label": "Fenstermodus",
|
||||||
|
"Options.WindowMode.Desc": "Normales Fenster, randloser Desktop oder exklusiver Vollbildmodus.",
|
||||||
|
"Options.WindowMode.Windowed": "Fenster",
|
||||||
|
"Options.WindowMode.Borderless": "Randlos",
|
||||||
|
"Options.WindowMode.Exclusive": "Exklusiv",
|
||||||
|
"Options.Resolution.Label": "Auflösung",
|
||||||
|
"Options.Resolution.Desc": "Anfängliche Fenstergröße oder exklusive Vollbildauflösung.",
|
||||||
|
"Options.Display.Label": "Anzeige",
|
||||||
|
"Options.Display.Desc": "Monitor für Zentrierung und Vollbilddarstellung.",
|
||||||
|
"Options.RefreshRate.Label": "Bildwiederholrate",
|
||||||
|
"Options.RefreshRate.Desc": "Bildwiederholrate im exklusiven Vollbildmodus. Automatisch wählt den nächstgelegenen Modus.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatisch",
|
||||||
|
"Options.Scaling.Label": "Skalierung",
|
||||||
|
"Options.Scaling.Desc": "Das native Gastbild skalieren, ohne seine interne Auflösung zu ändern.",
|
||||||
|
"Options.Scaling.Fit": "Einpassen",
|
||||||
|
"Options.Scaling.Cover": "Ausfüllen",
|
||||||
|
"Options.Scaling.Stretch": "Strecken",
|
||||||
|
"Options.Scaling.Integer": "Ganzzahlig",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "FIFO-Präsentation für eine Ausgabe ohne Tearing verwenden.",
|
||||||
|
"Options.Hdr.Label": "HDR-Ausgabe",
|
||||||
|
"Options.Hdr.Desc": "HDR verwenden, wenn die ausgewählte Anzeige und das Grafik-Backend es unterstützen. Automatisch fällt auf SDR zurück.",
|
||||||
|
"Options.Hdr.Auto": "Automatisch"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Søg i biblioteket…",
|
"Library.SearchWatermark": "Søg i biblioteket…",
|
||||||
"Library.AddFolder": "+ Tilføj mappe",
|
"Library.AddFolder": "+ Tilføj mappe",
|
||||||
"Library.Rescan": "⟳ Genindlæs",
|
|
||||||
"Library.OpenFile": "Åbn fil…",
|
"Library.OpenFile": "Åbn fil…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Start",
|
"Library.Context.Launch": "Start",
|
||||||
@@ -139,6 +138,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Log direkte hukommelsestildelinger og fejl til konsollen.\nBrug dette, når et spil afbryder eller lukker under opstart.",
|
"Options.Env.LogDirectMemory.Desc": "Log direkte hukommelsestildelinger og fejl til konsollen.\nBrug dette, når et spil afbryder eller lukker under opstart.",
|
||||||
"Options.Env.LogIo.Desc": "Log åbning og læsning af filer samt stiopslag til konsollen.\nBrug dette, når et spil ikke kan finde sine datafiler under opstart.",
|
"Options.Env.LogIo.Desc": "Log åbning og læsning af filer samt stiopslag til konsollen.\nBrug dette, når et spil ikke kan finde sine datafiler under opstart.",
|
||||||
"Options.Env.LogNp.Desc": "Log NP-bibliotekskald (PlayStation Network) til konsollen.",
|
"Options.Env.LogNp.Desc": "Log NP-bibliotekskald (PlayStation Network) til konsollen.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Genindlæs gæsteoverflader, som spillets egen CPU-kode omskriver.\nLad den være slået fra normalt. Slå til for titler, hvis CPU-tegnede overflader aldrig når skærmen.\nKoster ydeevne og giver regressioner i nogle titler, såsom GTA V.",
|
||||||
"Common.Save": "Gem",
|
"Common.Save": "Gem",
|
||||||
"Common.Cancel": "Annuller",
|
"Common.Cancel": "Annuller",
|
||||||
"PerGame.Title": "Indstillinger pr. spil — {0} ({1})",
|
"PerGame.Title": "Indstillinger pr. spil — {0} ({1})",
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Bliv en del af fællesskabet, få hjælp og følg udviklingen.",
|
"About.Discord.Desc": "Bliv en del af fællesskabet, få hjælp og følg udviklingen.",
|
||||||
"About.GithubButton": "Bidrag på GitHub!",
|
"About.GithubButton": "Bidrag på GitHub!",
|
||||||
"About.DiscordButton": "Bliv medlem af vores Discord!",
|
"About.DiscordComingSoon": "Kommer snart",
|
||||||
"Updater.Auto.Label": "Søg efter opdateringer ved start",
|
"Updater.Auto.Label": "Søg efter opdateringer ved start",
|
||||||
"Updater.Auto.Desc": "Tjekker GitHub uden at forsinke opstarten.",
|
"Updater.Auto.Desc": "Tjekker GitHub uden at forsinke opstarten.",
|
||||||
"Updater.Label": "Opdateringer",
|
"Updater.Label": "Opdateringer",
|
||||||
@@ -168,5 +168,34 @@
|
|||||||
"Updater.Status.Timeout": "Opdateringstjekket fik timeout efter 10 sekunder.",
|
"Updater.Status.Timeout": "Opdateringstjekket fik timeout efter 10 sekunder.",
|
||||||
"Updater.Status.Failed": "Kunne ikke søge efter opdateringer.",
|
"Updater.Status.Failed": "Kunne ikke søge efter opdateringer.",
|
||||||
"Updater.Status.ChecksumFailed": "Den downloadede opdatering bestod ikke SHA-256-verifikationen.",
|
"Updater.Status.ChecksumFailed": "Den downloadede opdatering bestod ikke SHA-256-verifikationen.",
|
||||||
"Updater.Status.Unsupported": "Automatisk opdatering kræver et x64-build til Windows, Linux eller macOS."
|
"Updater.Status.Unsupported": "Automatisk opdatering kræver et x64-build til Windows, Linux eller macOS.",
|
||||||
|
"Options.Graphics": "Grafik",
|
||||||
|
"Options.Section.Rendering": "GENGIVELSE",
|
||||||
|
"Options.Section.Display": "SKÆRM",
|
||||||
|
"Options.RenderResolution.Label": "Intern opløsning",
|
||||||
|
"Options.RenderResolution.Desc": "Render offscreen-mål under den oprindelige opløsning, og opskaler dem ved visning. Lavere værdier bytter billedkvalitet for GPU-kapacitet; træder i kraft ved næste start.",
|
||||||
|
"Options.RenderResolution.Native": "100 % (oprindelig)",
|
||||||
|
"Options.WindowMode.Label": "Vinduestilstand",
|
||||||
|
"Options.WindowMode.Desc": "Normalt vindue, kantløst skrivebord eller eksklusiv fuldskærm.",
|
||||||
|
"Options.WindowMode.Windowed": "Vindue",
|
||||||
|
"Options.WindowMode.Borderless": "Kantløs",
|
||||||
|
"Options.WindowMode.Exclusive": "Eksklusiv",
|
||||||
|
"Options.Resolution.Label": "Opløsning",
|
||||||
|
"Options.Resolution.Desc": "Oprindelig vinduesstørrelse eller opløsning i eksklusiv fuldskærm.",
|
||||||
|
"Options.Display.Label": "Skærm",
|
||||||
|
"Options.Display.Desc": "Skærm, der bruges til centrering og fuldskærm.",
|
||||||
|
"Options.RefreshRate.Label": "Opdateringshastighed",
|
||||||
|
"Options.RefreshRate.Desc": "Opdateringshastighed i eksklusiv fuldskærm. Automatisk vælger den nærmeste tilstand.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatisk",
|
||||||
|
"Options.Scaling.Label": "Skalering",
|
||||||
|
"Options.Scaling.Desc": "Skaler det oprindelige gæstebillede uden at ændre dets interne opløsning.",
|
||||||
|
"Options.Scaling.Fit": "Tilpas",
|
||||||
|
"Options.Scaling.Cover": "Udfyld",
|
||||||
|
"Options.Scaling.Stretch": "Stræk",
|
||||||
|
"Options.Scaling.Integer": "Heltal",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Brug FIFO-præsentation for output uden tearing.",
|
||||||
|
"Options.Hdr.Label": "HDR-output",
|
||||||
|
"Options.Hdr.Desc": "Brug HDR, når den valgte skærm og grafik-backend understøtter det. Automatisk falder tilbage til SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automatisk"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Search library…",
|
"Library.SearchWatermark": "Search library…",
|
||||||
"Library.AddFolder": "+ Add folder",
|
"Library.AddFolder": "+ Add folder",
|
||||||
"Library.Rescan": "⟳ Rescan",
|
|
||||||
"Library.OpenFile": "Open file…",
|
"Library.OpenFile": "Open file…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Launch",
|
"Library.Context.Launch": "Launch",
|
||||||
@@ -38,9 +37,40 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Log direct memory allocations and failures to the console.\nUse when a game aborts or exits during boot.",
|
"Options.Env.LogDirectMemory.Desc": "Log direct memory allocations and failures to the console.\nUse when a game aborts or exits during boot.",
|
||||||
"Options.Env.LogIo.Desc": "Log file open, read, and path-resolve activity to the console.\nUse when a game cannot find its data files during boot.",
|
"Options.Env.LogIo.Desc": "Log file open, read, and path-resolve activity to the console.\nUse when a game cannot find its data files during boot.",
|
||||||
"Options.Env.LogNp.Desc": "Log NP (PlayStation Network) library calls to the console.",
|
"Options.Env.LogNp.Desc": "Log NP (PlayStation Network) library calls to the console.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Re-upload guest surfaces the game's own CPU code rewrites.\nLeave off normally. Turn on for titles whose CPU-drawn surfaces never reach the screen.\nCosts performance and regresses some titles, such as GTA V.",
|
||||||
"Options.Section.Emulation": "EMULATION",
|
"Options.Section.Emulation": "EMULATION",
|
||||||
"Options.Section.Logging": "LOGGING",
|
"Options.Section.Logging": "LOGGING",
|
||||||
"Options.Section.Launcher": "LAUNCHER",
|
"Options.Section.Launcher": "LAUNCHER",
|
||||||
|
"Options.Section.Rendering": "RENDERING",
|
||||||
|
"Options.Section.Display": "DISPLAY",
|
||||||
|
"Options.Graphics": "Graphics",
|
||||||
|
|
||||||
|
"Options.RenderResolution.Label": "Internal resolution",
|
||||||
|
"Options.RenderResolution.Desc": "Render offscreen targets below native resolution and upscale on present. Lower values trade image quality for GPU headroom; takes effect on next launch.",
|
||||||
|
"Options.RenderResolution.Native": "100% (native)",
|
||||||
|
"Options.WindowMode.Label": "Window mode",
|
||||||
|
"Options.WindowMode.Desc": "Regular window, desktop borderless, or exclusive fullscreen.",
|
||||||
|
"Options.WindowMode.Windowed": "Windowed",
|
||||||
|
"Options.WindowMode.Borderless": "Borderless",
|
||||||
|
"Options.WindowMode.Exclusive": "Exclusive",
|
||||||
|
"Options.Resolution.Label": "Resolution",
|
||||||
|
"Options.Resolution.Desc": "Initial window size or exclusive fullscreen resolution.",
|
||||||
|
"Options.Display.Label": "Display",
|
||||||
|
"Options.Display.Desc": "Monitor used for centering and fullscreen.",
|
||||||
|
"Options.RefreshRate.Label": "Refresh rate",
|
||||||
|
"Options.RefreshRate.Desc": "Exclusive fullscreen refresh rate. Automatic selects the closest mode.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatic",
|
||||||
|
"Options.Scaling.Label": "Scaling",
|
||||||
|
"Options.Scaling.Desc": "Scale the native guest image without changing its internal resolution.",
|
||||||
|
"Options.Scaling.Fit": "Fit",
|
||||||
|
"Options.Scaling.Cover": "Cover",
|
||||||
|
"Options.Scaling.Stretch": "Stretch",
|
||||||
|
"Options.Scaling.Integer": "Integer",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Use FIFO presentation for tear-free output.",
|
||||||
|
"Options.Hdr.Label": "HDR output",
|
||||||
|
"Options.Hdr.Desc": "Use HDR when the selected display and graphics backend support it. Auto falls back to SDR.",
|
||||||
|
"Options.Hdr.Auto": "Auto",
|
||||||
|
|
||||||
"Options.CpuEngine.Label": "CPU engine",
|
"Options.CpuEngine.Label": "CPU engine",
|
||||||
"Options.CpuEngine.Desc": "Execution engine used to run game code.",
|
"Options.CpuEngine.Desc": "Execution engine used to run game code.",
|
||||||
@@ -87,6 +117,8 @@
|
|||||||
|
|
||||||
"PerGame.Title": "Per-game settings — {0} ({1})",
|
"PerGame.Title": "Per-game settings — {0} ({1})",
|
||||||
"PerGame.InheritNote": "Unchecked rows inherit the global defaults.",
|
"PerGame.InheritNote": "Unchecked rows inherit the global defaults.",
|
||||||
|
"PerGame.Tab.General": "General",
|
||||||
|
"PerGame.Tab.Graphics": "Graphics",
|
||||||
"PerGame.EnvToggles.Label": "Environment toggles",
|
"PerGame.EnvToggles.Label": "Environment toggles",
|
||||||
"PerGame.EnvToggles.Desc": "Override the global set of SHARPEMU_* switches for this game.",
|
"PerGame.EnvToggles.Desc": "Override the global set of SHARPEMU_* switches for this game.",
|
||||||
|
|
||||||
@@ -154,7 +186,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Join the community, get support and follow development.",
|
"About.Discord.Desc": "Join the community, get support and follow development.",
|
||||||
"About.GithubButton": "Contribute in GitHub!",
|
"About.GithubButton": "Contribute in GitHub!",
|
||||||
"About.DiscordButton": "Join our Discord!",
|
"About.DiscordComingSoon": "Coming soon",
|
||||||
|
|
||||||
"Updater.Auto.Label": "Check for updates on startup",
|
"Updater.Auto.Label": "Check for updates on startup",
|
||||||
"Updater.Auto.Desc": "Checks GitHub without delaying startup.",
|
"Updater.Auto.Desc": "Checks GitHub without delaying startup.",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Buscar en la biblioteca…",
|
"Library.SearchWatermark": "Buscar en la biblioteca…",
|
||||||
"Library.AddFolder": "+ Añadir carpeta",
|
"Library.AddFolder": "+ Añadir carpeta",
|
||||||
"Library.Rescan": "⟳ Volver a escanear",
|
|
||||||
"Library.OpenFile": "Abrir archivo…",
|
"Library.OpenFile": "Abrir archivo…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Iniciar",
|
"Library.Context.Launch": "Iniciar",
|
||||||
@@ -135,7 +134,7 @@
|
|||||||
"About.Github.LatestCommitDescription": "Último commit en la rama main",
|
"About.Github.LatestCommitDescription": "Último commit en la rama main",
|
||||||
"About.Discord.Desc": "Únete a la comunidad, recibe soporte y sigue el desarrollo.",
|
"About.Discord.Desc": "Únete a la comunidad, recibe soporte y sigue el desarrollo.",
|
||||||
"About.GithubButton": "Contribuye en GitHub!",
|
"About.GithubButton": "Contribuye en GitHub!",
|
||||||
"About.DiscordButton": "Únete a nuestro Discord!",
|
"About.DiscordComingSoon": "Próximamente",
|
||||||
|
|
||||||
"Library.Context.GameSettings": "Ajustes del juego…",
|
"Library.Context.GameSettings": "Ajustes del juego…",
|
||||||
"Options.Env.Tab": "Entorno",
|
"Options.Env.Tab": "Entorno",
|
||||||
@@ -149,6 +148,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Registrar en la consola las asignaciones de memoria directa y sus fallos.\nÚsalo cuando un juego se aborte o se cierre durante el arranque.",
|
"Options.Env.LogDirectMemory.Desc": "Registrar en la consola las asignaciones de memoria directa y sus fallos.\nÚsalo cuando un juego se aborte o se cierre durante el arranque.",
|
||||||
"Options.Env.LogIo.Desc": "Registrar en la consola la apertura y lectura de archivos y la resolución de rutas.\nÚsalo cuando un juego no encuentre sus archivos de datos durante el arranque.",
|
"Options.Env.LogIo.Desc": "Registrar en la consola la apertura y lectura de archivos y la resolución de rutas.\nÚsalo cuando un juego no encuentre sus archivos de datos durante el arranque.",
|
||||||
"Options.Env.LogNp.Desc": "Registrar en la consola las llamadas a la biblioteca NP (PlayStation Network).",
|
"Options.Env.LogNp.Desc": "Registrar en la consola las llamadas a la biblioteca NP (PlayStation Network).",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Volver a subir las superficies del invitado que reescribe el propio código de CPU del juego.\nDejar desactivado normalmente. Activar en títulos cuyas superficies dibujadas por CPU nunca llegan a la pantalla.\nCuesta rendimiento y causa regresiones en algunos títulos, como GTA V.",
|
||||||
"Common.Save": "Guardar",
|
"Common.Save": "Guardar",
|
||||||
"Common.Cancel": "Cancelar",
|
"Common.Cancel": "Cancelar",
|
||||||
"PerGame.Title": "Ajustes por juego — {0} ({1})",
|
"PerGame.Title": "Ajustes por juego — {0} ({1})",
|
||||||
@@ -169,5 +169,34 @@
|
|||||||
"Updater.Status.Timeout": "La comprobación de actualizaciones caducó tras 10 segundos.",
|
"Updater.Status.Timeout": "La comprobación de actualizaciones caducó tras 10 segundos.",
|
||||||
"Updater.Status.Failed": "No se pudieron comprobar las actualizaciones.",
|
"Updater.Status.Failed": "No se pudieron comprobar las actualizaciones.",
|
||||||
"Updater.Status.ChecksumFailed": "La actualización descargada no superó la verificación SHA-256.",
|
"Updater.Status.ChecksumFailed": "La actualización descargada no superó la verificación SHA-256.",
|
||||||
"Updater.Status.Unsupported": "La actualización automática requiere un build x64 de Windows, Linux o macOS."
|
"Updater.Status.Unsupported": "La actualización automática requiere un build x64 de Windows, Linux o macOS.",
|
||||||
|
"Options.Graphics": "Gráficos",
|
||||||
|
"Options.Section.Rendering": "RENDERIZADO",
|
||||||
|
"Options.Section.Display": "PANTALLA",
|
||||||
|
"Options.RenderResolution.Label": "Resolución interna",
|
||||||
|
"Options.RenderResolution.Desc": "Renderiza objetivos fuera de pantalla por debajo de la resolución nativa y los reescala al presentar. Los valores inferiores sacrifican calidad de imagen para liberar carga de la GPU; se aplica en el próximo inicio.",
|
||||||
|
"Options.RenderResolution.Native": "100 % (nativa)",
|
||||||
|
"Options.WindowMode.Label": "Modo de ventana",
|
||||||
|
"Options.WindowMode.Desc": "Ventana normal, escritorio sin bordes o pantalla completa exclusiva.",
|
||||||
|
"Options.WindowMode.Windowed": "En ventana",
|
||||||
|
"Options.WindowMode.Borderless": "Sin bordes",
|
||||||
|
"Options.WindowMode.Exclusive": "Exclusiva",
|
||||||
|
"Options.Resolution.Label": "Resolución",
|
||||||
|
"Options.Resolution.Desc": "Tamaño inicial de la ventana o resolución de pantalla completa exclusiva.",
|
||||||
|
"Options.Display.Label": "Pantalla",
|
||||||
|
"Options.Display.Desc": "Monitor utilizado para centrar y mostrar a pantalla completa.",
|
||||||
|
"Options.RefreshRate.Label": "Frecuencia de actualización",
|
||||||
|
"Options.RefreshRate.Desc": "Frecuencia de actualización de la pantalla completa exclusiva. El modo automático selecciona el modo más cercano.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automática",
|
||||||
|
"Options.Scaling.Label": "Escalado",
|
||||||
|
"Options.Scaling.Desc": "Escala la imagen nativa del sistema invitado sin cambiar su resolución interna.",
|
||||||
|
"Options.Scaling.Fit": "Ajustar",
|
||||||
|
"Options.Scaling.Cover": "Cubrir",
|
||||||
|
"Options.Scaling.Stretch": "Estirar",
|
||||||
|
"Options.Scaling.Integer": "Entero",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Usa presentación FIFO para evitar el desgarro de imagen.",
|
||||||
|
"Options.Hdr.Label": "Salida HDR",
|
||||||
|
"Options.Hdr.Desc": "Usa HDR cuando la pantalla seleccionada y el backend gráfico sean compatibles. El modo automático vuelve a SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automático"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Rechercher dans la bibliothèque…",
|
"Library.SearchWatermark": "Rechercher dans la bibliothèque…",
|
||||||
"Library.AddFolder": "+ Ajouter un dossier",
|
"Library.AddFolder": "+ Ajouter un dossier",
|
||||||
"Library.Rescan": "⟳ Analyser à nouveau",
|
|
||||||
"Library.OpenFile": "Ouvrir un fichier…",
|
"Library.OpenFile": "Ouvrir un fichier…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Lancer",
|
"Library.Context.Launch": "Lancer",
|
||||||
@@ -35,6 +34,7 @@
|
|||||||
"Options.Env.DumpSpirv.Desc": "Exporter les shaders AGC et leurs traductions SPIR-V dans le dossier shader-dumps.\nÀ utiliser pour signaler des bugs de shader ou de rendu.",
|
"Options.Env.DumpSpirv.Desc": "Exporter les shaders AGC et leurs traductions SPIR-V dans le dossier shader-dumps.\nÀ utiliser pour signaler des bugs de shader ou de rendu.",
|
||||||
"Options.Env.LogDirectMemory.Desc": "Journaliser les allocations de mémoire directe et les échecs dans la console.\nÀ utiliser quand un jeu plante ou se ferme pendant le démarrage.",
|
"Options.Env.LogDirectMemory.Desc": "Journaliser les allocations de mémoire directe et les échecs dans la console.\nÀ utiliser quand un jeu plante ou se ferme pendant le démarrage.",
|
||||||
"Options.Env.LogNp.Desc": "Journaliser les appels de la bibliothèque NP (PlayStation Network) dans la console.",
|
"Options.Env.LogNp.Desc": "Journaliser les appels de la bibliothèque NP (PlayStation Network) dans la console.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Recharger les surfaces invité que le code CPU du jeu réécrit lui-même.\nLaisser désactivé normalement. Activer pour les titres dont les surfaces dessinées par le CPU n'atteignent jamais l'écran.\nCoûte des performances et provoque des régressions sur certains titres, comme GTA V.",
|
||||||
"Options.Section.Emulation": "ÉMULATION",
|
"Options.Section.Emulation": "ÉMULATION",
|
||||||
"Options.Section.Logging": "JOURNALISATION",
|
"Options.Section.Logging": "JOURNALISATION",
|
||||||
"Options.Section.Launcher": "LANCEUR",
|
"Options.Section.Launcher": "LANCEUR",
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Rejoignez la communauté, obtenez de l’aide et suivez le développement.",
|
"About.Discord.Desc": "Rejoignez la communauté, obtenez de l’aide et suivez le développement.",
|
||||||
"About.GithubButton": "Contribuer sur GitHub !",
|
"About.GithubButton": "Contribuer sur GitHub !",
|
||||||
"About.DiscordButton": "Rejoindre notre Discord !",
|
"About.DiscordComingSoon": "Bientôt disponible",
|
||||||
|
|
||||||
"Library.Context.GameSettings": "Paramètres du jeu…",
|
"Library.Context.GameSettings": "Paramètres du jeu…",
|
||||||
"Options.Env.WritableApp0.Desc": "Autoriser les jeux à créer et écrire des fichiers dans leur dossier d’installation.\nNécessaire pour les dumps non empaquetés qui écrivent leurs sauvegardes ou leur configuration sous /app0.",
|
"Options.Env.WritableApp0.Desc": "Autoriser les jeux à créer et écrire des fichiers dans leur dossier d’installation.\nNécessaire pour les dumps non empaquetés qui écrivent leurs sauvegardes ou leur configuration sous /app0.",
|
||||||
@@ -169,5 +169,34 @@
|
|||||||
"Updater.Status.Timeout": "La vérification des mises à jour a expiré après 10 secondes.",
|
"Updater.Status.Timeout": "La vérification des mises à jour a expiré après 10 secondes.",
|
||||||
"Updater.Status.Failed": "Impossible de vérifier les mises à jour.",
|
"Updater.Status.Failed": "Impossible de vérifier les mises à jour.",
|
||||||
"Updater.Status.ChecksumFailed": "La mise à jour téléchargée a échoué à la vérification SHA-256.",
|
"Updater.Status.ChecksumFailed": "La mise à jour téléchargée a échoué à la vérification SHA-256.",
|
||||||
"Updater.Status.Unsupported": "La mise à jour automatique nécessite un build x64 pour Windows, Linux ou macOS."
|
"Updater.Status.Unsupported": "La mise à jour automatique nécessite un build x64 pour Windows, Linux ou macOS.",
|
||||||
|
"Options.Graphics": "Graphismes",
|
||||||
|
"Options.Section.Rendering": "RENDU",
|
||||||
|
"Options.Section.Display": "AFFICHAGE",
|
||||||
|
"Options.RenderResolution.Label": "Résolution interne",
|
||||||
|
"Options.RenderResolution.Desc": "Effectuer le rendu des cibles hors écran sous la résolution native et les mettre à l’échelle lors de l’affichage. Les valeurs inférieures réduisent la qualité d’image pour libérer des ressources GPU ; prend effet au prochain lancement.",
|
||||||
|
"Options.RenderResolution.Native": "100 % (native)",
|
||||||
|
"Options.WindowMode.Label": "Mode fenêtre",
|
||||||
|
"Options.WindowMode.Desc": "Fenêtre standard, bureau sans bordures ou plein écran exclusif.",
|
||||||
|
"Options.WindowMode.Windowed": "Fenêtré",
|
||||||
|
"Options.WindowMode.Borderless": "Sans bordures",
|
||||||
|
"Options.WindowMode.Exclusive": "Exclusif",
|
||||||
|
"Options.Resolution.Label": "Résolution",
|
||||||
|
"Options.Resolution.Desc": "Taille initiale de la fenêtre ou résolution du plein écran exclusif.",
|
||||||
|
"Options.Display.Label": "Écran",
|
||||||
|
"Options.Display.Desc": "Moniteur utilisé pour le centrage et le plein écran.",
|
||||||
|
"Options.RefreshRate.Label": "Fréquence de rafraîchissement",
|
||||||
|
"Options.RefreshRate.Desc": "Fréquence de rafraîchissement du plein écran exclusif. Le mode automatique sélectionne le mode le plus proche.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatique",
|
||||||
|
"Options.Scaling.Label": "Mise à l’échelle",
|
||||||
|
"Options.Scaling.Desc": "Mettre à l’échelle l’image native du système invité sans modifier sa résolution interne.",
|
||||||
|
"Options.Scaling.Fit": "Ajuster",
|
||||||
|
"Options.Scaling.Cover": "Remplir",
|
||||||
|
"Options.Scaling.Stretch": "Étirer",
|
||||||
|
"Options.Scaling.Integer": "Entier",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Utiliser la présentation FIFO pour un affichage sans déchirement.",
|
||||||
|
"Options.Hdr.Label": "Sortie HDR",
|
||||||
|
"Options.Hdr.Desc": "Utiliser le HDR lorsque l’écran sélectionné et le backend graphique le prennent en charge. Le mode automatique revient au SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automatique"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Keresés a könyvtárban",
|
"Library.SearchWatermark": "Keresés a könyvtárban",
|
||||||
"Library.AddFolder": "+ Mappa hozzáadása",
|
"Library.AddFolder": "+ Mappa hozzáadása",
|
||||||
"Library.Rescan": "⟳ Újrakeresés",
|
|
||||||
"Library.OpenFile": "Fájl megnyitása…",
|
"Library.OpenFile": "Fájl megnyitása…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Inditás",
|
"Library.Context.Launch": "Inditás",
|
||||||
@@ -35,6 +34,7 @@
|
|||||||
"Options.Env.DumpSpirv.Desc": "Az AGC-shaderek és azok SPIR-V-fordításainak mentése a shader-dumps mappába.\nHasználd shader- vagy renderelési hibák jelentésekor.",
|
"Options.Env.DumpSpirv.Desc": "Az AGC-shaderek és azok SPIR-V-fordításainak mentése a shader-dumps mappába.\nHasználd shader- vagy renderelési hibák jelentésekor.",
|
||||||
"Options.Env.LogDirectMemory.Desc": "A közvetlen memóriaallokációk és hibák naplózása a konzolra.\nHasználd, ha egy játék a rendszerindítás során megszakad vagy kilép.",
|
"Options.Env.LogDirectMemory.Desc": "A közvetlen memóriaallokációk és hibák naplózása a konzolra.\nHasználd, ha egy játék a rendszerindítás során megszakad vagy kilép.",
|
||||||
"Options.Env.LogNp.Desc": "Az NP (PlayStation Network) könyvtárhívásokat naplózza a konzolra.",
|
"Options.Env.LogNp.Desc": "Az NP (PlayStation Network) könyvtárhívásokat naplózza a konzolra.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Újratölti azokat a vendégfelületeket, amelyeket a játék saját CPU-kódja ír felül.\nNormál esetben hagyd kikapcsolva. Kapcsold be azoknál a címeknél, amelyek CPU-val rajzolt felületei sosem jutnak ki a képernyőre.\nTeljesítménybe kerül, és egyes címeknél, például a GTA V-nél regressziót okoz.",
|
||||||
"Options.Section.Emulation": "EMULÁCIÓ",
|
"Options.Section.Emulation": "EMULÁCIÓ",
|
||||||
"Options.Section.Logging": "LOGOLÁS",
|
"Options.Section.Logging": "LOGOLÁS",
|
||||||
"Options.Section.Launcher": "INDITÓ",
|
"Options.Section.Launcher": "INDITÓ",
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Csatlakozz a közösséghe, kérj segítéget és kövesd nyomon a fejlesztést.",
|
"About.Discord.Desc": "Csatlakozz a közösséghe, kérj segítéget és kövesd nyomon a fejlesztést.",
|
||||||
"About.GithubButton": "Járulj hozzá GitHubon!",
|
"About.GithubButton": "Járulj hozzá GitHubon!",
|
||||||
"About.DiscordButton": "Csatlakozz a Discordunhoz!",
|
"About.DiscordComingSoon": "Hamarosan",
|
||||||
|
|
||||||
"Library.Context.GameSettings": "Játékbeállítások…",
|
"Library.Context.GameSettings": "Játékbeállítások…",
|
||||||
"Options.Env.WritableApp0.Desc": "Engedélyezi, hogy a játékok fájlokat hozzanak létre és írjanak a telepítési mappájukban.\nA kicsomagolt dumpokhoz szükséges, amelyek a mentéseiket vagy beállításaikat az /app0 alá írják.",
|
"Options.Env.WritableApp0.Desc": "Engedélyezi, hogy a játékok fájlokat hozzanak létre és írjanak a telepítési mappájukban.\nA kicsomagolt dumpokhoz szükséges, amelyek a mentéseiket vagy beállításaikat az /app0 alá írják.",
|
||||||
@@ -169,5 +169,34 @@
|
|||||||
"Updater.Status.Timeout": "A frissítés-ellenőrzés 10 másodperc után túllépte az időkorlátot.",
|
"Updater.Status.Timeout": "A frissítés-ellenőrzés 10 másodperc után túllépte az időkorlátot.",
|
||||||
"Updater.Status.Failed": "Nem sikerült frissítéseket keresni.",
|
"Updater.Status.Failed": "Nem sikerült frissítéseket keresni.",
|
||||||
"Updater.Status.ChecksumFailed": "A letöltött frissítés nem ment át az SHA-256-ellenőrzésen.",
|
"Updater.Status.ChecksumFailed": "A letöltött frissítés nem ment át az SHA-256-ellenőrzésen.",
|
||||||
"Updater.Status.Unsupported": "Az automatikus frissítéshez Windows, Linux vagy macOS x64 build szükséges."
|
"Updater.Status.Unsupported": "Az automatikus frissítéshez Windows, Linux vagy macOS x64 build szükséges.",
|
||||||
|
"Options.Graphics": "Grafika",
|
||||||
|
"Options.Section.Rendering": "RENDERELÉS",
|
||||||
|
"Options.Section.Display": "KIJELZŐ",
|
||||||
|
"Options.RenderResolution.Label": "Belső felbontás",
|
||||||
|
"Options.RenderResolution.Desc": "A képernyőn kívüli célok renderelése a natívnál kisebb felbontáson, majd felskálázás megjelenítéskor. Az alacsonyabb értékek képminőséget cserélnek GPU-tartalékra; a következő indításkor lép érvénybe.",
|
||||||
|
"Options.RenderResolution.Native": "100% (natív)",
|
||||||
|
"Options.WindowMode.Label": "Ablakmód",
|
||||||
|
"Options.WindowMode.Desc": "Normál ablak, keret nélküli asztal vagy kizárólagos teljes képernyő.",
|
||||||
|
"Options.WindowMode.Windowed": "Ablakos",
|
||||||
|
"Options.WindowMode.Borderless": "Keret nélküli",
|
||||||
|
"Options.WindowMode.Exclusive": "Kizárólagos",
|
||||||
|
"Options.Resolution.Label": "Felbontás",
|
||||||
|
"Options.Resolution.Desc": "Kezdeti ablakméret vagy kizárólagos teljes képernyős felbontás.",
|
||||||
|
"Options.Display.Label": "Kijelző",
|
||||||
|
"Options.Display.Desc": "A középre igazításhoz és teljes képernyőhöz használt monitor.",
|
||||||
|
"Options.RefreshRate.Label": "Frissítési gyakoriság",
|
||||||
|
"Options.RefreshRate.Desc": "A kizárólagos teljes képernyő frissítési gyakorisága. Az automatikus mód a legközelebbi módot választja.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatikus",
|
||||||
|
"Options.Scaling.Label": "Méretezés",
|
||||||
|
"Options.Scaling.Desc": "A natív vendégkép méretezése a belső felbontás módosítása nélkül.",
|
||||||
|
"Options.Scaling.Fit": "Illesztés",
|
||||||
|
"Options.Scaling.Cover": "Kitöltés",
|
||||||
|
"Options.Scaling.Stretch": "Nyújtás",
|
||||||
|
"Options.Scaling.Integer": "Egész szám",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "FIFO megjelenítés használata képtörésmentes kimenethez.",
|
||||||
|
"Options.Hdr.Label": "HDR-kimenet",
|
||||||
|
"Options.Hdr.Desc": "HDR használata, ha a kiválasztott kijelző és grafikus backend támogatja. Az automatikus mód SDR-re vált vissza.",
|
||||||
|
"Options.Hdr.Auto": "Automatikus"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Cerca nella libreria…",
|
"Library.SearchWatermark": "Cerca nella libreria…",
|
||||||
"Library.AddFolder": "+ Aggiungi cartella",
|
"Library.AddFolder": "+ Aggiungi cartella",
|
||||||
"Library.Rescan": "⟳ Riscansiona",
|
|
||||||
"Library.OpenFile": "Apri file…",
|
"Library.OpenFile": "Apri file…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Avvia",
|
"Library.Context.Launch": "Avvia",
|
||||||
@@ -144,6 +143,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Registra in console le allocazioni di memoria diretta e i relativi errori.\nUsalo quando un gioco si interrompe o si chiude durante l'avvio.",
|
"Options.Env.LogDirectMemory.Desc": "Registra in console le allocazioni di memoria diretta e i relativi errori.\nUsalo quando un gioco si interrompe o si chiude durante l'avvio.",
|
||||||
"Options.Env.LogIo.Desc": "Registra in console l'apertura e la lettura dei file e la risoluzione dei percorsi.\nUsalo quando un gioco non trova i propri file di dati durante l'avvio.",
|
"Options.Env.LogIo.Desc": "Registra in console l'apertura e la lettura dei file e la risoluzione dei percorsi.\nUsalo quando un gioco non trova i propri file di dati durante l'avvio.",
|
||||||
"Options.Env.LogNp.Desc": "Registra in console le chiamate alla libreria NP (PlayStation Network).",
|
"Options.Env.LogNp.Desc": "Registra in console le chiamate alla libreria NP (PlayStation Network).",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Ricarica le superfici guest riscritte dal codice CPU del gioco.\nLasciare disattivato normalmente. Attivare per i titoli le cui superfici disegnate dalla CPU non raggiungono mai lo schermo.\nCosta prestazioni e causa regressioni in alcuni titoli, come GTA V.",
|
||||||
"Common.Save": "Salva",
|
"Common.Save": "Salva",
|
||||||
"Common.Cancel": "Annulla",
|
"Common.Cancel": "Annulla",
|
||||||
"PerGame.Title": "Impostazioni per gioco — {0} ({1})",
|
"PerGame.Title": "Impostazioni per gioco — {0} ({1})",
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Unisciti alla community, ricevi supporto e segui lo sviluppo.",
|
"About.Discord.Desc": "Unisciti alla community, ricevi supporto e segui lo sviluppo.",
|
||||||
"About.GithubButton": "Contribuisci su GitHub!",
|
"About.GithubButton": "Contribuisci su GitHub!",
|
||||||
"About.DiscordButton": "Unisciti al nostro Discord!",
|
"About.DiscordComingSoon": "Prossimamente",
|
||||||
"Updater.Auto.Label": "Controlla aggiornamenti all'avvio",
|
"Updater.Auto.Label": "Controlla aggiornamenti all'avvio",
|
||||||
"Updater.Auto.Desc": "Interroga GitHub senza rallentare l'avvio.",
|
"Updater.Auto.Desc": "Interroga GitHub senza rallentare l'avvio.",
|
||||||
"Updater.Label": "Aggiornamenti",
|
"Updater.Label": "Aggiornamenti",
|
||||||
@@ -173,5 +173,34 @@
|
|||||||
"Updater.Status.Timeout": "Il controllo degli aggiornamenti è scaduto dopo 10 secondi.",
|
"Updater.Status.Timeout": "Il controllo degli aggiornamenti è scaduto dopo 10 secondi.",
|
||||||
"Updater.Status.Failed": "Impossibile controllare gli aggiornamenti.",
|
"Updater.Status.Failed": "Impossibile controllare gli aggiornamenti.",
|
||||||
"Updater.Status.ChecksumFailed": "L'aggiornamento scaricato non ha superato la verifica SHA-256.",
|
"Updater.Status.ChecksumFailed": "L'aggiornamento scaricato non ha superato la verifica SHA-256.",
|
||||||
"Updater.Status.Unsupported": "L'aggiornamento automatico richiede un build x64 per Windows, Linux o macOS."
|
"Updater.Status.Unsupported": "L'aggiornamento automatico richiede un build x64 per Windows, Linux o macOS.",
|
||||||
|
"Options.Graphics": "Grafica",
|
||||||
|
"Options.Section.Rendering": "RENDERING",
|
||||||
|
"Options.Section.Display": "SCHERMO",
|
||||||
|
"Options.RenderResolution.Label": "Risoluzione interna",
|
||||||
|
"Options.RenderResolution.Desc": "Renderizza i target fuori schermo sotto la risoluzione nativa e li ridimensiona in fase di presentazione. Valori inferiori sacrificano la qualità dell'immagine per lasciare margine alla GPU; ha effetto al prossimo avvio.",
|
||||||
|
"Options.RenderResolution.Native": "100% (nativa)",
|
||||||
|
"Options.WindowMode.Label": "Modalità finestra",
|
||||||
|
"Options.WindowMode.Desc": "Finestra normale, desktop senza bordi o schermo intero esclusivo.",
|
||||||
|
"Options.WindowMode.Windowed": "In finestra",
|
||||||
|
"Options.WindowMode.Borderless": "Senza bordi",
|
||||||
|
"Options.WindowMode.Exclusive": "Esclusiva",
|
||||||
|
"Options.Resolution.Label": "Risoluzione",
|
||||||
|
"Options.Resolution.Desc": "Dimensione iniziale della finestra o risoluzione dello schermo intero esclusivo.",
|
||||||
|
"Options.Display.Label": "Schermo",
|
||||||
|
"Options.Display.Desc": "Monitor utilizzato per il centraggio e lo schermo intero.",
|
||||||
|
"Options.RefreshRate.Label": "Frequenza di aggiornamento",
|
||||||
|
"Options.RefreshRate.Desc": "Frequenza di aggiornamento dello schermo intero esclusivo. La modalità automatica seleziona la modalità più vicina.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatica",
|
||||||
|
"Options.Scaling.Label": "Ridimensionamento",
|
||||||
|
"Options.Scaling.Desc": "Ridimensiona l'immagine nativa del sistema guest senza modificarne la risoluzione interna.",
|
||||||
|
"Options.Scaling.Fit": "Adatta",
|
||||||
|
"Options.Scaling.Cover": "Riempi",
|
||||||
|
"Options.Scaling.Stretch": "Estendi",
|
||||||
|
"Options.Scaling.Integer": "Intero",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Usa la presentazione FIFO per evitare lo screen tearing.",
|
||||||
|
"Options.Hdr.Label": "Output HDR",
|
||||||
|
"Options.Hdr.Desc": "Usa HDR quando lo schermo selezionato e il backend grafico lo supportano. La modalità automatica torna a SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automatico"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "ライブラリを検索…",
|
"Library.SearchWatermark": "ライブラリを検索…",
|
||||||
"Library.AddFolder": "+ フォルダーを追加",
|
"Library.AddFolder": "+ フォルダーを追加",
|
||||||
"Library.Rescan": "⟳ 再スキャン",
|
|
||||||
"Library.OpenFile": "ファイルを開く…",
|
"Library.OpenFile": "ファイルを開く…",
|
||||||
|
|
||||||
"Library.Context.Launch": "起動",
|
"Library.Context.Launch": "起動",
|
||||||
@@ -139,6 +138,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "ダイレクトメモリの割り当てと失敗をコンソールに記録します。\nゲームが起動中に中断・終了する場合に使用してください。",
|
"Options.Env.LogDirectMemory.Desc": "ダイレクトメモリの割り当てと失敗をコンソールに記録します。\nゲームが起動中に中断・終了する場合に使用してください。",
|
||||||
"Options.Env.LogIo.Desc": "ファイルのオープン・読み込み・パス解決の動作をコンソールに記録します。\nゲームが起動中にデータファイルを見つけられない場合に使用してください。",
|
"Options.Env.LogIo.Desc": "ファイルのオープン・読み込み・パス解決の動作をコンソールに記録します。\nゲームが起動中にデータファイルを見つけられない場合に使用してください。",
|
||||||
"Options.Env.LogNp.Desc": "NP(PlayStation Network)ライブラリの呼び出しをコンソールに記録します。",
|
"Options.Env.LogNp.Desc": "NP(PlayStation Network)ライブラリの呼び出しをコンソールに記録します。",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "ゲーム自身の CPU コードが書き換えるゲスト表面を再アップロードします。\n通常はオフのままにしてください。CPU で描画した表面が画面に反映されないタイトルで有効にします。\n性能を犠牲にし、GTA V など一部のタイトルでは不具合が生じます。",
|
||||||
"Common.Save": "保存",
|
"Common.Save": "保存",
|
||||||
"Common.Cancel": "キャンセル",
|
"Common.Cancel": "キャンセル",
|
||||||
"PerGame.Title": "ゲームごとの設定 — {0} ({1})",
|
"PerGame.Title": "ゲームごとの設定 — {0} ({1})",
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "コミュニティに参加して、サポートを受けたり開発を追いかけたりしましょう。",
|
"About.Discord.Desc": "コミュニティに参加して、サポートを受けたり開発を追いかけたりしましょう。",
|
||||||
"About.GithubButton": "GitHubで貢献しよう!",
|
"About.GithubButton": "GitHubで貢献しよう!",
|
||||||
"About.DiscordButton": "Discordに参加しよう!",
|
"About.DiscordComingSoon": "近日公開",
|
||||||
"Updater.Auto.Label": "起動時にアップデートを確認",
|
"Updater.Auto.Label": "起動時にアップデートを確認",
|
||||||
"Updater.Auto.Desc": "起動を遅らせずにGitHubへ確認します。",
|
"Updater.Auto.Desc": "起動を遅らせずにGitHubへ確認します。",
|
||||||
"Updater.Label": "アップデート",
|
"Updater.Label": "アップデート",
|
||||||
@@ -168,5 +168,34 @@
|
|||||||
"Updater.Status.Timeout": "アップデートの確認が10秒でタイムアウトしました。",
|
"Updater.Status.Timeout": "アップデートの確認が10秒でタイムアウトしました。",
|
||||||
"Updater.Status.Failed": "アップデートを確認できませんでした。",
|
"Updater.Status.Failed": "アップデートを確認できませんでした。",
|
||||||
"Updater.Status.ChecksumFailed": "ダウンロードしたアップデートはSHA-256検証に失敗しました。",
|
"Updater.Status.ChecksumFailed": "ダウンロードしたアップデートはSHA-256検証に失敗しました。",
|
||||||
"Updater.Status.Unsupported": "自動アップデートにはWindows、Linux、またはmacOSのx64ビルドが必要です。"
|
"Updater.Status.Unsupported": "自動アップデートにはWindows、Linux、またはmacOSのx64ビルドが必要です。",
|
||||||
|
"Options.Graphics": "グラフィックス",
|
||||||
|
"Options.Section.Rendering": "レンダリング",
|
||||||
|
"Options.Section.Display": "ディスプレイ",
|
||||||
|
"Options.RenderResolution.Label": "内部解像度",
|
||||||
|
"Options.RenderResolution.Desc": "ネイティブ解像度より低い解像度でオフスクリーンターゲットを描画し、表示時にアップスケールします。値を下げると画質と引き換えにGPU負荷を軽減します。次回起動時に適用されます。",
|
||||||
|
"Options.RenderResolution.Native": "100%(ネイティブ)",
|
||||||
|
"Options.WindowMode.Label": "ウィンドウモード",
|
||||||
|
"Options.WindowMode.Desc": "通常ウィンドウ、デスクトップのボーダーレス、または排他フルスクリーン。",
|
||||||
|
"Options.WindowMode.Windowed": "ウィンドウ",
|
||||||
|
"Options.WindowMode.Borderless": "ボーダーレス",
|
||||||
|
"Options.WindowMode.Exclusive": "排他",
|
||||||
|
"Options.Resolution.Label": "解像度",
|
||||||
|
"Options.Resolution.Desc": "初期ウィンドウサイズまたは排他フルスクリーンの解像度。",
|
||||||
|
"Options.Display.Label": "ディスプレイ",
|
||||||
|
"Options.Display.Desc": "中央配置とフルスクリーンに使用するモニター。",
|
||||||
|
"Options.RefreshRate.Label": "リフレッシュレート",
|
||||||
|
"Options.RefreshRate.Desc": "排他フルスクリーンのリフレッシュレート。自動では最も近いモードを選択します。",
|
||||||
|
"Options.RefreshRate.Automatic": "自動",
|
||||||
|
"Options.Scaling.Label": "スケーリング",
|
||||||
|
"Options.Scaling.Desc": "内部解像度を変更せずにゲストのネイティブ画像を拡大縮小します。",
|
||||||
|
"Options.Scaling.Fit": "フィット",
|
||||||
|
"Options.Scaling.Cover": "カバー",
|
||||||
|
"Options.Scaling.Stretch": "引き伸ばし",
|
||||||
|
"Options.Scaling.Integer": "整数倍",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "ティアリングのない表示のためFIFOプレゼンテーションを使用します。",
|
||||||
|
"Options.Hdr.Label": "HDR出力",
|
||||||
|
"Options.Hdr.Desc": "選択したディスプレイとグラフィックスバックエンドが対応している場合にHDRを使用します。自動ではSDRにフォールバックします。",
|
||||||
|
"Options.Hdr.Auto": "自動"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "라이브러리 검색…",
|
"Library.SearchWatermark": "라이브러리 검색…",
|
||||||
"Library.AddFolder": "+ 폴더 추가",
|
"Library.AddFolder": "+ 폴더 추가",
|
||||||
"Library.Rescan": "⟳ 다시 스캔",
|
|
||||||
"Library.OpenFile": "파일 열기…",
|
"Library.OpenFile": "파일 열기…",
|
||||||
|
|
||||||
"Library.Context.Launch": "실행",
|
"Library.Context.Launch": "실행",
|
||||||
@@ -139,6 +138,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "다이렉트 메모리 할당과 실패를 콘솔에 기록합니다.\n게임이 부팅 중 중단되거나 종료될 때 사용하세요.",
|
"Options.Env.LogDirectMemory.Desc": "다이렉트 메모리 할당과 실패를 콘솔에 기록합니다.\n게임이 부팅 중 중단되거나 종료될 때 사용하세요.",
|
||||||
"Options.Env.LogIo.Desc": "파일 열기, 읽기, 경로 확인 동작을 콘솔에 기록합니다.\n게임이 부팅 중 데이터 파일을 찾지 못할 때 사용하세요.",
|
"Options.Env.LogIo.Desc": "파일 열기, 읽기, 경로 확인 동작을 콘솔에 기록합니다.\n게임이 부팅 중 데이터 파일을 찾지 못할 때 사용하세요.",
|
||||||
"Options.Env.LogNp.Desc": "NP(PlayStation Network) 라이브러리 호출을 콘솔에 기록합니다.",
|
"Options.Env.LogNp.Desc": "NP(PlayStation Network) 라이브러리 호출을 콘솔에 기록합니다.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "게임의 자체 CPU 코드가 다시 쓰는 게스트 표면을 다시 업로드합니다.\n평소에는 꺼 두세요. CPU로 그린 표면이 화면에 나타나지 않는 타이틀에서 켜세요.\n성능을 소모하며 GTA V 등 일부 타이틀에서는 문제가 생깁니다.",
|
||||||
"Common.Save": "저장",
|
"Common.Save": "저장",
|
||||||
"Common.Cancel": "취소",
|
"Common.Cancel": "취소",
|
||||||
"PerGame.Title": "게임별 설정 — {0} ({1})",
|
"PerGame.Title": "게임별 설정 — {0} ({1})",
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
"About.Discord.Label": "디스코드",
|
"About.Discord.Label": "디스코드",
|
||||||
"About.Discord.Desc": "커뮤니티에 참여해 지원을 받고 개발 소식을 확인하세요.",
|
"About.Discord.Desc": "커뮤니티에 참여해 지원을 받고 개발 소식을 확인하세요.",
|
||||||
"About.GithubButton": "GitHub에서 기여하기!",
|
"About.GithubButton": "GitHub에서 기여하기!",
|
||||||
"About.DiscordButton": "디스코드 참여하기!",
|
"About.DiscordComingSoon": "곧 공개",
|
||||||
"Updater.Auto.Label": "시작 시 업데이트 확인",
|
"Updater.Auto.Label": "시작 시 업데이트 확인",
|
||||||
"Updater.Auto.Desc": "시작을 지연시키지 않고 GitHub를 확인합니다.",
|
"Updater.Auto.Desc": "시작을 지연시키지 않고 GitHub를 확인합니다.",
|
||||||
"Updater.Label": "업데이트",
|
"Updater.Label": "업데이트",
|
||||||
@@ -168,5 +168,34 @@
|
|||||||
"Updater.Status.Timeout": "업데이트 확인이 10초 후 시간 초과되었습니다.",
|
"Updater.Status.Timeout": "업데이트 확인이 10초 후 시간 초과되었습니다.",
|
||||||
"Updater.Status.Failed": "업데이트를 확인할 수 없습니다.",
|
"Updater.Status.Failed": "업데이트를 확인할 수 없습니다.",
|
||||||
"Updater.Status.ChecksumFailed": "다운로드한 업데이트가 SHA-256 검증에 실패했습니다.",
|
"Updater.Status.ChecksumFailed": "다운로드한 업데이트가 SHA-256 검증에 실패했습니다.",
|
||||||
"Updater.Status.Unsupported": "자동 업데이트에는 Windows, Linux 또는 macOS x64 빌드가 필요합니다."
|
"Updater.Status.Unsupported": "자동 업데이트에는 Windows, Linux 또는 macOS x64 빌드가 필요합니다.",
|
||||||
|
"Options.Graphics": "그래픽",
|
||||||
|
"Options.Section.Rendering": "렌더링",
|
||||||
|
"Options.Section.Display": "디스플레이",
|
||||||
|
"Options.RenderResolution.Label": "내부 해상도",
|
||||||
|
"Options.RenderResolution.Desc": "네이티브 해상도보다 낮은 해상도로 오프스크린 대상을 렌더링한 뒤 표시할 때 업스케일합니다. 값이 낮을수록 화질을 희생해 GPU 여유를 확보하며 다음 실행부터 적용됩니다.",
|
||||||
|
"Options.RenderResolution.Native": "100% (네이티브)",
|
||||||
|
"Options.WindowMode.Label": "창 모드",
|
||||||
|
"Options.WindowMode.Desc": "일반 창, 데스크톱 테두리 없음 또는 독점 전체 화면.",
|
||||||
|
"Options.WindowMode.Windowed": "창",
|
||||||
|
"Options.WindowMode.Borderless": "테두리 없음",
|
||||||
|
"Options.WindowMode.Exclusive": "독점",
|
||||||
|
"Options.Resolution.Label": "해상도",
|
||||||
|
"Options.Resolution.Desc": "초기 창 크기 또는 독점 전체 화면 해상도.",
|
||||||
|
"Options.Display.Label": "디스플레이",
|
||||||
|
"Options.Display.Desc": "가운데 배치와 전체 화면에 사용할 모니터.",
|
||||||
|
"Options.RefreshRate.Label": "새로 고침 빈도",
|
||||||
|
"Options.RefreshRate.Desc": "독점 전체 화면의 새로 고침 빈도입니다. 자동은 가장 가까운 모드를 선택합니다.",
|
||||||
|
"Options.RefreshRate.Automatic": "자동",
|
||||||
|
"Options.Scaling.Label": "스케일링",
|
||||||
|
"Options.Scaling.Desc": "내부 해상도를 변경하지 않고 게스트의 네이티브 이미지를 확대 또는 축소합니다.",
|
||||||
|
"Options.Scaling.Fit": "맞춤",
|
||||||
|
"Options.Scaling.Cover": "채우기",
|
||||||
|
"Options.Scaling.Stretch": "늘이기",
|
||||||
|
"Options.Scaling.Integer": "정수배",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "티어링 없는 출력을 위해 FIFO 프레젠테이션을 사용합니다.",
|
||||||
|
"Options.Hdr.Label": "HDR 출력",
|
||||||
|
"Options.Hdr.Desc": "선택한 디스플레이와 그래픽 백엔드가 지원하는 경우 HDR을 사용합니다. 자동 모드는 SDR로 대체됩니다.",
|
||||||
|
"Options.Hdr.Auto": "자동"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Zoeken in bibliotheek…",
|
"Library.SearchWatermark": "Zoeken in bibliotheek…",
|
||||||
"Library.AddFolder": "+ Map toevoegen",
|
"Library.AddFolder": "+ Map toevoegen",
|
||||||
"Library.Rescan": "⟳ Opnieuw scannen",
|
|
||||||
"Library.OpenFile": "Bestand openen…",
|
"Library.OpenFile": "Bestand openen…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Starten",
|
"Library.Context.Launch": "Starten",
|
||||||
@@ -139,6 +138,7 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Log directe geheugentoewijzingen en fouten naar de console.\nGebruik dit wanneer een game tijdens het opstarten afbreekt of afsluit.",
|
"Options.Env.LogDirectMemory.Desc": "Log directe geheugentoewijzingen en fouten naar de console.\nGebruik dit wanneer een game tijdens het opstarten afbreekt of afsluit.",
|
||||||
"Options.Env.LogIo.Desc": "Log het openen en lezen van bestanden en het oplossen van paden naar de console.\nGebruik dit wanneer een game zijn databestanden niet kan vinden tijdens het opstarten.",
|
"Options.Env.LogIo.Desc": "Log het openen en lezen van bestanden en het oplossen van paden naar de console.\nGebruik dit wanneer een game zijn databestanden niet kan vinden tijdens het opstarten.",
|
||||||
"Options.Env.LogNp.Desc": "Log NP-bibliotheekaanroepen (PlayStation Network) naar de console.",
|
"Options.Env.LogNp.Desc": "Log NP-bibliotheekaanroepen (PlayStation Network) naar de console.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Gastoppervlakken opnieuw uploaden die de eigen CPU-code van de game herschrijft.\nNormaal uit laten. Inschakelen voor titels waarvan de door de CPU getekende oppervlakken nooit het scherm bereiken.\nKost prestaties en veroorzaakt regressies in sommige titels, zoals GTA V.",
|
||||||
"Common.Save": "Opslaan",
|
"Common.Save": "Opslaan",
|
||||||
"Common.Cancel": "Annuleren",
|
"Common.Cancel": "Annuleren",
|
||||||
"PerGame.Title": "Instellingen per game — {0} ({1})",
|
"PerGame.Title": "Instellingen per game — {0} ({1})",
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Word lid van de community, krijg ondersteuning en volg de ontwikkeling.",
|
"About.Discord.Desc": "Word lid van de community, krijg ondersteuning en volg de ontwikkeling.",
|
||||||
"About.GithubButton": "Draag bij op GitHub!",
|
"About.GithubButton": "Draag bij op GitHub!",
|
||||||
"About.DiscordButton": "Word lid van onze Discord!",
|
"About.DiscordComingSoon": "Binnenkort",
|
||||||
"Updater.Auto.Label": "Bij het opstarten controleren op updates",
|
"Updater.Auto.Label": "Bij het opstarten controleren op updates",
|
||||||
"Updater.Auto.Desc": "Controleert GitHub zonder het opstarten te vertragen.",
|
"Updater.Auto.Desc": "Controleert GitHub zonder het opstarten te vertragen.",
|
||||||
"Updater.Label": "Updates",
|
"Updater.Label": "Updates",
|
||||||
@@ -168,5 +168,34 @@
|
|||||||
"Updater.Status.Timeout": "De updatecontrole is na 10 seconden verlopen.",
|
"Updater.Status.Timeout": "De updatecontrole is na 10 seconden verlopen.",
|
||||||
"Updater.Status.Failed": "Kon niet controleren op updates.",
|
"Updater.Status.Failed": "Kon niet controleren op updates.",
|
||||||
"Updater.Status.ChecksumFailed": "De gedownloade update is niet door de SHA-256-verificatie gekomen.",
|
"Updater.Status.ChecksumFailed": "De gedownloade update is niet door de SHA-256-verificatie gekomen.",
|
||||||
"Updater.Status.Unsupported": "Automatisch updaten vereist een x64-build voor Windows, Linux of macOS."
|
"Updater.Status.Unsupported": "Automatisch updaten vereist een x64-build voor Windows, Linux of macOS.",
|
||||||
|
"Options.Graphics": "Grafisch",
|
||||||
|
"Options.Section.Rendering": "RENDERING",
|
||||||
|
"Options.Section.Display": "BEELDSCHERM",
|
||||||
|
"Options.RenderResolution.Label": "Interne resolutie",
|
||||||
|
"Options.RenderResolution.Desc": "Render offscreen-doelen onder de oorspronkelijke resolutie en schaal ze bij presentatie op. Lagere waarden ruilen beeldkwaliteit in voor GPU-marge; wordt bij de volgende start toegepast.",
|
||||||
|
"Options.RenderResolution.Native": "100% (native)",
|
||||||
|
"Options.WindowMode.Label": "Venstermodus",
|
||||||
|
"Options.WindowMode.Desc": "Normaal venster, randloos bureaublad of exclusief volledig scherm.",
|
||||||
|
"Options.WindowMode.Windowed": "Venster",
|
||||||
|
"Options.WindowMode.Borderless": "Randloos",
|
||||||
|
"Options.WindowMode.Exclusive": "Exclusief",
|
||||||
|
"Options.Resolution.Label": "Resolutie",
|
||||||
|
"Options.Resolution.Desc": "Initiële venstergrootte of resolutie voor exclusief volledig scherm.",
|
||||||
|
"Options.Display.Label": "Beeldscherm",
|
||||||
|
"Options.Display.Desc": "Monitor die wordt gebruikt voor centrering en volledig scherm.",
|
||||||
|
"Options.RefreshRate.Label": "Verversingssnelheid",
|
||||||
|
"Options.RefreshRate.Desc": "Verversingssnelheid voor exclusief volledig scherm. Automatisch selecteert de dichtstbijzijnde modus.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automatisch",
|
||||||
|
"Options.Scaling.Label": "Schaling",
|
||||||
|
"Options.Scaling.Desc": "Schaal de oorspronkelijke gastafbeelding zonder de interne resolutie te wijzigen.",
|
||||||
|
"Options.Scaling.Fit": "Passend",
|
||||||
|
"Options.Scaling.Cover": "Vullend",
|
||||||
|
"Options.Scaling.Stretch": "Uitrekken",
|
||||||
|
"Options.Scaling.Integer": "Geheel getal",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Gebruik FIFO-presentatie voor uitvoer zonder tearing.",
|
||||||
|
"Options.Hdr.Label": "HDR-uitvoer",
|
||||||
|
"Options.Hdr.Desc": "Gebruik HDR wanneer het geselecteerde beeldscherm en de grafische backend dit ondersteunen. Automatisch valt terug op SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automatisch"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Pesquisar biblioteca…",
|
"Library.SearchWatermark": "Pesquisar biblioteca…",
|
||||||
"Library.AddFolder": "+ Adicionar pasta",
|
"Library.AddFolder": "+ Adicionar pasta",
|
||||||
"Library.Rescan": "⟳ Reanalisar",
|
|
||||||
"Library.OpenFile": "Abrir ficheiro…",
|
"Library.OpenFile": "Abrir ficheiro…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Iniciar",
|
"Library.Context.Launch": "Iniciar",
|
||||||
@@ -35,6 +34,7 @@
|
|||||||
"Options.Env.DumpSpirv.Desc": "Extrai os shaders AGC e as respetivas traduções SPIR-V para a pasta shader-dumps.\nUtilize ao reportar problemas de shaders ou renderização.",
|
"Options.Env.DumpSpirv.Desc": "Extrai os shaders AGC e as respetivas traduções SPIR-V para a pasta shader-dumps.\nUtilize ao reportar problemas de shaders ou renderização.",
|
||||||
"Options.Env.LogDirectMemory.Desc": "Regista alocações de memória direta e falhas na consola.\nUtilize quando um jogo aborta ou fecha durante o arranque.",
|
"Options.Env.LogDirectMemory.Desc": "Regista alocações de memória direta e falhas na consola.\nUtilize quando um jogo aborta ou fecha durante o arranque.",
|
||||||
"Options.Env.LogNp.Desc": "Regista chamadas da biblioteca NP (PlayStation Network) na consola.",
|
"Options.Env.LogNp.Desc": "Regista chamadas da biblioteca NP (PlayStation Network) na consola.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Recarrega as superfícies do convidado que o próprio código de CPU do jogo reescreve.\nDeixar desativado normalmente. Ativar para títulos cujas superfícies desenhadas pela CPU nunca chegam ao ecrã.\nCusta desempenho e causa regressões em alguns títulos, como GTA V.",
|
||||||
"Options.Section.Emulation": "EMULAÇÃO",
|
"Options.Section.Emulation": "EMULAÇÃO",
|
||||||
"Options.Section.Logging": "REGISTOS",
|
"Options.Section.Logging": "REGISTOS",
|
||||||
"Options.Section.Launcher": "LANÇADOR",
|
"Options.Section.Launcher": "LANÇADOR",
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Junte-se à comunidade, obtenha suporte e acompanhe o desenvolvimento.",
|
"About.Discord.Desc": "Junte-se à comunidade, obtenha suporte e acompanhe o desenvolvimento.",
|
||||||
"About.GithubButton": "Contribua no GitHub!",
|
"About.GithubButton": "Contribua no GitHub!",
|
||||||
"About.DiscordButton": "Junte-se ao nosso Discord!",
|
"About.DiscordComingSoon": "Em breve",
|
||||||
|
|
||||||
"Library.Context.GameSettings": "Definições do jogo…",
|
"Library.Context.GameSettings": "Definições do jogo…",
|
||||||
"Options.Env.WritableApp0.Desc": "Permitir que os jogos criem e escrevam ficheiros dentro da sua pasta de instalação.\nNecessário para dumps não empacotados que escrevem os seus dados guardados ou configurações em /app0.",
|
"Options.Env.WritableApp0.Desc": "Permitir que os jogos criem e escrevam ficheiros dentro da sua pasta de instalação.\nNecessário para dumps não empacotados que escrevem os seus dados guardados ou configurações em /app0.",
|
||||||
@@ -169,5 +169,34 @@
|
|||||||
"Updater.Status.Timeout": "A verificação de atualizações expirou após 10 segundos.",
|
"Updater.Status.Timeout": "A verificação de atualizações expirou após 10 segundos.",
|
||||||
"Updater.Status.Failed": "Não foi possível procurar atualizações.",
|
"Updater.Status.Failed": "Não foi possível procurar atualizações.",
|
||||||
"Updater.Status.ChecksumFailed": "A atualização transferida falhou a verificação SHA-256.",
|
"Updater.Status.ChecksumFailed": "A atualização transferida falhou a verificação SHA-256.",
|
||||||
"Updater.Status.Unsupported": "A atualização automática requer um build x64 para Windows, Linux ou macOS."
|
"Updater.Status.Unsupported": "A atualização automática requer um build x64 para Windows, Linux ou macOS.",
|
||||||
|
"Options.Graphics": "Gráficos",
|
||||||
|
"Options.Section.Rendering": "RENDERIZAÇÃO",
|
||||||
|
"Options.Section.Display": "ECRÃ",
|
||||||
|
"Options.RenderResolution.Label": "Resolução interna",
|
||||||
|
"Options.RenderResolution.Desc": "Renderiza alvos fora do ecrã abaixo da resolução nativa e amplia-os na apresentação. Valores inferiores trocam qualidade de imagem por margem da GPU; entra em vigor no próximo arranque.",
|
||||||
|
"Options.RenderResolution.Native": "100% (nativa)",
|
||||||
|
"Options.WindowMode.Label": "Modo de janela",
|
||||||
|
"Options.WindowMode.Desc": "Janela normal, ambiente de trabalho sem margens ou ecrã inteiro exclusivo.",
|
||||||
|
"Options.WindowMode.Windowed": "Em janela",
|
||||||
|
"Options.WindowMode.Borderless": "Sem margens",
|
||||||
|
"Options.WindowMode.Exclusive": "Exclusivo",
|
||||||
|
"Options.Resolution.Label": "Resolução",
|
||||||
|
"Options.Resolution.Desc": "Tamanho inicial da janela ou resolução de ecrã inteiro exclusivo.",
|
||||||
|
"Options.Display.Label": "Ecrã",
|
||||||
|
"Options.Display.Desc": "Monitor utilizado para centrar e apresentar em ecrã inteiro.",
|
||||||
|
"Options.RefreshRate.Label": "Taxa de atualização",
|
||||||
|
"Options.RefreshRate.Desc": "Taxa de atualização do ecrã inteiro exclusivo. O modo automático seleciona o modo mais próximo.",
|
||||||
|
"Options.RefreshRate.Automatic": "Automática",
|
||||||
|
"Options.Scaling.Label": "Escala",
|
||||||
|
"Options.Scaling.Desc": "Dimensiona a imagem nativa do sistema convidado sem alterar a respetiva resolução interna.",
|
||||||
|
"Options.Scaling.Fit": "Ajustar",
|
||||||
|
"Options.Scaling.Cover": "Preencher",
|
||||||
|
"Options.Scaling.Stretch": "Esticar",
|
||||||
|
"Options.Scaling.Integer": "Inteira",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Utiliza apresentação FIFO para evitar cortes na imagem.",
|
||||||
|
"Options.Hdr.Label": "Saída HDR",
|
||||||
|
"Options.Hdr.Desc": "Utiliza HDR quando o ecrã selecionado e o backend gráfico o suportam. O modo automático regressa a SDR.",
|
||||||
|
"Options.Hdr.Auto": "Automático"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Поиск…",
|
"Library.SearchWatermark": "Поиск…",
|
||||||
"Library.AddFolder": "+ Добавить папку",
|
"Library.AddFolder": "+ Добавить папку",
|
||||||
"Library.Rescan": "⟳ Сканировать",
|
|
||||||
"Library.OpenFile": "Открыть файл…",
|
"Library.OpenFile": "Открыть файл…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Запустить",
|
"Library.Context.Launch": "Запустить",
|
||||||
@@ -38,9 +37,40 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Выводить в консоль выделения прямой памяти и ошибки выделения.\nИспользуйте, если игра аварийно завершает работу или закрывается при запуске.",
|
"Options.Env.LogDirectMemory.Desc": "Выводить в консоль выделения прямой памяти и ошибки выделения.\nИспользуйте, если игра аварийно завершает работу или закрывается при запуске.",
|
||||||
"Options.Env.LogIo.Desc": "Выводить в консоль операции открытия и чтения файлов, а также разрешение путей.\nИспользуйте, если игра не может найти файлы данных при запуске.",
|
"Options.Env.LogIo.Desc": "Выводить в консоль операции открытия и чтения файлов, а также разрешение путей.\nИспользуйте, если игра не может найти файлы данных при запуске.",
|
||||||
"Options.Env.LogNp.Desc": "Выводить в консоль вызовы библиотеки NP (PlayStation Network).",
|
"Options.Env.LogNp.Desc": "Выводить в консоль вызовы библиотеки NP (PlayStation Network).",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Повторно загружать гостевые поверхности, которые переписывает собственный код ЦП игры.\nОбычно оставляйте выключенным. Включайте для игр, чьи отрисованные ЦП поверхности не попадают на экран.\nСнижает производительность и вызывает регрессии в некоторых играх, например в GTA V.",
|
||||||
"Options.Section.Emulation": "ЭМУЛЯЦИЯ",
|
"Options.Section.Emulation": "ЭМУЛЯЦИЯ",
|
||||||
"Options.Section.Logging": "ЛОГГИРОВАНИЕ",
|
"Options.Section.Logging": "ЛОГГИРОВАНИЕ",
|
||||||
"Options.Section.Launcher": "ЛАУНЧЕР",
|
"Options.Section.Launcher": "ЛАУНЧЕР",
|
||||||
|
"Options.Section.Rendering": "РЕНДЕРИНГ",
|
||||||
|
"Options.Section.Display": "ЭКРАН",
|
||||||
|
"Options.Graphics": "Графика",
|
||||||
|
|
||||||
|
"Options.RenderResolution.Label": "Внутреннее разрешение",
|
||||||
|
"Options.RenderResolution.Desc": "Рендерить внеэкранные буферы ниже нативного разрешения и масштабировать при выводе. Меньшие значения снижают качество изображения, но уменьшают нагрузку на GPU; применяется при следующем запуске.",
|
||||||
|
"Options.RenderResolution.Native": "100% (нативное)",
|
||||||
|
"Options.WindowMode.Label": "Режим окна",
|
||||||
|
"Options.WindowMode.Desc": "Обычное окно, безрамочный режим рабочего стола или эксклюзивный полноэкранный режим.",
|
||||||
|
"Options.WindowMode.Windowed": "Оконный",
|
||||||
|
"Options.WindowMode.Borderless": "Без рамки",
|
||||||
|
"Options.WindowMode.Exclusive": "Эксклюзивный",
|
||||||
|
"Options.Resolution.Label": "Разрешение",
|
||||||
|
"Options.Resolution.Desc": "Начальный размер окна или разрешение эксклюзивного полноэкранного режима.",
|
||||||
|
"Options.Display.Label": "Монитор",
|
||||||
|
"Options.Display.Desc": "Монитор, используемый для центрирования окна и полноэкранного режима.",
|
||||||
|
"Options.RefreshRate.Label": "Частота обновления",
|
||||||
|
"Options.RefreshRate.Desc": "Частота обновления эксклюзивного полноэкранного режима. Автоматический режим выбирает ближайшее значение.",
|
||||||
|
"Options.RefreshRate.Automatic": "Автоматически",
|
||||||
|
"Options.Scaling.Label": "Масштабирование",
|
||||||
|
"Options.Scaling.Desc": "Масштабировать нативное изображение игры без изменения внутреннего разрешения.",
|
||||||
|
"Options.Scaling.Fit": "Вписать",
|
||||||
|
"Options.Scaling.Cover": "Заполнить",
|
||||||
|
"Options.Scaling.Stretch": "Растянуть",
|
||||||
|
"Options.Scaling.Integer": "Целочисленное",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Использовать режим представления FIFO для вывода без разрывов изображения.",
|
||||||
|
"Options.Hdr.Label": "HDR-вывод",
|
||||||
|
"Options.Hdr.Desc": "Использовать HDR, если выбранный монитор и графический бэкенд его поддерживают. Автоматический режим при необходимости переключается на SDR.",
|
||||||
|
"Options.Hdr.Auto": "Авто",
|
||||||
|
|
||||||
"Options.CpuEngine.Label": "Движок ЦП",
|
"Options.CpuEngine.Label": "Движок ЦП",
|
||||||
"Options.CpuEngine.Desc": "Движок выполнения, используемый для запуска игрового кода.",
|
"Options.CpuEngine.Desc": "Движок выполнения, используемый для запуска игрового кода.",
|
||||||
@@ -51,12 +81,12 @@
|
|||||||
|
|
||||||
"Options.LogLevel.Label": "Уровень логгирования",
|
"Options.LogLevel.Label": "Уровень логгирования",
|
||||||
"Options.LogLevel.Desc": "Подробность вывода в консоль эмулятора.",
|
"Options.LogLevel.Desc": "Подробность вывода в консоль эмулятора.",
|
||||||
"Options.LogLevel.Trace": "Trace",
|
"Options.LogLevel.Trace": "Трассировка",
|
||||||
"Options.LogLevel.Debug": "Debug",
|
"Options.LogLevel.Debug": "Отладка",
|
||||||
"Options.LogLevel.Info": "Info",
|
"Options.LogLevel.Info": "Информация",
|
||||||
"Options.LogLevel.Warning": "Warning",
|
"Options.LogLevel.Warning": "Предупреждение",
|
||||||
"Options.LogLevel.Error": "Error",
|
"Options.LogLevel.Error": "Ошибка",
|
||||||
"Options.LogLevel.Critical": "Critical",
|
"Options.LogLevel.Critical": "Критический",
|
||||||
|
|
||||||
"Options.TraceImports.Label": "Лимит трассировки импортов",
|
"Options.TraceImports.Label": "Лимит трассировки импортов",
|
||||||
"Options.TraceImports.Desc": "Трассировать первые N импортов в каждом модуле (0 - выключено).",
|
"Options.TraceImports.Desc": "Трассировать первые N импортов в каждом модуле (0 - выключено).",
|
||||||
@@ -87,6 +117,8 @@
|
|||||||
|
|
||||||
"PerGame.Title": "Настройки игры — {0} ({1})",
|
"PerGame.Title": "Настройки игры — {0} ({1})",
|
||||||
"PerGame.InheritNote": "Неотмеченные строки наследуют глобальные настройки.",
|
"PerGame.InheritNote": "Неотмеченные строки наследуют глобальные настройки.",
|
||||||
|
"PerGame.Tab.General": "Основные",
|
||||||
|
"PerGame.Tab.Graphics": "Графика",
|
||||||
"PerGame.EnvToggles.Label": "Переключатели окружения",
|
"PerGame.EnvToggles.Label": "Переключатели окружения",
|
||||||
"PerGame.EnvToggles.Desc": "Переопределить глобальный набор переключателей SHARPEMU_* для этой игры.",
|
"PerGame.EnvToggles.Desc": "Переопределить глобальный набор переключателей SHARPEMU_* для этой игры.",
|
||||||
|
|
||||||
@@ -154,7 +186,7 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Присоединяйтесь к сообществу, получайте поддержку и следите за разработкой.",
|
"About.Discord.Desc": "Присоединяйтесь к сообществу, получайте поддержку и следите за разработкой.",
|
||||||
"About.GithubButton": "Участвовать в разработке на GitHub!",
|
"About.GithubButton": "Участвовать в разработке на GitHub!",
|
||||||
"About.DiscordButton": "Присоединиться к нашему Discord!",
|
"About.DiscordComingSoon": "Скоро",
|
||||||
|
|
||||||
"Updater.Auto.Label": "Проверять обновления при запуске",
|
"Updater.Auto.Label": "Проверять обновления при запуске",
|
||||||
"Updater.Auto.Desc": "Проверяет GitHub без задержки запуска.",
|
"Updater.Auto.Desc": "Проверяет GitHub без задержки запуска.",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"Library.SearchWatermark": "Kütüphanede ara…",
|
"Library.SearchWatermark": "Kütüphanede ara…",
|
||||||
"Library.AddFolder": "+ Klasör ekle",
|
"Library.AddFolder": "+ Klasör ekle",
|
||||||
"Library.Rescan": "⟳ Yeniden tara",
|
|
||||||
"Library.OpenFile": "Dosya aç…",
|
"Library.OpenFile": "Dosya aç…",
|
||||||
|
|
||||||
"Library.Context.Launch": "Başlat",
|
"Library.Context.Launch": "Başlat",
|
||||||
@@ -29,6 +28,24 @@
|
|||||||
"Options.Section.Emulation": "EMÜLASYON",
|
"Options.Section.Emulation": "EMÜLASYON",
|
||||||
"Options.Section.Logging": "GÜNLÜKLEME",
|
"Options.Section.Logging": "GÜNLÜKLEME",
|
||||||
"Options.Section.Launcher": "BAŞLATICI",
|
"Options.Section.Launcher": "BAŞLATICI",
|
||||||
|
"Options.Section.Display": "GÖRÜNTÜ",
|
||||||
|
"Options.Graphics": "Grafik",
|
||||||
|
|
||||||
|
"Options.WindowMode.Label": "Pencere modu",
|
||||||
|
"Options.WindowMode.Desc": "Normal pencere, kenarlıksız masaüstü veya özel tam ekran.",
|
||||||
|
"Options.Resolution.Label": "Çözünürlük",
|
||||||
|
"Options.Resolution.Desc": "Başlangıç pencere boyutu veya özel tam ekran çözünürlüğü.",
|
||||||
|
"Options.Display.Label": "Ekran",
|
||||||
|
"Options.Display.Desc": "Ortalama ve tam ekran için kullanılan monitör.",
|
||||||
|
"Options.RefreshRate.Label": "Yenileme hızı",
|
||||||
|
"Options.RefreshRate.Desc": "Özel tam ekran yenileme hızı. Otomatik, en yakın modu seçer.",
|
||||||
|
"Options.RefreshRate.Automatic": "Otomatik",
|
||||||
|
"Options.Scaling.Label": "Ölçekleme",
|
||||||
|
"Options.Scaling.Desc": "Dahili çözünürlüğü değiştirmeden oyun görüntüsünü ölçekle.",
|
||||||
|
"Options.VSync.Label": "VSync",
|
||||||
|
"Options.VSync.Desc": "Yırtılmasız görüntü için FIFO sunumunu kullan.",
|
||||||
|
"Options.Hdr.Label": "HDR çıkışı",
|
||||||
|
"Options.Hdr.Desc": "Seçili ekran ve grafik backend'i destekliyorsa HDR kullan. Otomatik mod SDR'ye geri döner.",
|
||||||
|
|
||||||
"Options.CpuEngine.Label": "CPU motoru",
|
"Options.CpuEngine.Label": "CPU motoru",
|
||||||
"Options.CpuEngine.Desc": "Oyun kodunu çalıştırmak için kullanılan yürütme motoru.",
|
"Options.CpuEngine.Desc": "Oyun kodunu çalıştırmak için kullanılan yürütme motoru.",
|
||||||
@@ -155,10 +172,13 @@
|
|||||||
"Options.Env.LogDirectMemory.Desc": "Doğrudan bellek tahsislerini ve hatalarını konsola günlükle.\nBir oyun açılış sırasında çöküyor veya kapanıyorsa kullanın.",
|
"Options.Env.LogDirectMemory.Desc": "Doğrudan bellek tahsislerini ve hatalarını konsola günlükle.\nBir oyun açılış sırasında çöküyor veya kapanıyorsa kullanın.",
|
||||||
"Options.Env.LogIo.Desc": "Dosya açma, okuma ve yol çözümleme etkinliğini konsola günlükle.\nBir oyun açılışta veri dosyalarını bulamıyorsa kullanın.",
|
"Options.Env.LogIo.Desc": "Dosya açma, okuma ve yol çözümleme etkinliğini konsola günlükle.\nBir oyun açılışta veri dosyalarını bulamıyorsa kullanın.",
|
||||||
"Options.Env.LogNp.Desc": "NP (PlayStation Network) kütüphane çağrılarını konsola günlükle.",
|
"Options.Env.LogNp.Desc": "NP (PlayStation Network) kütüphane çağrılarını konsola günlükle.",
|
||||||
|
"Options.Env.GuestImageCpuSync.Desc": "Oyunun kendi CPU kodunun yeniden yazdığı misafir yüzeyleri tekrar yükler.\nNormalde kapalı bırakın. CPU ile çizilen yüzeyleri ekrana ulaşmayan oyunlarda açın.\nPerformansa mal olur ve GTA V gibi bazı oyunlarda soruna yol açar.",
|
||||||
"Common.Save": "Kaydet",
|
"Common.Save": "Kaydet",
|
||||||
"Common.Cancel": "İptal",
|
"Common.Cancel": "İptal",
|
||||||
"PerGame.Title": "Oyuna özel ayarlar — {0} ({1})",
|
"PerGame.Title": "Oyuna özel ayarlar — {0} ({1})",
|
||||||
"PerGame.InheritNote": "İşaretlenmemiş satırlar genel varsayılanları kullanır.",
|
"PerGame.InheritNote": "İşaretlenmemiş satırlar genel varsayılanları kullanır.",
|
||||||
|
"PerGame.Tab.General": "Genel",
|
||||||
|
"PerGame.Tab.Graphics": "Grafik",
|
||||||
"PerGame.EnvToggles.Label": "Ortam anahtarları",
|
"PerGame.EnvToggles.Label": "Ortam anahtarları",
|
||||||
"PerGame.EnvToggles.Desc": "Bu oyun için genel SHARPEMU_* anahtar kümesini geçersiz kıl.",
|
"PerGame.EnvToggles.Desc": "Bu oyun için genel SHARPEMU_* anahtar kümesini geçersiz kıl.",
|
||||||
"Options.About": "Hakkında",
|
"Options.About": "Hakkında",
|
||||||
@@ -169,5 +189,17 @@
|
|||||||
"About.Discord.Label": "Discord",
|
"About.Discord.Label": "Discord",
|
||||||
"About.Discord.Desc": "Topluluğa katılın, destek alın ve geliştirmeyi takip edin.",
|
"About.Discord.Desc": "Topluluğa katılın, destek alın ve geliştirmeyi takip edin.",
|
||||||
"About.GithubButton": "GitHub'da katkıda bulun!",
|
"About.GithubButton": "GitHub'da katkıda bulun!",
|
||||||
"About.DiscordButton": "Discord'umuza katıl!"
|
"About.DiscordComingSoon": "Yakında",
|
||||||
|
"Options.Section.Rendering": "GÖRÜNTÜ İŞLEME",
|
||||||
|
"Options.RenderResolution.Label": "Dahili çözünürlük",
|
||||||
|
"Options.RenderResolution.Desc": "Ekran dışı hedefleri doğal çözünürlüğün altında işle ve sunum sırasında ölçeklendir. Daha düşük değerler GPU payı karşılığında görüntü kalitesini azaltır; bir sonraki başlatmada etkili olur.",
|
||||||
|
"Options.RenderResolution.Native": "%100 (doğal)",
|
||||||
|
"Options.WindowMode.Windowed": "Pencereli",
|
||||||
|
"Options.WindowMode.Borderless": "Kenarlıksız",
|
||||||
|
"Options.WindowMode.Exclusive": "Özel",
|
||||||
|
"Options.Scaling.Fit": "Sığdır",
|
||||||
|
"Options.Scaling.Cover": "Kapla",
|
||||||
|
"Options.Scaling.Stretch": "Uzat",
|
||||||
|
"Options.Scaling.Integer": "Tam sayı",
|
||||||
|
"Options.Hdr.Auto": "Otomatik"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace SharpEmu.GUI;
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
public sealed record LanguageInfo(string Code, string NativeName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads UI strings for the launcher. Every language ships embedded in the
|
/// Loads UI strings for the launcher. Every language ships embedded in the
|
||||||
/// assembly (see SharpEmu.GUI.csproj) so a release build is fully
|
/// assembly (see SharpEmu.GUI.csproj) so a release build is fully
|
||||||
@@ -12,27 +16,50 @@ namespace SharpEmu.GUI;
|
|||||||
/// executable overrides the embedded copy for that code, so a translation
|
/// executable overrides the embedded copy for that code, so a translation
|
||||||
/// fix or a brand-new language never needs a rebuild.
|
/// fix or a brand-new language never needs a rebuild.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class Localization
|
public sealed class Localization : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public static Localization Instance { get; } = new();
|
public static Localization Instance { get; } = new();
|
||||||
|
|
||||||
public sealed record LanguageInfo(string Code, string NativeName);
|
|
||||||
|
|
||||||
private const string EmbeddedResourcePrefix = "Languages.";
|
private const string EmbeddedResourcePrefix = "Languages.";
|
||||||
private const string EmbeddedResourceSuffix = ".json";
|
private const string EmbeddedResourceSuffix = ".json";
|
||||||
|
private const string IndexerPropertyName = "Item";
|
||||||
|
|
||||||
|
private readonly string _languagesDirectory;
|
||||||
private Dictionary<string, string> _strings = new();
|
private Dictionary<string, string> _strings = new();
|
||||||
private Dictionary<string, string> _fallbackStrings = new();
|
private Dictionary<string, string> _fallbackStrings = new();
|
||||||
|
private string _currentCode = "en";
|
||||||
|
|
||||||
|
private Localization() : this(LanguagesDirectory)
|
||||||
private Localization()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Localization(string languagesDirectory)
|
||||||
|
{
|
||||||
|
_languagesDirectory = languagesDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Directory holding optional *.json language overrides, next to the executable.</summary>
|
/// <summary>Directory holding optional *.json language overrides, next to the executable.</summary>
|
||||||
public static string LanguagesDirectory => Path.Combine(AppContext.BaseDirectory, "Languages");
|
public static string LanguagesDirectory => Path.Combine(AppContext.BaseDirectory, "Languages");
|
||||||
|
|
||||||
public string CurrentCode { get; private set; } = "en";
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
|
/// <summary>Exposes localized strings to XAML bindings by key.</summary>
|
||||||
|
public string this[string key] => Get(key);
|
||||||
|
|
||||||
|
public string CurrentCode
|
||||||
|
{
|
||||||
|
get => _currentCode;
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
if (_currentCode == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentCode = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string Get(string key)
|
public string Get(string key)
|
||||||
{
|
{
|
||||||
@@ -67,7 +94,7 @@ public sealed class Localization
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var file in Directory.EnumerateFiles(LanguagesDirectory, "*.json"))
|
foreach (var file in Directory.EnumerateFiles(_languagesDirectory, "*.json"))
|
||||||
{
|
{
|
||||||
var code = Path.GetFileNameWithoutExtension(file);
|
var code = Path.GetFileNameWithoutExtension(file);
|
||||||
using var stream = File.OpenRead(file);
|
using var stream = File.OpenRead(file);
|
||||||
@@ -84,47 +111,36 @@ public sealed class Localization
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Loads a language by code (e.g. "en"): a loose override file first, then the embedded copy.</summary>
|
/// <summary>
|
||||||
/// english is the fallback language
|
/// Loads a language by code. Loose files overlay the embedded language,
|
||||||
|
/// while English supplies values missing from the selected language.
|
||||||
|
/// </summary>
|
||||||
public void Load(string code)
|
public void Load(string code)
|
||||||
{
|
{
|
||||||
if (_fallbackStrings.Count == 0 && !string.Equals(code, "en", StringComparison.OrdinalIgnoreCase))
|
_fallbackStrings = LoadMergedLanguage("en");
|
||||||
|
_strings = string.Equals(code, "en", StringComparison.OrdinalIgnoreCase)
|
||||||
|
? _fallbackStrings
|
||||||
|
: LoadMergedLanguage(code);
|
||||||
|
|
||||||
|
CurrentCode = code;
|
||||||
|
OnPropertyChanged(IndexerPropertyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, string> LoadMergedLanguage(string code)
|
||||||
|
{
|
||||||
|
var merged = TryLoadEmbedded(code, out var embedded)
|
||||||
|
? embedded
|
||||||
|
: new Dictionary<string, string>();
|
||||||
|
|
||||||
|
if (TryLoadLooseFile(code, out var loose))
|
||||||
{
|
{
|
||||||
if (!TryLoadLooseFile("en", out var fallback) && !TryLoadEmbedded("en", out fallback))
|
foreach (var (key, value) in loose)
|
||||||
{
|
{
|
||||||
fallback = new Dictionary<string, string>();
|
merged[key] = value;
|
||||||
}
|
}
|
||||||
_fallbackStrings = fallback;
|
|
||||||
}
|
|
||||||
else if (string.Equals(code, "en", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
if (TryLoadLooseFile("en", out var enDict) || TryLoadEmbedded("en", out enDict))
|
|
||||||
{
|
|
||||||
_strings = enDict;
|
|
||||||
_fallbackStrings = enDict;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_strings = new Dictionary<string, string>();
|
|
||||||
_fallbackStrings = new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
CurrentCode = "en";
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the requested language
|
return merged;
|
||||||
if (TryLoadLooseFile(code, out var loaded) || TryLoadEmbedded(code, out loaded))
|
|
||||||
{
|
|
||||||
_strings = loaded;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_fallbackStrings.Count > 0)
|
|
||||||
_strings = new Dictionary<string, string>(_fallbackStrings);
|
|
||||||
else
|
|
||||||
_strings = new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
CurrentCode = code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> EmbeddedLanguageCodes()
|
private static IEnumerable<string> EmbeddedLanguageCodes()
|
||||||
@@ -161,44 +177,12 @@ public sealed class Localization
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryLoadLooseFile(string code)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var path = Path.Combine(LanguagesDirectory, $"{code}.json");
|
|
||||||
return File.Exists(path) && TryLoad(code, File.ReadAllText(path));
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryLoadEmbedded(string code)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var stream = OpenEmbeddedLanguageStream(code);
|
|
||||||
if (stream is null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var reader = new StreamReader(stream);
|
|
||||||
return TryLoad(code, reader.ReadToEnd());
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryLoadLooseFile(string code, out Dictionary<string, string> result)
|
private bool TryLoadLooseFile(string code, out Dictionary<string, string> result)
|
||||||
{
|
{
|
||||||
result = new Dictionary<string, string>();
|
result = new Dictionary<string, string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = Path.Combine(LanguagesDirectory, $"{code}.json");
|
var path = Path.Combine(_languagesDirectory, $"{code}.json");
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -243,14 +227,6 @@ public sealed class Localization
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryLoad(string code, string json)
|
private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||||
{
|
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
if (TryLoad(json, out var dict))
|
|
||||||
{
|
|
||||||
_strings = dict;
|
|
||||||
CurrentCode = code;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A stable settings value with a display label that can be refreshed when
|
||||||
|
/// the active UI language changes.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class LocalizedChoice : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
private string _label;
|
||||||
|
|
||||||
|
private LocalizedChoice(string value, string label, string? localizationKey)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
_label = label;
|
||||||
|
LocalizationKey = localizationKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Value { get; }
|
||||||
|
|
||||||
|
public string Label
|
||||||
|
{
|
||||||
|
get => _label;
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
if (_label == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_label = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? LocalizationKey { get; }
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
|
public static LocalizedChoice FromKey(string value, string localizationKey) =>
|
||||||
|
new(value, localizationKey, localizationKey);
|
||||||
|
|
||||||
|
public static LocalizedChoice Literal(string value, string label) =>
|
||||||
|
new(value, label, null);
|
||||||
|
|
||||||
|
public void Refresh(Localization localization)
|
||||||
|
{
|
||||||
|
if (LocalizationKey is { } key)
|
||||||
|
{
|
||||||
|
Label = localization.Get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPropertyChanged([CallerMemberName] string? propertyName = null) =>
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
+386
-175
@@ -14,12 +14,18 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
WindowState="Maximized"
|
WindowState="Maximized"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Background="{StaticResource BgBrush}"
|
Background="{StaticResource BgBrush}"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
WindowDecorations="None"
|
||||||
ExtendClientAreaChromeHints="PreferSystemChrome"
|
|
||||||
ExtendClientAreaTitleBarHeightHint="44"
|
|
||||||
Icon="avares://SharpEmu.GUI/Assets/SharpEmu.ico"
|
Icon="avares://SharpEmu.GUI/Assets/SharpEmu.ico"
|
||||||
KeyDown="OnKeyDown">
|
KeyDown="OnKeyDown">
|
||||||
|
|
||||||
|
<Window.Resources>
|
||||||
|
<DataTemplate x:Key="LocalizedChoiceTemplate" x:DataType="local:LocalizedChoice">
|
||||||
|
<TextBlock Text="{Binding Label}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
TextAlignment="Left" />
|
||||||
|
</DataTemplate>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid x:Name="RootLayout" RowDefinitions="Auto,*,Auto">
|
<Grid x:Name="RootLayout" RowDefinitions="Auto,*,Auto">
|
||||||
|
|
||||||
<!-- Selected-game backdrop: key art behind the main content, dimmed by
|
<!-- Selected-game backdrop: key art behind the main content, dimmed by
|
||||||
@@ -46,7 +52,11 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
|
|
||||||
<!-- Title bar; hidden in fullscreen (F11) along with the status bar, so
|
<!-- Title bar; hidden in fullscreen (F11) along with the status bar, so
|
||||||
the game gets the whole screen. -->
|
the game gets the whole screen. -->
|
||||||
<Grid x:Name="TitleBar" Grid.Row="0" Height="44" Background="{StaticResource ChromeBrush}">
|
<Grid x:Name="TitleBar"
|
||||||
|
Grid.Row="0"
|
||||||
|
Height="44"
|
||||||
|
ColumnDefinitions="*,Auto"
|
||||||
|
Background="{StaticResource ChromeBrush}">
|
||||||
<StackPanel Orientation="Horizontal" Spacing="10" Margin="16,0" VerticalAlignment="Center">
|
<StackPanel Orientation="Horizontal" Spacing="10" Margin="16,0" VerticalAlignment="Center">
|
||||||
<Image Source="avares://SharpEmu.GUI/Assets/SharpEmu.ico" Width="20" Height="20"
|
<Image Source="avares://SharpEmu.GUI/Assets/SharpEmu.ico" Width="20" Height="20"
|
||||||
RenderOptions.BitmapInterpolationMode="HighQuality" />
|
RenderOptions.BitmapInterpolationMode="HighQuality" />
|
||||||
@@ -55,17 +65,34 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<TextBlock x:Name="VersionText" Text="v0.0.1" FontSize="11" Foreground="{StaticResource MutedBrush}" />
|
<TextBlock x:Name="VersionText" Text="v0.0.1" FontSize="11" Foreground="{StaticResource MutedBrush}" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel x:Name="WindowChromeButtons"
|
||||||
|
Grid.Column="1"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Right">
|
||||||
|
<Button x:Name="MinimizeButton"
|
||||||
|
Classes="windowChrome"
|
||||||
|
ToolTip.Tip="Minimize"
|
||||||
|
AutomationProperties.Name="Minimize window">
|
||||||
|
<TextBlock Text="—" FontSize="16" />
|
||||||
|
</Button>
|
||||||
|
<Button x:Name="MaximizeButton"
|
||||||
|
Classes="windowChrome"
|
||||||
|
ToolTip.Tip="Restore"
|
||||||
|
AutomationProperties.Name="Restore window">
|
||||||
|
<TextBlock x:Name="MaximizeGlyph" Text="❐" FontSize="13" />
|
||||||
|
</Button>
|
||||||
|
<Button x:Name="CloseButton"
|
||||||
|
Classes="windowChrome windowClose"
|
||||||
|
ToolTip.Tip="Close"
|
||||||
|
AutomationProperties.Name="Close window">
|
||||||
|
<TextBlock Text="×" FontSize="20" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Main content -->
|
<!-- Main content -->
|
||||||
<Grid x:Name="MainContent" Grid.Row="1" Margin="32,24,32,20" RowDefinitions="Auto,*,Auto,Auto">
|
<Grid x:Name="MainContent" Grid.Row="1" Margin="32,24,32,20" RowDefinitions="Auto,*,Auto,Auto">
|
||||||
|
|
||||||
<!-- The game owns the full client area while running. Session controls
|
|
||||||
use a native popup so they can stay above this native child surface. -->
|
|
||||||
<Border x:Name="GameView" Grid.Row="0" Grid.RowSpan="4" IsVisible="False" Background="#000000" ClipToBounds="True">
|
|
||||||
<Grid x:Name="GameSurfaceContainer" />
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<!-- Library / Options page switcher, with the library toolbar sharing
|
<!-- Library / Options page switcher, with the library toolbar sharing
|
||||||
the same row on the right. Plain buttons (not TabItem) so there is
|
the same row on the right. Plain buttons (not TabItem) so there is
|
||||||
no underline; LB/RB hint chips flank the pair and the gamepad's
|
no underline; LB/RB hint chips flank the pair and the gamepad's
|
||||||
@@ -75,8 +102,12 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<Border Classes="padHint" VerticalAlignment="Center">
|
<Border Classes="padHint" VerticalAlignment="Center">
|
||||||
<TextBlock Text="LB" FontSize="11" FontWeight="Bold" Foreground="{StaticResource MutedBrush}" />
|
<TextBlock Text="LB" FontSize="11" FontWeight="Bold" Foreground="{StaticResource MutedBrush}" />
|
||||||
</Border>
|
</Border>
|
||||||
<Button x:Name="LibraryTabButton" Classes="segment active" Content="Library" />
|
<Button x:Name="LibraryTabButton"
|
||||||
<Button x:Name="OptionsTabButton" Classes="segment" Content="Options" />
|
Classes="segment active"
|
||||||
|
Content="{Binding [Page.Library], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
<Button x:Name="OptionsTabButton"
|
||||||
|
Classes="segment"
|
||||||
|
Content="{Binding [Page.Options], Source={x:Static local:Localization.Instance}}" />
|
||||||
<Border Classes="padHint" VerticalAlignment="Center">
|
<Border Classes="padHint" VerticalAlignment="Center">
|
||||||
<TextBlock Text="RB" FontSize="11" FontWeight="Bold" Foreground="{StaticResource MutedBrush}" />
|
<TextBlock Text="RB" FontSize="11" FontWeight="Bold" Foreground="{StaticResource MutedBrush}" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -84,10 +115,18 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
|
|
||||||
<StackPanel Grid.Column="2" x:Name="LibraryToolbar" Orientation="Horizontal" Spacing="8"
|
<StackPanel Grid.Column="2" x:Name="LibraryToolbar" Orientation="Horizontal" Spacing="8"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center">
|
||||||
<TextBox x:Name="SearchBox" Watermark="Search library…" Width="240" VerticalAlignment="Center" />
|
<TextBox x:Name="SearchBox"
|
||||||
<Button x:Name="AddFolderButton" Classes="ghost" Content="+ Add folder" VerticalAlignment="Center" />
|
PlaceholderText="{Binding [Library.SearchWatermark], Source={x:Static local:Localization.Instance}}"
|
||||||
<Button x:Name="RescanButton" Classes="ghost" Content="⟳ Rescan" VerticalAlignment="Center" />
|
Width="240"
|
||||||
<Button x:Name="OpenFileButton" Classes="ghost" Content="Open file…" VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
|
<Button x:Name="AddFolderButton"
|
||||||
|
Classes="ghost"
|
||||||
|
Content="{Binding [Library.AddFolder], Source={x:Static local:Localization.Instance}}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<Button x:Name="OpenFileButton"
|
||||||
|
Classes="ghost"
|
||||||
|
Content="{Binding [Library.OpenFile], Source={x:Static local:Localization.Instance}}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -101,39 +140,46 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
SelectionMode="Single" Padding="0">
|
SelectionMode="Single" Padding="0">
|
||||||
<ListBox.ContextMenu>
|
<ListBox.ContextMenu>
|
||||||
<ContextMenu x:Name="GameContextMenu" Placement="Pointer">
|
<ContextMenu x:Name="GameContextMenu" Placement="Pointer">
|
||||||
<MenuItem x:Name="CtxLaunch" Header="Launch" FontWeight="SemiBold">
|
<MenuItem x:Name="CtxLaunch"
|
||||||
|
Header="{Binding [Library.Context.Launch], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontWeight="SemiBold">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock Text="▶" FontSize="11" Foreground="{StaticResource AccentHoverBrush}"
|
<TextBlock Text="▶" FontSize="11" Foreground="{StaticResource AccentHoverBrush}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem x:Name="CtxOpenFolder" Header="Open game folder">
|
<MenuItem x:Name="CtxOpenFolder"
|
||||||
|
Header="{Binding [Library.Context.OpenFolder], Source={x:Static local:Localization.Instance}}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock Text="📂" FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
<TextBlock Text="📂" FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem x:Name="CtxCopyPath" Header="Copy path">
|
<MenuItem x:Name="CtxCopyPath"
|
||||||
|
Header="{Binding [Library.Context.CopyPath], Source={x:Static local:Localization.Instance}}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock Text="⧉" FontSize="13" Foreground="{StaticResource MutedBrush}"
|
<TextBlock Text="⧉" FontSize="13" Foreground="{StaticResource MutedBrush}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem x:Name="CtxCopyTitleId" Header="Copy title ID">
|
<MenuItem x:Name="CtxCopyTitleId"
|
||||||
|
Header="{Binding [Library.Context.CopyTitleId], Source={x:Static local:Localization.Instance}}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock Text="⧉" FontSize="13" Foreground="{StaticResource MutedBrush}"
|
<TextBlock Text="⧉" FontSize="13" Foreground="{StaticResource MutedBrush}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem x:Name="CtxGameSettings" Header="Game settings…">
|
<MenuItem x:Name="CtxGameSettings"
|
||||||
|
Header="{Binding [Library.Context.GameSettings], Source={x:Static local:Localization.Instance}}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock Text="⚙" FontSize="13" Foreground="{StaticResource MutedBrush}"
|
<TextBlock Text="⚙" FontSize="13" Foreground="{StaticResource MutedBrush}"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem x:Name="CtxRemove" Header="Remove from library"
|
<MenuItem x:Name="CtxRemove"
|
||||||
|
Header="{Binding [Library.Context.Remove], Source={x:Static local:Localization.Instance}}"
|
||||||
Foreground="{StaticResource DangerHoverBrush}">
|
Foreground="{StaticResource DangerHoverBrush}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<TextBlock Text="✕" FontSize="12" Foreground="{StaticResource DangerHoverBrush}"
|
<TextBlock Text="✕" FontSize="12" Foreground="{StaticResource DangerHoverBrush}"
|
||||||
@@ -148,7 +194,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ListBox.ItemsPanel>
|
</ListBox.ItemsPanel>
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate x:DataType="local:GameEntry" x:CompileBindings="True">
|
||||||
<StackPanel Width="128" Height="172" Spacing="7">
|
<StackPanel Width="128" Height="172" Spacing="7">
|
||||||
<Border Classes="coverShadow" Width="128" Height="128">
|
<Border Classes="coverShadow" Width="128" Height="128">
|
||||||
<Border Classes="coverClip">
|
<Border Classes="coverClip">
|
||||||
@@ -178,7 +224,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
HorizontalAlignment="Center" />
|
HorizontalAlignment="Center" />
|
||||||
<TextBlock x:Name="EmptyStateHint" Text="Add a folder containing your games to get started."
|
<TextBlock x:Name="EmptyStateHint" Text="Add a folder containing your games to get started."
|
||||||
FontSize="13" Foreground="{StaticResource MutedBrush}" HorizontalAlignment="Center" />
|
FontSize="13" Foreground="{StaticResource MutedBrush}" HorizontalAlignment="Center" />
|
||||||
<Button x:Name="EmptyAddFolderButton" Classes="accent" Content="+ Add game folder"
|
<Button x:Name="EmptyAddFolderButton" Classes="accent"
|
||||||
|
Content="{Binding [Library.Empty.AddFolder], Source={x:Static local:Localization.Instance}}"
|
||||||
HorizontalAlignment="Center" Margin="0,8,0,0" />
|
HorizontalAlignment="Center" Margin="0,8,0,0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@@ -188,7 +235,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<StackPanel x:Name="LoadingState" Spacing="14" HorizontalAlignment="Center" VerticalAlignment="Center"
|
<StackPanel x:Name="LoadingState" Spacing="14" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
IsVisible="False">
|
IsVisible="False">
|
||||||
<ProgressBar IsIndeterminate="True" Width="180" Height="3" />
|
<ProgressBar IsIndeterminate="True" Width="180" Height="3" />
|
||||||
<TextBlock x:Name="LoadingStateText" Text="Loading library…" FontSize="13"
|
<TextBlock x:Name="LoadingStateText"
|
||||||
|
Text="{Binding [Library.Loading], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="13"
|
||||||
Foreground="{StaticResource MutedBrush}" HorizontalAlignment="Center" />
|
Foreground="{StaticResource MutedBrush}" HorizontalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Panel>
|
</Panel>
|
||||||
@@ -198,25 +247,32 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
language used by the console panel and launch bar below. -->
|
language used by the console panel and launch bar below. -->
|
||||||
<Grid x:Name="OptionsPage" IsVisible="False">
|
<Grid x:Name="OptionsPage" IsVisible="False">
|
||||||
<TabControl>
|
<TabControl>
|
||||||
<TabItem x:Name="GeneralTabItem" Header="General" FontSize="15">
|
<TabItem x:Name="GeneralTabItem"
|
||||||
|
Header="{Binding [Options.General], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="15">
|
||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<StackPanel Margin="0,14,0,16" Spacing="16" MaxWidth="1280" HorizontalAlignment="Left">
|
<StackPanel Margin="0,14,0,16" Spacing="16" MaxWidth="1280" HorizontalAlignment="Left">
|
||||||
|
|
||||||
<Border Classes="card">
|
<Border Classes="card">
|
||||||
<StackPanel Spacing="14">
|
<StackPanel Spacing="14">
|
||||||
<TextBlock x:Name="EmulationSectionTitle" Classes="sectionTitle" Text="EMULATION" />
|
<TextBlock x:Name="EmulationSectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Options.Section.Emulation], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
|
||||||
<local:SettingRow x:Name="CpuEngineRow" Label="CPU engine"
|
<local:SettingRow x:Name="CpuEngineRow"
|
||||||
Description="Execution engine used to run game code.">
|
Label="{Binding [Options.CpuEngine.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ComboBox x:Name="CpuEngineBox" Width="160" SelectedIndex="0"
|
Description="{Binding [Options.CpuEngine.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
VerticalAlignment="Center" CornerRadius="8">
|
<ComboBox x:Name="CpuEngineBox" Width="160"
|
||||||
<ComboBoxItem x:Name="CpuEngineNativeItem" Content="Native" />
|
ItemTemplate="{StaticResource LocalizedChoiceTemplate}"
|
||||||
</ComboBox>
|
HorizontalContentAlignment="Left"
|
||||||
|
VerticalAlignment="Center" CornerRadius="8" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="StrictRow" Label="Strict dynlib resolution"
|
<local:SettingRow x:Name="StrictRow"
|
||||||
Description="Fail the launch when an imported symbol cannot be resolved.">
|
Label="{Binding [Options.Strict.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ToggleSwitch x:Name="StrictToggle" OnContent="On" OffContent="Off"
|
Description="{Binding [Options.Strict.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="StrictToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -224,43 +280,49 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
|
|
||||||
<Border Classes="card">
|
<Border Classes="card">
|
||||||
<StackPanel Spacing="14">
|
<StackPanel Spacing="14">
|
||||||
<TextBlock x:Name="LoggingSectionTitle" Classes="sectionTitle" Text="LOGGING" />
|
<TextBlock x:Name="LoggingSectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Options.Section.Logging], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
|
||||||
<local:SettingRow x:Name="LogLevelRow" Label="Log level"
|
<local:SettingRow x:Name="LogLevelRow"
|
||||||
Description="Verbosity of the emulator console output.">
|
Label="{Binding [Options.LogLevel.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ComboBox x:Name="LogLevelBox" Width="160" SelectedIndex="2"
|
Description="{Binding [Options.LogLevel.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
VerticalAlignment="Center" CornerRadius="8">
|
<ComboBox x:Name="LogLevelBox" Width="160"
|
||||||
<ComboBoxItem x:Name="LogLevelTraceItem" Content="Trace" />
|
ItemTemplate="{StaticResource LocalizedChoiceTemplate}"
|
||||||
<ComboBoxItem x:Name="LogLevelDebugItem" Content="Debug" />
|
HorizontalContentAlignment="Left"
|
||||||
<ComboBoxItem x:Name="LogLevelInfoItem" Content="Info" />
|
VerticalAlignment="Center" CornerRadius="8" />
|
||||||
<ComboBoxItem x:Name="LogLevelWarningItem" Content="Warning" />
|
|
||||||
<ComboBoxItem x:Name="LogLevelErrorItem" Content="Error" />
|
|
||||||
<ComboBoxItem x:Name="LogLevelCriticalItem" Content="Critical" />
|
|
||||||
</ComboBox>
|
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="TraceImportsRow" Label="Import trace limit"
|
<local:SettingRow x:Name="TraceImportsRow"
|
||||||
Description="Trace the first N imports per module (0 = off).">
|
Label="{Binding [Options.TraceImports.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.TraceImports.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<NumericUpDown x:Name="TraceImportsBox" Width="160" Minimum="0"
|
<NumericUpDown x:Name="TraceImportsBox" Width="160" Minimum="0"
|
||||||
Maximum="4096" Increment="16" Value="0" FormatString="0"
|
Maximum="4096" Increment="16" Value="0" FormatString="0"
|
||||||
VerticalAlignment="Center" CornerRadius="8" />
|
VerticalAlignment="Center" CornerRadius="8" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="LogToFileRow" Label="Log to file"
|
<local:SettingRow x:Name="LogToFileRow"
|
||||||
Description="Mirror emulator output to a log file.">
|
Label="{Binding [Options.LogToFile.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ToggleSwitch x:Name="LogToFileToggle" OnContent="On" OffContent="Off"
|
Description="{Binding [Options.LogToFile.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="LogToFileToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="LogFilePathRow" Label="Log file path"
|
<local:SettingRow x:Name="LogFilePathRow"
|
||||||
|
Label="{Binding [Options.LogFilePath.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
Description="No custom path">
|
Description="No custom path">
|
||||||
<Button x:Name="SelectLogFilePathButton" Classes="ghost" Content="Select…"
|
<Button x:Name="SelectLogFilePathButton" Classes="ghost"
|
||||||
|
Content="{Binding [Options.LogFilePath.Select], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="OverrideLogFileRow" Label="Override log file"
|
<local:SettingRow x:Name="OverrideLogFileRow"
|
||||||
Description="Use the exact file path instead of appending title ID and timestamp.">
|
Label="{Binding [Options.OverrideLogFile.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ToggleSwitch x:Name="OverrideLogFileToggle" OnContent="On" OffContent="Off"
|
Description="{Binding [Options.OverrideLogFile.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="OverrideLogFileToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -268,30 +330,46 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
|
|
||||||
<Border Classes="card">
|
<Border Classes="card">
|
||||||
<StackPanel Spacing="14">
|
<StackPanel Spacing="14">
|
||||||
<TextBlock x:Name="LauncherSectionTitle" Classes="sectionTitle" Text="LAUNCHER" />
|
<TextBlock x:Name="LauncherSectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Options.Section.Launcher], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
|
||||||
<local:SettingRow x:Name="LanguageRow" Label="Emulator language"
|
<local:SettingRow x:Name="LanguageRow"
|
||||||
Description="Language used throughout the launcher. Applies immediately.">
|
Label="{Binding [Options.Language.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.Language.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ComboBox x:Name="LanguageBox" Width="160"
|
<ComboBox x:Name="LanguageBox" Width="160"
|
||||||
VerticalAlignment="Center" CornerRadius="8"
|
VerticalAlignment="Center" CornerRadius="8">
|
||||||
DisplayMemberBinding="{Binding NativeName}" />
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="local:LanguageInfo">
|
||||||
|
<TextBlock Text="{Binding NativeName}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="TitleMusicRow" Label="Title music"
|
<local:SettingRow x:Name="TitleMusicRow"
|
||||||
Description="Loop the selected game's preview music in the library.">
|
Label="{Binding [Options.TitleMusic.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ToggleSwitch x:Name="TitleMusicToggle" OnContent="On" OffContent="Off"
|
Description="{Binding [Options.TitleMusic.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="TitleMusicToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
IsChecked="True" VerticalAlignment="Center" />
|
IsChecked="True" VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="DiscordRow" Label="Discord presence"
|
<local:SettingRow x:Name="DiscordRow"
|
||||||
Description="Show the running game on your Discord profile.">
|
Label="{Binding [Options.Discord.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ToggleSwitch x:Name="DiscordToggle" OnContent="On" OffContent="Off"
|
Description="{Binding [Options.Discord.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="DiscordToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="AutoUpdateRow" Label="Check for updates on startup"
|
<local:SettingRow x:Name="AutoUpdateRow"
|
||||||
Description="Checks GitHub without delaying startup.">
|
Label="{Binding [Updater.Auto.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ToggleSwitch x:Name="AutoUpdateToggle" OnContent="On" OffContent="Off"
|
Description="{Binding [Updater.Auto.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="AutoUpdateToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
IsChecked="True" VerticalAlignment="Center" />
|
IsChecked="True" VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -300,7 +378,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<StackPanel Spacing="14">
|
<StackPanel Spacing="14">
|
||||||
<TextBlock x:Name="AboutSectionTitle"
|
<TextBlock x:Name="AboutSectionTitle"
|
||||||
Classes="sectionTitle"
|
Classes="sectionTitle"
|
||||||
Text="ABOUT" />
|
Text="{Binding [Options.About], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
|
||||||
<!--Latest commit info-->
|
<!--Latest commit info-->
|
||||||
<Grid ColumnDefinitions="*,Auto">
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
@@ -308,8 +386,12 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<Image Source="avares://SharpEmu.GUI/Assets/commit-icon.png"
|
<Image Source="avares://SharpEmu.GUI/Assets/commit-icon.png"
|
||||||
Width="24" Height="24" VerticalAlignment="Center" />
|
Width="24" Height="24" VerticalAlignment="Center" />
|
||||||
<StackPanel Spacing="2" VerticalAlignment="Center">
|
<StackPanel Spacing="2" VerticalAlignment="Center">
|
||||||
<TextBlock x:Name="LatestCommitLabel" Text="Latest commit" FontSize="13"/>
|
<TextBlock x:Name="LatestCommitLabel"
|
||||||
<TextBlock x:Name="LatestCommitDescription" Text="Latest commit on the main branch" FontSize="11" Foreground="{StaticResource MutedBrush}"/>
|
Text="{Binding [About.Github.LatestCommitLabel], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="13"/>
|
||||||
|
<TextBlock x:Name="LatestCommitDescription"
|
||||||
|
Text="{Binding [About.Github.LatestCommitDescription], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="11" Foreground="{StaticResource MutedBrush}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@@ -327,7 +409,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
Height="24"
|
Height="24"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
<StackPanel Spacing="2" VerticalAlignment="Center">
|
<StackPanel Spacing="2" VerticalAlignment="Center">
|
||||||
<TextBlock x:Name="UpdateLabel" Text="Updates" FontSize="13" />
|
<TextBlock x:Name="UpdateLabel"
|
||||||
|
Text="{Binding [Updater.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="13" />
|
||||||
<TextBlock x:Name="UpdateStatusText" Text="Current build: dev" FontSize="11"
|
<TextBlock x:Name="UpdateStatusText" Text="Current build: dev" FontSize="11"
|
||||||
Foreground="{StaticResource MutedBrush}" TextWrapping="Wrap" />
|
Foreground="{StaticResource MutedBrush}" TextWrapping="Wrap" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -349,10 +433,10 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<StackPanel VerticalAlignment="Center"
|
<StackPanel VerticalAlignment="Center"
|
||||||
Spacing="2">
|
Spacing="2">
|
||||||
<TextBlock x:Name="GithubLabel"
|
<TextBlock x:Name="GithubLabel"
|
||||||
Text="GitHub"
|
Text="{Binding [About.Github.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
FontSize="13" />
|
FontSize="13" />
|
||||||
<TextBlock x:Name="GithubDesc"
|
<TextBlock x:Name="GithubDesc"
|
||||||
Text="Source code, issues and project development."
|
Text="{Binding [About.Github.Desc], Source={x:Static local:Localization.Instance}}"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
Foreground="{StaticResource MutedBrush}"
|
Foreground="{StaticResource MutedBrush}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
@@ -362,7 +446,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<Button Grid.Column="1"
|
<Button Grid.Column="1"
|
||||||
x:Name="GithubButton"
|
x:Name="GithubButton"
|
||||||
Classes="ghost"
|
Classes="ghost"
|
||||||
Content="Open"
|
Content="{Binding [About.GithubButton], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -379,106 +463,187 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<StackPanel VerticalAlignment="Center"
|
<StackPanel VerticalAlignment="Center"
|
||||||
Spacing="2">
|
Spacing="2">
|
||||||
<TextBlock x:Name="DiscordServerLabel"
|
<TextBlock x:Name="DiscordServerLabel"
|
||||||
Text="Discord"
|
Text="{Binding [About.Discord.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
FontSize="13" />
|
FontSize="13" />
|
||||||
<TextBlock x:Name="DiscordServerDesc"
|
<TextBlock x:Name="DiscordServerDesc"
|
||||||
Text="Join the community, get support and follow development."
|
Text="{Binding [About.Discord.Desc], Source={x:Static local:Localization.Instance}}"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
Foreground="{StaticResource MutedBrush}"
|
Foreground="{StaticResource MutedBrush}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Button Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
x:Name="DiscordButton"
|
x:Name="DiscordComingSoonText"
|
||||||
Classes="ghost"
|
Text="{Binding [About.DiscordComingSoon], Source={x:Static local:Localization.Instance}}"
|
||||||
Content="Join"
|
FontSize="12"
|
||||||
VerticalAlignment="Center" />
|
Foreground="{StaticResource MutedBrush}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem x:Name="GraphicsTabItem" Header="Graphics" FontSize="15">
|
<TabItem x:Name="GraphicsTabItem"
|
||||||
|
Header="{Binding [Options.Graphics], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="15">
|
||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<StackPanel Margin="0,14,0,16" Spacing="16" MaxWidth="1280" HorizontalAlignment="Left">
|
<StackPanel Margin="0,14,0,16" Spacing="16" MaxWidth="1280" HorizontalAlignment="Left">
|
||||||
|
<Border Classes="card">
|
||||||
|
<StackPanel Spacing="14">
|
||||||
|
<TextBlock x:Name="RenderingSectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Options.Section.Rendering], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
|
||||||
|
<local:SettingRow x:Name="RenderResolutionRow"
|
||||||
|
Label="{Binding [Options.RenderResolution.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.RenderResolution.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ComboBox x:Name="RenderResolutionBox" Width="160"
|
||||||
|
ItemTemplate="{StaticResource LocalizedChoiceTemplate}"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
VerticalAlignment="Center" CornerRadius="8" />
|
||||||
|
</local:SettingRow>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<Border Classes="card">
|
<Border Classes="card">
|
||||||
<StackPanel Spacing="14">
|
<StackPanel Spacing="14">
|
||||||
<TextBlock x:Name="RenderingSectionTitle" Classes="sectionTitle" Text="RENDERING" />
|
<TextBlock x:Name="DisplaySectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Options.Section.Display], Source={x:Static local:Localization.Instance}}" />
|
||||||
<local:SettingRow x:Name="RenderResolutionRow" Label="Internal resolution"
|
<local:SettingRow x:Name="WindowModeRow"
|
||||||
Description="Render offscreen targets below native resolution and upscale on present. Lower values trade image quality for GPU headroom; takes effect on next launch.">
|
Label="{Binding [Options.WindowMode.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
<ComboBox x:Name="RenderResolutionBox" Width="160" SelectedIndex="0"
|
Description="{Binding [Options.WindowMode.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
VerticalAlignment="Center" CornerRadius="8">
|
<ComboBox x:Name="WindowModeBox" Width="180"
|
||||||
<ComboBoxItem x:Name="RenderResolution100Item" Content="100% (native)" Tag="1.0" />
|
ItemTemplate="{StaticResource LocalizedChoiceTemplate}"
|
||||||
<ComboBoxItem x:Name="RenderResolution75Item" Content="75%" Tag="0.75" />
|
HorizontalContentAlignment="Left"
|
||||||
<ComboBoxItem x:Name="RenderResolution50Item" Content="50%" Tag="0.5" />
|
CornerRadius="8" />
|
||||||
<ComboBoxItem x:Name="RenderResolution25Item" Content="25%" Tag="0.25" />
|
</local:SettingRow>
|
||||||
</ComboBox>
|
<local:SettingRow x:Name="ResolutionRow"
|
||||||
|
Label="{Binding [Options.Resolution.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.Resolution.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ComboBox x:Name="ResolutionBox" Width="180" CornerRadius="8" />
|
||||||
|
</local:SettingRow>
|
||||||
|
<local:SettingRow x:Name="DisplayRow"
|
||||||
|
Label="{Binding [Options.Display.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.Display.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ComboBox x:Name="DisplayBox" Width="260" CornerRadius="8" />
|
||||||
|
</local:SettingRow>
|
||||||
|
<local:SettingRow x:Name="RefreshRateRow"
|
||||||
|
Label="{Binding [Options.RefreshRate.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.RefreshRate.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ComboBox x:Name="RefreshRateBox" Width="180" CornerRadius="8" />
|
||||||
|
</local:SettingRow>
|
||||||
|
<local:SettingRow x:Name="ScalingRow"
|
||||||
|
Label="{Binding [Options.Scaling.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.Scaling.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ComboBox x:Name="ScalingModeBox" Width="180"
|
||||||
|
ItemTemplate="{StaticResource LocalizedChoiceTemplate}"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
CornerRadius="8" />
|
||||||
|
</local:SettingRow>
|
||||||
|
<local:SettingRow x:Name="VSyncRow"
|
||||||
|
Label="{Binding [Options.VSync.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.VSync.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="VSyncToggle" IsChecked="True"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}" />
|
||||||
|
</local:SettingRow>
|
||||||
|
<local:SettingRow x:Name="HdrRow"
|
||||||
|
Label="{Binding [Options.Hdr.Label], Source={x:Static local:Localization.Instance}}"
|
||||||
|
Description="{Binding [Options.Hdr.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ComboBox x:Name="HdrModeBox" Width="180"
|
||||||
|
ItemTemplate="{StaticResource LocalizedChoiceTemplate}"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
CornerRadius="8" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem x:Name="EnvTabItem" Header="Environment" FontSize="15">
|
<TabItem x:Name="EnvTabItem"
|
||||||
|
Header="{Binding [Options.Env.Tab], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="15">
|
||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<StackPanel Margin="0,14,0,16" Spacing="16" MaxWidth="1280" HorizontalAlignment="Left">
|
<StackPanel Margin="0,14,0,16" Spacing="16" MaxWidth="1280" HorizontalAlignment="Left">
|
||||||
|
|
||||||
<Border Classes="card">
|
<Border Classes="card">
|
||||||
<StackPanel Spacing="14">
|
<StackPanel Spacing="14">
|
||||||
<TextBlock x:Name="EnvSectionTitle" Classes="sectionTitle" Text="ENVIRONMENT VARIABLES" />
|
<TextBlock x:Name="EnvSectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Options.Section.Environment], Source={x:Static local:Localization.Instance}}" />
|
||||||
<TextBlock x:Name="EnvDesc"
|
<TextBlock x:Name="EnvDesc"
|
||||||
Text="Switches passed to the emulator as environment variables at launch."
|
Text="{Binding [Options.Env.Desc], Source={x:Static local:Localization.Instance}}"
|
||||||
FontSize="11" Foreground="{StaticResource MutedBrush}" TextWrapping="Wrap" />
|
FontSize="11" Foreground="{StaticResource MutedBrush}" TextWrapping="Wrap" />
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvBthidRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_BTHID_UNAVAILABLE"
|
<local:SettingRow x:Name="EnvBthidRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_BTHID_UNAVAILABLE"
|
||||||
Description="Report Bluetooth HID as unavailable for titles whose wheel/FFB middleware polls forever. Leave off normally. Some titles freeze when init fails.">
|
Description="{Binding [Options.Env.Bthid.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvBthidToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvBthidToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvLoopGuardRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_DISABLE_IMPORT_LOOP_GUARD"
|
<local:SettingRow x:Name="EnvLoopGuardRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_DISABLE_IMPORT_LOOP_GUARD"
|
||||||
Description="Do not force quit titles that repeat the same call for too long. Try this when a game exits on its own while loading.">
|
Description="{Binding [Options.Env.LoopGuard.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvLoopGuardToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvLoopGuardToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvWritableApp0Row" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_WRITABLE_APP0"
|
<local:SettingRow x:Name="EnvWritableApp0Row" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_WRITABLE_APP0"
|
||||||
Description="Allow titles to create and write files inside their install folder. Needed by unpackaged dumps that write their save or config data under /app0.">
|
Description="{Binding [Options.Env.WritableApp0.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvWritableApp0Toggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvWritableApp0Toggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvVkValidationRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_VK_VALIDATION"
|
<local:SettingRow x:Name="EnvVkValidationRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_VK_VALIDATION"
|
||||||
Description="Enable Vulkan validation layers for GPU debugging. Slow. Requires the Vulkan SDK to be installed.">
|
Description="{Binding [Options.Env.VkValidation.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvVkValidationToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvVkValidationToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvDumpSpirvRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_DUMP_SPIRV"
|
<local:SettingRow x:Name="EnvDumpSpirvRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_DUMP_SPIRV"
|
||||||
Description="Dump AGC shaders and their SPIR-V translations to the shader-dumps folder. Use when reporting shader or rendering bugs.">
|
Description="{Binding [Options.Env.DumpSpirv.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvDumpSpirvToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvDumpSpirvToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvLogDirectMemoryRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_LOG_DIRECT_MEMORY"
|
<local:SettingRow x:Name="EnvLogDirectMemoryRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_LOG_DIRECT_MEMORY"
|
||||||
Description="Log direct memory allocations and failures to the console. Use when a game aborts or exits during boot.">
|
Description="{Binding [Options.Env.LogDirectMemory.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvLogDirectMemoryToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvLogDirectMemoryToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvLogIoRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_LOG_IO"
|
<local:SettingRow x:Name="EnvLogIoRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_LOG_IO"
|
||||||
Description="Log file open, read, and path-resolve activity to the console. Use when a game cannot find its data files during boot.">
|
Description="{Binding [Options.Env.LogIo.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvLogIoToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvLogIoToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
|
|
||||||
<local:SettingRow x:Name="EnvLogNpRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_LOG_NP"
|
<local:SettingRow x:Name="EnvLogNpRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_LOG_NP"
|
||||||
Description="Log NP (PlayStation Network) library calls to the console.">
|
Description="{Binding [Options.Env.LogNp.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
<ToggleSwitch x:Name="EnvLogNpToggle" OnContent="On" OffContent="Off"
|
<ToggleSwitch x:Name="EnvLogNpToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</local:SettingRow>
|
||||||
|
|
||||||
|
<local:SettingRow x:Name="EnvGuestImageCpuSyncRow" LabelFontFamily="Consolas,monospace" Label="SHARPEMU_GUEST_IMAGE_CPU_SYNC"
|
||||||
|
Description="{Binding [Options.Env.GuestImageCpuSync.Desc], Source={x:Static local:Localization.Instance}}">
|
||||||
|
<ToggleSwitch x:Name="EnvGuestImageCpuSyncToggle"
|
||||||
|
OnContent="{Binding [Common.On], Source={x:Static local:Localization.Instance}}"
|
||||||
|
OffContent="{Binding [Common.Off], Source={x:Static local:Localization.Instance}}"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
</local:SettingRow>
|
</local:SettingRow>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -496,22 +661,33 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
Margin="0,12,0,0" IsVisible="False">
|
Margin="0,12,0,0" IsVisible="False">
|
||||||
<Grid RowDefinitions="Auto,*">
|
<Grid RowDefinitions="Auto,*">
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="*,Auto,Auto,Auto,Auto,Auto" Margin="16,12,16,8">
|
<Grid Grid.Row="0" ColumnDefinitions="*,Auto,Auto,Auto,Auto,Auto" Margin="16,12,16,8">
|
||||||
<TextBlock x:Name="ConsoleSectionTitle" Classes="sectionTitle" Text="CONSOLE" VerticalAlignment="Center" />
|
<TextBlock x:Name="ConsoleSectionTitle" Classes="sectionTitle"
|
||||||
|
Text="{Binding [Console.Title], Source={x:Static local:Localization.Instance}}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
<TextBox Grid.Column="1" FontSize="12" Margin="0,0,12,0" x:Name="ConsoleSearchBox"
|
<TextBox Grid.Column="1" FontSize="12" Margin="0,0,12,0" x:Name="ConsoleSearchBox"
|
||||||
Watermark="Search..." Width="320" />
|
PlaceholderText="{Binding [Console.SearchWatermark], Source={x:Static local:Localization.Instance}}"
|
||||||
<CheckBox Grid.Column="2" x:Name="AutoScrollCheck" Content="Auto-scroll" IsChecked="True"
|
Width="320" />
|
||||||
|
<CheckBox Grid.Column="2" x:Name="AutoScrollCheck"
|
||||||
|
Content="{Binding [Console.AutoScroll], Source={x:Static local:Localization.Instance}}"
|
||||||
|
IsChecked="True"
|
||||||
FontSize="12" Margin="0,0,12,0" />
|
FontSize="12" Margin="0,0,12,0" />
|
||||||
<Button Grid.Column="3" x:Name="DetachConsoleButton" Classes="ghost" Content="Split" FontSize="12"
|
<Button Grid.Column="3" x:Name="DetachConsoleButton" Classes="ghost"
|
||||||
|
Content="{Binding [Console.Split], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="12"
|
||||||
Padding="10,4" Margin="0,0,8,0" />
|
Padding="10,4" Margin="0,0,8,0" />
|
||||||
<Button Grid.Column="4" x:Name="CopyLogButton" Classes="ghost" Content="Copy" FontSize="12"
|
<Button Grid.Column="4" x:Name="CopyLogButton" Classes="ghost"
|
||||||
|
Content="{Binding [Console.Copy], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="12"
|
||||||
Padding="10,4" Margin="0,0,8,0" />
|
Padding="10,4" Margin="0,0,8,0" />
|
||||||
<Button Grid.Column="5" x:Name="ClearLogButton" Classes="ghost" Content="Clear" FontSize="12"
|
<Button Grid.Column="5" x:Name="ClearLogButton" Classes="ghost"
|
||||||
|
Content="{Binding [Console.Clear], Source={x:Static local:Localization.Instance}}"
|
||||||
|
FontSize="12"
|
||||||
Padding="10,4" />
|
Padding="10,4" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<ListBox Grid.Row="1" x:Name="ConsoleList" Classes="console" BorderThickness="0,1,0,0"
|
<ListBox Grid.Row="1" x:Name="ConsoleList" Classes="console" BorderThickness="0,1,0,0"
|
||||||
BorderBrush="{StaticResource CardBorderBrush}" CornerRadius="0,0,12,12">
|
BorderBrush="{StaticResource CardBorderBrush}" CornerRadius="0,0,12,12">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate x:DataType="local:LogLine" x:CompileBindings="True">
|
||||||
<TextBlock Text="{Binding Text}" Foreground="{Binding Brush}" TextWrapping="NoWrap" />
|
<TextBlock Text="{Binding Text}" Foreground="{Binding Brush}" TextWrapping="NoWrap" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
@@ -527,7 +703,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<!-- Selected game cover thumbnail -->
|
<!-- Selected game cover thumbnail -->
|
||||||
<Border Grid.Column="0" Classes="coverClip" Width="56" Height="56" CornerRadius="8"
|
<Border Grid.Column="0" Classes="coverClip" Width="56" Height="56" CornerRadius="8"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center">
|
||||||
<Panel x:Name="SelectedCoverPanel">
|
<Panel x:Name="SelectedCoverPanel"
|
||||||
|
x:DataType="local:GameEntry"
|
||||||
|
x:CompileBindings="True">
|
||||||
<Border Background="{Binding PlaceholderBrush, FallbackValue={x:Null}}"
|
<Border Background="{Binding PlaceholderBrush, FallbackValue={x:Null}}"
|
||||||
IsVisible="{Binding !HasCover, FallbackValue=False}">
|
IsVisible="{Binding !HasCover, FallbackValue=False}">
|
||||||
<TextBlock Text="{Binding Initials}" FontSize="20" FontWeight="Bold"
|
<TextBlock Text="{Binding Initials}" FontSize="20" FontWeight="Bold"
|
||||||
@@ -548,7 +726,10 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<!-- Title id / version / size badges, right next to the
|
<!-- Title id / version / size badges, right next to the
|
||||||
title. The title's own MaxWidth (not a "*" column) is
|
title. The title's own MaxWidth (not a "*" column) is
|
||||||
what keeps them from drifting to the far right. -->
|
what keeps them from drifting to the far right. -->
|
||||||
<StackPanel Grid.Column="1" x:Name="SelectedBadgesRow" Orientation="Horizontal" Spacing="6"
|
<StackPanel Grid.Column="1" x:Name="SelectedBadgesRow"
|
||||||
|
x:DataType="local:GameEntry"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
Orientation="Horizontal" Spacing="6"
|
||||||
IsVisible="False" VerticalAlignment="Center">
|
IsVisible="False" VerticalAlignment="Center">
|
||||||
<Border Classes="pill" IsVisible="{Binding HasTitleId, FallbackValue=False}">
|
<Border Classes="pill" IsVisible="{Binding HasTitleId, FallbackValue=False}">
|
||||||
<TextBlock Text="{Binding TitleId}" FontSize="10" FontWeight="SemiBold"
|
<TextBlock Text="{Binding TitleId}" FontSize="10" FontWeight="SemiBold"
|
||||||
@@ -576,60 +757,22 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
||||||
<ToggleButton x:Name="ConsoleToggle" Classes="ghost" Content="≡ Console" />
|
<ToggleButton x:Name="ConsoleToggle" Classes="ghost"
|
||||||
<Button x:Name="LaunchButton" Classes="accent" Content="▶ Launch" IsEnabled="False" />
|
Content="{Binding [Launch.Console], Source={x:Static local:Localization.Instance}}" />
|
||||||
<Button x:Name="StopButton" Classes="danger" Content="■ Stop" IsEnabled="False" />
|
<Button x:Name="LaunchButton" Classes="accent"
|
||||||
|
Content="{Binding [Launch.Launch], Source={x:Static local:Localization.Instance}}"
|
||||||
|
IsEnabled="False" />
|
||||||
|
<Button x:Name="StopButton" Classes="danger"
|
||||||
|
Content="{Binding [Launch.Stop], Source={x:Static local:Localization.Instance}}"
|
||||||
|
IsEnabled="False" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Avalonia's regular overlay layer cannot appear over a native child
|
<!-- Keep launch progress above the blurred library while the SDL game
|
||||||
HWND/X11/Metal surface. Keep the running-session controls in a native
|
process owns its independent top-level window. -->
|
||||||
popup so the game reaches the bottom status bar without losing Stop. -->
|
|
||||||
<primitives:Popup x:Name="SessionBarPopup"
|
|
||||||
IsOpen="False"
|
|
||||||
PlacementTarget="{Binding #GameView}"
|
|
||||||
Placement="Bottom"
|
|
||||||
VerticalOffset="-66"
|
|
||||||
Topmost="True"
|
|
||||||
ShouldUseOverlayLayer="False"
|
|
||||||
TakesFocusFromNativeControl="False"
|
|
||||||
IsLightDismissEnabled="False">
|
|
||||||
<Border Classes="card" Width="598" Height="58" CornerRadius="16" Padding="14,8">
|
|
||||||
<Grid ColumnDefinitions="*,Auto">
|
|
||||||
<StackPanel Spacing="3" VerticalAlignment="Center">
|
|
||||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
|
||||||
<TextBlock x:Name="SessionGameTitle" Text="GAME RUNNING" FontSize="13" FontWeight="SemiBold"
|
|
||||||
MaxWidth="240" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
|
|
||||||
<Border Classes="badge running" VerticalAlignment="Center">
|
|
||||||
<TextBlock Text="RUNNING" FontSize="9" FontWeight="Bold" LetterSpacing="1"
|
|
||||||
Foreground="{StaticResource SuccessBrush}" />
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Orientation="Horizontal" Spacing="7">
|
|
||||||
<Border x:Name="SessionF11Badge" Classes="badge key" VerticalAlignment="Center">
|
|
||||||
<TextBlock Text="F11" FontSize="9" FontWeight="Bold"
|
|
||||||
Foreground="{StaticResource InfoBrush}" />
|
|
||||||
</Border>
|
|
||||||
<TextBlock x:Name="SessionHintText" Text="Fullscreen" FontSize="11"
|
|
||||||
Foreground="{StaticResource MutedBrush}" VerticalAlignment="Center" />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
|
||||||
<Button x:Name="SessionConsoleButton" Classes="ghost" Content="≡ Console" />
|
|
||||||
<Button x:Name="SessionStopButton" Classes="danger" Content="■ Stop" IsEnabled="False" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</primitives:Popup>
|
|
||||||
|
|
||||||
<!-- This is a native popup rather than an Avalonia overlay because the
|
|
||||||
emulated Vulkan surface is a native child window. -->
|
|
||||||
<!-- Anchored to MainContent, not GameView: the surface host is parked in
|
|
||||||
a 1x1 corner while loading/closing, which would pull a GameView-
|
|
||||||
anchored popup into the corner with it. -->
|
|
||||||
<primitives:Popup x:Name="SessionLoadingPopup"
|
<primitives:Popup x:Name="SessionLoadingPopup"
|
||||||
IsOpen="False"
|
IsOpen="False"
|
||||||
PlacementTarget="{Binding #MainContent}"
|
PlacementTarget="{Binding #MainContent}"
|
||||||
@@ -643,7 +786,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<TextBlock x:Name="SessionLoadingTitle" Text="Loading game" FontSize="16" FontWeight="SemiBold" />
|
<TextBlock x:Name="SessionLoadingTitle" Text="Loading game" FontSize="16" FontWeight="SemiBold" />
|
||||||
<TextBlock x:Name="SessionLoadingDetail" Text="Preparing the emulation session..." FontSize="12"
|
<TextBlock x:Name="SessionLoadingDetail" Text="Preparing the emulation session..." FontSize="12"
|
||||||
Foreground="{StaticResource MutedBrush}" TextTrimming="CharacterEllipsis" />
|
Foreground="{StaticResource MutedBrush}" TextTrimming="CharacterEllipsis" />
|
||||||
<ProgressBar IsIndeterminate="True" Height="5" />
|
<ProgressBar x:Name="SessionLoadingProgress" IsIndeterminate="True" Height="5" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</primitives:Popup>
|
</primitives:Popup>
|
||||||
@@ -657,5 +800,73 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<TextBlock x:Name="StatusBarRight" Grid.Column="1" Text="" FontSize="11"
|
<TextBlock x:Name="StatusBarRight" Grid.Column="1" Text="" FontSize="11"
|
||||||
Foreground="{StaticResource FaintBrush}" VerticalAlignment="Center" Margin="16,0" />
|
Foreground="{StaticResource FaintBrush}" VerticalAlignment="Center" Margin="16,0" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Portable resize hit targets for the frameless desktop window. They
|
||||||
|
are disabled while maximized or fullscreen in code-behind. -->
|
||||||
|
<Panel x:Name="ResizeHandles"
|
||||||
|
Grid.RowSpan="3"
|
||||||
|
ZIndex="1000"
|
||||||
|
IsVisible="False">
|
||||||
|
<Border Tag="North"
|
||||||
|
Height="6"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="TopSide"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="South"
|
||||||
|
Height="6"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="BottomSide"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="West"
|
||||||
|
Width="6"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="LeftSide"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="East"
|
||||||
|
Width="6"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="RightSide"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="NorthWest"
|
||||||
|
Width="12"
|
||||||
|
Height="12"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="TopLeftCorner"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="NorthEast"
|
||||||
|
Width="12"
|
||||||
|
Height="12"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="TopRightCorner"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="SouthWest"
|
||||||
|
Width="12"
|
||||||
|
Height="12"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="BottomLeftCorner"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
<Border Tag="SouthEast"
|
||||||
|
Width="12"
|
||||||
|
Height="12"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Background="#01000000"
|
||||||
|
Cursor="BottomRightCorner"
|
||||||
|
PointerPressed="OnResizeHandlePointerPressed" />
|
||||||
|
</Panel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,20 @@ public sealed class PerGameSettings
|
|||||||
|
|
||||||
public bool? LogToFile { get; set; }
|
public bool? LogToFile { get; set; }
|
||||||
|
|
||||||
|
public string? WindowMode { get; set; }
|
||||||
|
|
||||||
|
public string? Resolution { get; set; }
|
||||||
|
|
||||||
|
public int? DisplayIndex { get; set; }
|
||||||
|
|
||||||
|
public int? RefreshRate { get; set; }
|
||||||
|
|
||||||
|
public string? ScalingMode { get; set; }
|
||||||
|
|
||||||
|
public bool? VSync { get; set; }
|
||||||
|
|
||||||
|
public string? HdrMode { get; set; }
|
||||||
|
|
||||||
public List<string>? EnvironmentToggles { get; set; }
|
public List<string>? EnvironmentToggles { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
@@ -29,6 +43,13 @@ public sealed class PerGameSettings
|
|||||||
ImportTraceLimit is null &&
|
ImportTraceLimit is null &&
|
||||||
StrictDynlibResolution is null &&
|
StrictDynlibResolution is null &&
|
||||||
LogToFile is null &&
|
LogToFile is null &&
|
||||||
|
WindowMode is null &&
|
||||||
|
Resolution is null &&
|
||||||
|
DisplayIndex is null &&
|
||||||
|
RefreshRate is null &&
|
||||||
|
ScalingMode is null &&
|
||||||
|
VSync is null &&
|
||||||
|
HdrMode is null &&
|
||||||
EnvironmentToggles is null;
|
EnvironmentToggles is null;
|
||||||
|
|
||||||
public static string DirectoryPath =>
|
public static string DirectoryPath =>
|
||||||
@@ -116,6 +137,13 @@ public sealed record EffectiveLaunchSettings(
|
|||||||
int ImportTraceLimit,
|
int ImportTraceLimit,
|
||||||
bool StrictDynlibResolution,
|
bool StrictDynlibResolution,
|
||||||
bool LogToFile,
|
bool LogToFile,
|
||||||
|
string WindowMode,
|
||||||
|
string Resolution,
|
||||||
|
int DisplayIndex,
|
||||||
|
int RefreshRate,
|
||||||
|
string ScalingMode,
|
||||||
|
bool VSync,
|
||||||
|
string HdrMode,
|
||||||
IReadOnlyList<string> EnvironmentToggles)
|
IReadOnlyList<string> EnvironmentToggles)
|
||||||
{
|
{
|
||||||
public static EffectiveLaunchSettings Resolve(GuiSettings global, PerGameSettings? perGame) => new(
|
public static EffectiveLaunchSettings Resolve(GuiSettings global, PerGameSettings? perGame) => new(
|
||||||
@@ -123,5 +151,12 @@ public sealed record EffectiveLaunchSettings(
|
|||||||
perGame?.ImportTraceLimit ?? global.ImportTraceLimit,
|
perGame?.ImportTraceLimit ?? global.ImportTraceLimit,
|
||||||
perGame?.StrictDynlibResolution ?? global.StrictDynlibResolution,
|
perGame?.StrictDynlibResolution ?? global.StrictDynlibResolution,
|
||||||
perGame?.LogToFile ?? global.LogToFile,
|
perGame?.LogToFile ?? global.LogToFile,
|
||||||
|
perGame?.WindowMode ?? global.WindowMode,
|
||||||
|
perGame?.Resolution ?? global.Resolution,
|
||||||
|
Math.Max(0, perGame?.DisplayIndex ?? global.DisplayIndex),
|
||||||
|
Math.Clamp(perGame?.RefreshRate ?? global.RefreshRate, 0, 1000),
|
||||||
|
perGame?.ScalingMode ?? global.ScalingMode,
|
||||||
|
perGame?.VSync ?? global.VSync,
|
||||||
|
perGame?.HdrMode ?? global.HdrMode,
|
||||||
perGame?.EnvironmentToggles ?? global.EnvironmentToggles);
|
perGame?.EnvironmentToggles ?? global.EnvironmentToggles);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using SharpEmu.Libs.VideoOut;
|
||||||
|
|
||||||
namespace SharpEmu.GUI;
|
namespace SharpEmu.GUI;
|
||||||
|
|
||||||
@@ -12,6 +13,9 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
{
|
{
|
||||||
private static readonly string[] LogLevels =
|
private static readonly string[] LogLevels =
|
||||||
{ "Trace", "Debug", "Info", "Warning", "Error", "Critical" };
|
{ "Trace", "Debug", "Info", "Warning", "Error", "Critical" };
|
||||||
|
private static readonly string[] WindowModes = { "Windowed", "Borderless", "Exclusive" };
|
||||||
|
private static readonly string[] ScalingModes = { "Fit", "Cover", "Stretch", "Integer" };
|
||||||
|
private static readonly string[] HdrModes = { "Auto", "On", "Off" };
|
||||||
|
|
||||||
private static readonly string[] EnvToggles =
|
private static readonly string[] EnvToggles =
|
||||||
{
|
{
|
||||||
@@ -23,9 +27,12 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
"SHARPEMU_LOG_DIRECT_MEMORY",
|
"SHARPEMU_LOG_DIRECT_MEMORY",
|
||||||
"SHARPEMU_LOG_IO",
|
"SHARPEMU_LOG_IO",
|
||||||
"SHARPEMU_LOG_NP",
|
"SHARPEMU_LOG_NP",
|
||||||
|
"SHARPEMU_GUEST_IMAGE_CPU_SYNC",
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly string _titleId;
|
private readonly string _titleId;
|
||||||
|
private IReadOnlyList<HostDisplayOption> _hostDisplays = [];
|
||||||
|
private bool _updatingHostDisplayOptions;
|
||||||
|
|
||||||
private readonly SettingRow _logLevelRow;
|
private readonly SettingRow _logLevelRow;
|
||||||
private readonly ComboBox _logLevel = new() { ItemsSource = LogLevels, Width = 160 };
|
private readonly ComboBox _logLevel = new() { ItemsSource = LogLevels, Width = 160 };
|
||||||
@@ -42,6 +49,27 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
private readonly SettingRow _logToFileRow;
|
private readonly SettingRow _logToFileRow;
|
||||||
private readonly ToggleSwitch _logToFile = new();
|
private readonly ToggleSwitch _logToFile = new();
|
||||||
|
|
||||||
|
private readonly SettingRow _windowModeRow;
|
||||||
|
private readonly ComboBox _windowMode = new() { ItemsSource = WindowModes, Width = 160 };
|
||||||
|
|
||||||
|
private readonly SettingRow _resolutionRow;
|
||||||
|
private readonly ComboBox _resolution = new() { Width = 160 };
|
||||||
|
|
||||||
|
private readonly SettingRow _displayIndexRow;
|
||||||
|
private readonly ComboBox _displayIndex = new() { Width = 240 };
|
||||||
|
|
||||||
|
private readonly SettingRow _refreshRateRow;
|
||||||
|
private readonly ComboBox _refreshRate = new() { Width = 160 };
|
||||||
|
|
||||||
|
private readonly SettingRow _scalingModeRow;
|
||||||
|
private readonly ComboBox _scalingMode = new() { ItemsSource = ScalingModes, Width = 160 };
|
||||||
|
|
||||||
|
private readonly SettingRow _vsyncRow;
|
||||||
|
private readonly ToggleSwitch _vsync = new();
|
||||||
|
|
||||||
|
private readonly SettingRow _hdrModeRow;
|
||||||
|
private readonly ComboBox _hdrMode = new() { ItemsSource = HdrModes, Width = 160 };
|
||||||
|
|
||||||
private readonly SettingRow _envRow;
|
private readonly SettingRow _envRow;
|
||||||
private readonly StackPanel _envList = new() { Orientation = Orientation.Vertical, Spacing = 8, Margin = new(0, 4, 0, 0) };
|
private readonly StackPanel _envList = new() { Orientation = Orientation.Vertical, Spacing = 8, Margin = new(0, 4, 0, 0) };
|
||||||
private readonly List<(string Name, ToggleSwitch Box)> _envBoxes = new();
|
private readonly List<(string Name, ToggleSwitch Box)> _envBoxes = new();
|
||||||
@@ -60,13 +88,20 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
|
|
||||||
Background = new SolidColorBrush(Color.Parse("#0D1017"));
|
Background = new SolidColorBrush(Color.Parse("#0D1017"));
|
||||||
|
|
||||||
_strict.OnContent = _logToFile.OnContent = loc.Get("Common.On");
|
_strict.OnContent = _logToFile.OnContent = _vsync.OnContent = loc.Get("Common.On");
|
||||||
_strict.OffContent = _logToFile.OffContent = loc.Get("Common.Off");
|
_strict.OffContent = _logToFile.OffContent = _vsync.OffContent = loc.Get("Common.Off");
|
||||||
|
|
||||||
_logLevelRow = Row(loc.Get("Options.LogLevel.Label"), loc.Get("Options.LogLevel.Desc"), _logLevel);
|
_logLevelRow = Row(loc.Get("Options.LogLevel.Label"), loc.Get("Options.LogLevel.Desc"), _logLevel);
|
||||||
_traceRow = Row(loc.Get("Options.TraceImports.Label"), loc.Get("Options.TraceImports.Desc"), _trace);
|
_traceRow = Row(loc.Get("Options.TraceImports.Label"), loc.Get("Options.TraceImports.Desc"), _trace);
|
||||||
_strictRow = Row(loc.Get("Options.Strict.Label"), loc.Get("Options.Strict.Desc"), _strict);
|
_strictRow = Row(loc.Get("Options.Strict.Label"), loc.Get("Options.Strict.Desc"), _strict);
|
||||||
_logToFileRow = Row(loc.Get("Options.LogToFile.Label"), loc.Get("Options.LogToFile.Desc"), _logToFile);
|
_logToFileRow = Row(loc.Get("Options.LogToFile.Label"), loc.Get("Options.LogToFile.Desc"), _logToFile);
|
||||||
|
_windowModeRow = Row(loc.Get("Options.WindowMode.Label"), loc.Get("Options.WindowMode.Desc"), _windowMode);
|
||||||
|
_resolutionRow = Row(loc.Get("Options.Resolution.Label"), loc.Get("Options.Resolution.Desc"), _resolution);
|
||||||
|
_displayIndexRow = Row(loc.Get("Options.Display.Label"), loc.Get("Options.Display.Desc"), _displayIndex);
|
||||||
|
_refreshRateRow = Row(loc.Get("Options.RefreshRate.Label"), loc.Get("Options.RefreshRate.Desc"), _refreshRate);
|
||||||
|
_scalingModeRow = Row(loc.Get("Options.Scaling.Label"), loc.Get("Options.Scaling.Desc"), _scalingMode);
|
||||||
|
_vsyncRow = Row(loc.Get("Options.VSync.Label"), loc.Get("Options.VSync.Desc"), _vsync);
|
||||||
|
_hdrModeRow = Row(loc.Get("Options.Hdr.Label"), loc.Get("Options.Hdr.Desc"), _hdrMode);
|
||||||
_envRow = new SettingRow
|
_envRow = new SettingRow
|
||||||
{
|
{
|
||||||
Label = loc.Get("PerGame.EnvToggles.Label"),
|
Label = loc.Get("PerGame.EnvToggles.Label"),
|
||||||
@@ -81,6 +116,22 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
_envList.Children.Add(box);
|
_envList.Children.Add(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var general = new StackPanel { Orientation = Orientation.Vertical, Spacing = 12, Margin = new(0, 12, 0, 0) };
|
||||||
|
general.Children.Add(Card(loc.Get("Options.Section.Emulation"), _strictRow));
|
||||||
|
general.Children.Add(Card(loc.Get("Options.Section.Logging"), _logLevelRow, _traceRow, _logToFileRow));
|
||||||
|
general.Children.Add(Card(loc.Get("Options.Section.Environment"), _envRow, _envList));
|
||||||
|
|
||||||
|
var graphics = new StackPanel { Orientation = Orientation.Vertical, Spacing = 12, Margin = new(0, 12, 0, 0) };
|
||||||
|
graphics.Children.Add(Card(
|
||||||
|
loc.Get("Options.Section.Display"),
|
||||||
|
_windowModeRow,
|
||||||
|
_resolutionRow,
|
||||||
|
_displayIndexRow,
|
||||||
|
_refreshRateRow,
|
||||||
|
_scalingModeRow,
|
||||||
|
_vsyncRow,
|
||||||
|
_hdrModeRow));
|
||||||
|
|
||||||
var content = new StackPanel { Orientation = Orientation.Vertical, Spacing = 12, Margin = new(16) };
|
var content = new StackPanel { Orientation = Orientation.Vertical, Spacing = 12, Margin = new(16) };
|
||||||
content.Children.Add(new TextBlock
|
content.Children.Add(new TextBlock
|
||||||
{
|
{
|
||||||
@@ -88,9 +139,14 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
Foreground = new SolidColorBrush(Color.Parse("#8B94A7")),
|
Foreground = new SolidColorBrush(Color.Parse("#8B94A7")),
|
||||||
FontSize = 12,
|
FontSize = 12,
|
||||||
});
|
});
|
||||||
content.Children.Add(Card(loc.Get("Options.Section.Emulation"), _strictRow));
|
content.Children.Add(new TabControl
|
||||||
content.Children.Add(Card(loc.Get("Options.Section.Logging"), _logLevelRow, _traceRow, _logToFileRow));
|
{
|
||||||
content.Children.Add(Card(loc.Get("Options.Section.Environment"), _envRow, _envList));
|
ItemsSource = new[]
|
||||||
|
{
|
||||||
|
new TabItem { Header = loc.Get("PerGame.Tab.General"), Content = general },
|
||||||
|
new TabItem { Header = loc.Get("PerGame.Tab.Graphics"), Content = graphics },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
var save = new Button { Content = loc.Get("Common.Save"), Classes = { "accent" } };
|
var save = new Button { Content = loc.Get("Common.Save"), Classes = { "accent" } };
|
||||||
var cancel = new Button { Content = loc.Get("Common.Cancel"), Classes = { "ghost" } };
|
var cancel = new Button { Content = loc.Get("Common.Cancel"), Classes = { "ghost" } };
|
||||||
@@ -119,6 +175,8 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
root.Children.Add(buttonBar);
|
root.Children.Add(buttonBar);
|
||||||
Content = root;
|
Content = root;
|
||||||
|
|
||||||
|
_displayIndex.SelectionChanged += (_, _) => OnHostDisplayChanged();
|
||||||
|
_resolution.SelectionChanged += (_, _) => OnHostResolutionChanged();
|
||||||
LoadValues(global);
|
LoadValues(global);
|
||||||
_envRow.PropertyChanged += (_, e) =>
|
_envRow.PropertyChanged += (_, e) =>
|
||||||
{
|
{
|
||||||
@@ -154,16 +212,38 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
|
|
||||||
private void LoadValues(GuiSettings global)
|
private void LoadValues(GuiSettings global)
|
||||||
{
|
{
|
||||||
|
var existing = PerGameSettings.Load(_titleId);
|
||||||
|
var displayIndex = Math.Max(0, existing?.DisplayIndex ?? global.DisplayIndex);
|
||||||
|
var resolution = existing?.Resolution ?? global.Resolution;
|
||||||
|
var refreshRate = Math.Clamp(existing?.RefreshRate ?? global.RefreshRate, 0, 1000);
|
||||||
|
|
||||||
|
_updatingHostDisplayOptions = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_hostDisplays = HostDisplayOptions.BuildDisplays(HostDisplayCatalog.Query(), displayIndex);
|
||||||
|
_displayIndex.ItemsSource = _hostDisplays;
|
||||||
|
var display = HostDisplayOptions.SelectDisplay(_hostDisplays, displayIndex);
|
||||||
|
_displayIndex.SelectedItem = display;
|
||||||
|
PopulateHostModes(display, resolution, refreshRate);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_updatingHostDisplayOptions = false;
|
||||||
|
}
|
||||||
|
|
||||||
_logLevel.SelectedItem = Array.IndexOf(LogLevels, global.LogLevel) >= 0 ? global.LogLevel : "Info";
|
_logLevel.SelectedItem = Array.IndexOf(LogLevels, global.LogLevel) >= 0 ? global.LogLevel : "Info";
|
||||||
_trace.Value = global.ImportTraceLimit;
|
_trace.Value = global.ImportTraceLimit;
|
||||||
_strict.IsChecked = global.StrictDynlibResolution;
|
_strict.IsChecked = global.StrictDynlibResolution;
|
||||||
_logToFile.IsChecked = global.LogToFile;
|
_logToFile.IsChecked = global.LogToFile;
|
||||||
|
_windowMode.SelectedItem = ChoiceOrDefault(WindowModes, global.WindowMode, "Windowed");
|
||||||
|
_scalingMode.SelectedItem = ChoiceOrDefault(ScalingModes, global.ScalingMode, "Fit");
|
||||||
|
_vsync.IsChecked = global.VSync;
|
||||||
|
_hdrMode.SelectedItem = ChoiceOrDefault(HdrModes, global.HdrMode, "Auto");
|
||||||
foreach (var (name, box) in _envBoxes)
|
foreach (var (name, box) in _envBoxes)
|
||||||
{
|
{
|
||||||
box.IsChecked = global.EnvironmentToggles.Contains(name);
|
box.IsChecked = IsEnvironmentEnabled(global.EnvironmentToggles, name, defaultValue: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var existing = PerGameSettings.Load(_titleId);
|
|
||||||
if (existing is null)
|
if (existing is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -178,16 +258,120 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
if (existing.ImportTraceLimit is { } t) { _traceRow.IsOverridden = true; _trace.Value = t; }
|
if (existing.ImportTraceLimit is { } t) { _traceRow.IsOverridden = true; _trace.Value = t; }
|
||||||
if (existing.StrictDynlibResolution is { } s) { _strictRow.IsOverridden = true; _strict.IsChecked = s; }
|
if (existing.StrictDynlibResolution is { } s) { _strictRow.IsOverridden = true; _strict.IsChecked = s; }
|
||||||
if (existing.LogToFile is { } l) { _logToFileRow.IsOverridden = true; _logToFile.IsChecked = l; }
|
if (existing.LogToFile is { } l) { _logToFileRow.IsOverridden = true; _logToFile.IsChecked = l; }
|
||||||
|
if (existing.WindowMode is { } windowMode && WindowModes.Contains(windowMode, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_windowModeRow.IsOverridden = true;
|
||||||
|
_windowMode.SelectedItem = ChoiceOrDefault(WindowModes, windowMode, "Windowed");
|
||||||
|
}
|
||||||
|
if (existing.Resolution is not null)
|
||||||
|
{
|
||||||
|
_resolutionRow.IsOverridden = true;
|
||||||
|
}
|
||||||
|
if (existing.DisplayIndex is not null)
|
||||||
|
{
|
||||||
|
_displayIndexRow.IsOverridden = true;
|
||||||
|
}
|
||||||
|
if (existing.RefreshRate is not null)
|
||||||
|
{
|
||||||
|
_refreshRateRow.IsOverridden = true;
|
||||||
|
}
|
||||||
|
if (existing.ScalingMode is { } scalingMode && ScalingModes.Contains(scalingMode, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_scalingModeRow.IsOverridden = true;
|
||||||
|
_scalingMode.SelectedItem = ChoiceOrDefault(ScalingModes, scalingMode, "Fit");
|
||||||
|
}
|
||||||
|
if (existing.VSync is { } vsync)
|
||||||
|
{
|
||||||
|
_vsyncRow.IsOverridden = true;
|
||||||
|
_vsync.IsChecked = vsync;
|
||||||
|
}
|
||||||
|
if (existing.HdrMode is { } hdrMode && HdrModes.Contains(hdrMode, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_hdrModeRow.IsOverridden = true;
|
||||||
|
_hdrMode.SelectedItem = ChoiceOrDefault(HdrModes, hdrMode, "Auto");
|
||||||
|
}
|
||||||
if (existing.EnvironmentToggles is { } env)
|
if (existing.EnvironmentToggles is { } env)
|
||||||
{
|
{
|
||||||
_envRow.IsOverridden = true;
|
_envRow.IsOverridden = true;
|
||||||
foreach (var (name, box) in _envBoxes)
|
foreach (var (name, box) in _envBoxes)
|
||||||
{
|
{
|
||||||
box.IsChecked = env.Contains(name);
|
box.IsChecked = IsEnvironmentEnabled(env, name, defaultValue: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string ChoiceOrDefault(string[] choices, string? value, string fallback) =>
|
||||||
|
choices.FirstOrDefault(choice => string.Equals(choice, value, StringComparison.OrdinalIgnoreCase)) ?? fallback;
|
||||||
|
|
||||||
|
private void OnHostDisplayChanged()
|
||||||
|
{
|
||||||
|
if (_updatingHostDisplayOptions || _displayIndex.SelectedItem is not HostDisplayOption display)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_updatingHostDisplayOptions = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PopulateHostModes(
|
||||||
|
display,
|
||||||
|
_resolution.SelectedItem as string ?? "1920x1080",
|
||||||
|
SelectedRefreshRate());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_updatingHostDisplayOptions = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnHostResolutionChanged()
|
||||||
|
{
|
||||||
|
if (_updatingHostDisplayOptions || _displayIndex.SelectedItem is not HostDisplayOption display)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedRefreshRate = SelectedRefreshRate();
|
||||||
|
_updatingHostDisplayOptions = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PopulateRefreshRates(display, _resolution.SelectedItem as string, selectedRefreshRate);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_updatingHostDisplayOptions = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateHostModes(
|
||||||
|
HostDisplayOption display,
|
||||||
|
string selectedResolution,
|
||||||
|
int selectedRefreshRate)
|
||||||
|
{
|
||||||
|
var resolutions = HostDisplayOptions.BuildResolutions(display, selectedResolution);
|
||||||
|
_resolution.ItemsSource = resolutions;
|
||||||
|
_resolution.SelectedItem = resolutions.FirstOrDefault(resolution =>
|
||||||
|
string.Equals(resolution, selectedResolution, StringComparison.OrdinalIgnoreCase)) ?? resolutions[0];
|
||||||
|
PopulateRefreshRates(display, _resolution.SelectedItem as string, selectedRefreshRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateRefreshRates(
|
||||||
|
HostDisplayOption display,
|
||||||
|
string? resolution,
|
||||||
|
int selectedRefreshRate)
|
||||||
|
{
|
||||||
|
var rates = HostDisplayOptions.BuildRefreshRates(
|
||||||
|
display,
|
||||||
|
resolution,
|
||||||
|
selectedRefreshRate,
|
||||||
|
Localization.Instance.Get("Options.RefreshRate.Automatic"));
|
||||||
|
_refreshRate.ItemsSource = rates;
|
||||||
|
_refreshRate.SelectedItem = rates.FirstOrDefault(rate => rate.Value == selectedRefreshRate) ?? rates[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private int SelectedRefreshRate() =>
|
||||||
|
_refreshRate.SelectedItem is HostRefreshRateOption refreshRate ? refreshRate.Value : 0;
|
||||||
|
|
||||||
private void Persist()
|
private void Persist()
|
||||||
{
|
{
|
||||||
var settings = new PerGameSettings
|
var settings = new PerGameSettings
|
||||||
@@ -196,10 +380,47 @@ public sealed class PerGameSettingsDialog : Window
|
|||||||
ImportTraceLimit = _traceRow.IsOverridden ? (int)(_trace.Value ?? 0) : null,
|
ImportTraceLimit = _traceRow.IsOverridden ? (int)(_trace.Value ?? 0) : null,
|
||||||
StrictDynlibResolution = _strictRow.IsOverridden ? _strict.IsChecked == true : null,
|
StrictDynlibResolution = _strictRow.IsOverridden ? _strict.IsChecked == true : null,
|
||||||
LogToFile = _logToFileRow.IsOverridden ? _logToFile.IsChecked == true : null,
|
LogToFile = _logToFileRow.IsOverridden ? _logToFile.IsChecked == true : null,
|
||||||
EnvironmentToggles = _envRow.IsOverridden
|
WindowMode = _windowModeRow.IsOverridden ? _windowMode.SelectedItem as string : null,
|
||||||
? _envBoxes.Where(e => e.Box.IsChecked == true).Select(e => e.Name).ToList()
|
Resolution = _resolutionRow.IsOverridden ? _resolution.SelectedItem as string : null,
|
||||||
|
DisplayIndex = _displayIndexRow.IsOverridden && _displayIndex.SelectedItem is HostDisplayOption display
|
||||||
|
? display.Index
|
||||||
: null,
|
: null,
|
||||||
|
RefreshRate = _refreshRateRow.IsOverridden ? SelectedRefreshRate() : null,
|
||||||
|
ScalingMode = _scalingModeRow.IsOverridden ? _scalingMode.SelectedItem as string : null,
|
||||||
|
VSync = _vsyncRow.IsOverridden ? _vsync.IsChecked == true : null,
|
||||||
|
HdrMode = _hdrModeRow.IsOverridden ? _hdrMode.SelectedItem as string : null,
|
||||||
|
EnvironmentToggles = _envRow.IsOverridden ? BuildEnvironmentEntries() : null,
|
||||||
};
|
};
|
||||||
settings.Save(_titleId);
|
settings.Save(_titleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<string> BuildEnvironmentEntries()
|
||||||
|
{
|
||||||
|
return _envBoxes
|
||||||
|
.Where(entry => entry.Box.IsChecked == true)
|
||||||
|
.Select(entry => entry.Name)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsEnvironmentEnabled(
|
||||||
|
IEnumerable<string> entries,
|
||||||
|
string name,
|
||||||
|
bool defaultValue)
|
||||||
|
{
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
if (string.Equals(entry, name + "=0", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(entry, name, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(entry, name + "=1", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,15 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
the executable is started without arguments. -->
|
the executable is started without arguments. -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||||
<!-- Required by the source-generated LibraryImport stubs in the linked
|
|
||||||
controller readers below. -->
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Dependency-free; provides the BuildInfo provenance shown in the
|
<!-- Dependency-free; provides the BuildInfo provenance shown in the
|
||||||
title bar. -->
|
title bar. -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- The GUI owns the native presentation control while each game runs in
|
<!-- Games run in isolated SDL-window processes; the GUI owns launch and
|
||||||
an isolated emulator process. -->
|
session controls only. -->
|
||||||
|
<ProjectReference Include="..\SharpEmu.LibAtrac9\SharpEmu.LibAtrac9.csproj" />
|
||||||
<ProjectReference Include="..\SharpEmu.Core\SharpEmu.Core.csproj" />
|
<ProjectReference Include="..\SharpEmu.Core\SharpEmu.Core.csproj" />
|
||||||
<ProjectReference Include="..\SharpEmu.Libs\SharpEmu.Libs.csproj" />
|
<ProjectReference Include="..\SharpEmu.Libs\SharpEmu.Libs.csproj" />
|
||||||
<ProjectReference Include="..\SharpEmu.Logging\SharpEmu.Logging.csproj" />
|
<ProjectReference Include="..\SharpEmu.Logging\SharpEmu.Logging.csproj" />
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Window and text defaults shared by all launcher views.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="Window">
|
||||||
|
<Setter Property="FontFamily" Value="Inter, Segoe UI, sans-serif" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBlock.sectionTitle">
|
||||||
|
<Setter Property="FontSize" Value="11" />
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold" />
|
||||||
|
<Setter Property="LetterSpacing" Value="1.5" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource MutedBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBlock.fieldLabel">
|
||||||
|
<Setter Property="FontSize" Value="12" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource MutedBrush}" />
|
||||||
|
<Setter Property="Margin" Value="0,0,0,6" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Shared launcher button variants and page switcher styles.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="Button.accent">
|
||||||
|
<Setter Property="Background" Value="{StaticResource AccentBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold" />
|
||||||
|
<Setter Property="Padding" Value="22,10" />
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.accent:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource AccentHoverBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Button.danger">
|
||||||
|
<Setter Property="Background" Value="{StaticResource DangerBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold" />
|
||||||
|
<Setter Property="Padding" Value="22,10" />
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.danger:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource DangerHoverBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Button.ghost">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
<Setter Property="Padding" Value="12,7" />
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.ghost:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="ToggleButton.ghost">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
<Setter Property="Padding" Value="12,7" />
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ToggleButton.ghost:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ToggleButton.ghost:checked /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Top-level page switcher (Library / Options): plain transparent
|
||||||
|
buttons, not TabItem, so there is no Fluent selected-tab underline.
|
||||||
|
The active page is conveyed by brightness alone; LB/RB gamepad
|
||||||
|
hints flank the pair. -->
|
||||||
|
<Style Selector="Button.segment">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource MutedBrush}" />
|
||||||
|
<Setter Property="FontSize" Value="22" />
|
||||||
|
<Setter Property="FontWeight" Value="Bold" />
|
||||||
|
<Setter Property="Padding" Value="6,4" />
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.segment:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.segment.active">
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Window chrome button sizing and interaction states.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="Button.windowChrome">
|
||||||
|
<Setter Property="Width" Value="46" />
|
||||||
|
<Setter Property="Height" Value="44" />
|
||||||
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
<Setter Property="MinHeight" Value="0" />
|
||||||
|
<Setter Property="Padding" Value="0" />
|
||||||
|
<Setter Property="CornerRadius" Value="0" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.windowChrome:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource TextBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button.windowClose:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource DangerBrush}" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Console list typography and compact item spacing.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="ListBox.console">
|
||||||
|
<Setter Property="Background" Value="#0B0E14" />
|
||||||
|
<Setter Property="FontFamily" Value="Cascadia Mono, Consolas, Courier New, monospace" />
|
||||||
|
<Setter Property="FontSize" Value="12" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox.console ListBoxItem">
|
||||||
|
<Setter Property="Padding" Value="10,1" />
|
||||||
|
<Setter Property="MinHeight" Value="0" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Shared text input and context-menu styles.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="TextBox">
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="ContextMenu">
|
||||||
|
<Setter Property="Background" Value="{StaticResource CardBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="CornerRadius" Value="10" />
|
||||||
|
<Setter Property="Padding" Value="6" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ContextMenu MenuItem">
|
||||||
|
<Setter Property="Padding" Value="10,7" />
|
||||||
|
<Setter Property="CornerRadius" Value="7" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ContextMenu Separator">
|
||||||
|
<Setter Property="Background" Value="{StaticResource CardBorderBrush}" />
|
||||||
|
<Setter Property="Height" Value="1" />
|
||||||
|
<Setter Property="Margin" Value="8,4" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Cover-art library item states and motion.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="ListBox.tileGrid ListBoxItem">
|
||||||
|
<Setter Property="Padding" Value="10" />
|
||||||
|
<Setter Property="Margin" Value="5" />
|
||||||
|
<Setter Property="CornerRadius" Value="14" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="RenderTransform" Value="translateY(0px)" />
|
||||||
|
<Setter Property="Transitions">
|
||||||
|
<Transitions>
|
||||||
|
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.12" />
|
||||||
|
</Transitions>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox.tileGrid ListBoxItem:pointerover">
|
||||||
|
<Setter Property="RenderTransform" Value="translateY(-3px)" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox.tileGrid ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource TileHoverBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox.tileGrid ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource TileSelectedBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBox.tileGrid ListBoxItem:selected:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{StaticResource TileSelectedBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource AccentHoverBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Shared card, badge, hint and cover surfaces.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Style Selector="Border.card">
|
||||||
|
<Setter Property="Background" Value="{StaticResource CardBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{StaticResource CardBorderBrush}" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="CornerRadius" Value="12" />
|
||||||
|
<Setter Property="Padding" Value="16" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Border.pill">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="CornerRadius" Value="999" />
|
||||||
|
<Setter Property="Padding" Value="10,3" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Session status/hotkey badges: the title-id pill geometry with a
|
||||||
|
tinted fill so state (RUNNING) and keys (F11) read at a glance. -->
|
||||||
|
<Style Selector="Border.badge">
|
||||||
|
<Setter Property="CornerRadius" Value="999" />
|
||||||
|
<Setter Property="Padding" Value="8,2" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Border.badge.running">
|
||||||
|
<Setter Property="Background" Value="#1E46C46B" />
|
||||||
|
<Setter Property="BorderBrush" Value="#5546C46B" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Border.badge.key">
|
||||||
|
<Setter Property="Background" Value="#1E58A6FF" />
|
||||||
|
<Setter Property="BorderBrush" Value="#5558A6FF" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- Gamepad shoulder-button hint chip (LB/RB, L1/R1). -->
|
||||||
|
<Style Selector="Border.padHint">
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
<Setter Property="CornerRadius" Value="6" />
|
||||||
|
<Setter Property="Padding" Value="8,3" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Border.coverShadow">
|
||||||
|
<Setter Property="CornerRadius" Value="10" />
|
||||||
|
<Setter Property="BoxShadow" Value="0 6 14 0 #55000000" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Border.coverClip">
|
||||||
|
<Setter Property="CornerRadius" Value="10" />
|
||||||
|
<Setter Property="ClipToBounds" Value="True" />
|
||||||
|
<Setter Property="Background" Value="{StaticResource ElevatedBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Control theme for the shared launcher settings row.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:SharpEmu.GUI">
|
||||||
|
<ControlTheme x:Key="{x:Type local:SettingRow}" TargetType="local:SettingRow">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<StackPanel VerticalAlignment="Center" Spacing="2" Margin="0,0,16,0">
|
||||||
|
<TextBlock x:Name="PART_Label" Text="{TemplateBinding Label}" FontSize="13" />
|
||||||
|
<TextBlock Text="{TemplateBinding Description}" FontSize="11"
|
||||||
|
Foreground="{StaticResource MutedBrush}" TextWrapping="Wrap"
|
||||||
|
IsVisible="{Binding Description, RelativeSource={RelativeSource TemplatedParent},
|
||||||
|
Converter={x:Static StringConverters.IsNotNullOrEmpty}}" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="10" VerticalAlignment="Center">
|
||||||
|
<ToggleSwitch OnContent="Override" OffContent="Override" MinWidth="0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
IsVisible="{TemplateBinding ShowOverride}"
|
||||||
|
IsChecked="{Binding IsOverridden, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
|
||||||
|
<ContentPresenter x:Name="PART_Slot"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
Shared colors and brushes used throughout the launcher.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Color x:Key="SystemAccentColor">#7C5CFC</Color>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="BgBrush" StartPoint="0%,0%" EndPoint="100%,100%">
|
||||||
|
<GradientStop Offset="0" Color="#12151F" />
|
||||||
|
<GradientStop Offset="0.55" Color="#0D1017" />
|
||||||
|
<GradientStop Offset="1" Color="#0B0D14" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="ChromeBrush" Color="#090C12" />
|
||||||
|
<SolidColorBrush x:Key="CardBrush" Color="#141924" />
|
||||||
|
<SolidColorBrush x:Key="CardBorderBrush" Color="#232B3A" />
|
||||||
|
<SolidColorBrush x:Key="ElevatedBrush" Color="#1B2230" />
|
||||||
|
<SolidColorBrush x:Key="TextBrush" Color="#E8ECF4" />
|
||||||
|
<SolidColorBrush x:Key="MutedBrush" Color="#8B94A7" />
|
||||||
|
<SolidColorBrush x:Key="FaintBrush" Color="#5A6478" />
|
||||||
|
<SolidColorBrush x:Key="AccentBrush" Color="#7C5CFC" />
|
||||||
|
<SolidColorBrush x:Key="AccentHoverBrush" Color="#8F73FF" />
|
||||||
|
<SolidColorBrush x:Key="DangerBrush" Color="#E5484D" />
|
||||||
|
<SolidColorBrush x:Key="DangerHoverBrush" Color="#F2555A" />
|
||||||
|
<SolidColorBrush x:Key="SuccessBrush" Color="#46C46B" />
|
||||||
|
<SolidColorBrush x:Key="InfoBrush" Color="#58A6FF" />
|
||||||
|
<SolidColorBrush x:Key="TileHoverBrush" Color="#1A2130" />
|
||||||
|
<SolidColorBrush x:Key="TileSelectedBrush" Color="#212A3F" />
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -20,6 +20,15 @@ public sealed class CpuContext(ICpuMemory memory, Generation generation)
|
|||||||
|
|
||||||
public ulong Rip { get; set; }
|
public ulong Rip { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Index of the import this context is currently executing, or -1 when it is
|
||||||
|
/// running guest code. Only maintained while guest profiling is enabled;
|
||||||
|
/// <see cref="Rip"/> alone cannot answer "what is this thread inside right
|
||||||
|
/// now" because it keeps pointing at the last import stub after the call
|
||||||
|
/// returns.
|
||||||
|
/// </summary>
|
||||||
|
public int ActiveImportIndex { get; set; } = -1;
|
||||||
|
|
||||||
public ulong Rflags { get; set; }
|
public ulong Rflags { get; set; }
|
||||||
|
|
||||||
public ulong FsBase { get; set; }
|
public ulong FsBase { get; set; }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -30,6 +31,12 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
public ulong End;
|
public ulong End;
|
||||||
public int Dirty;
|
public int Dirty;
|
||||||
public int Armed;
|
public int Armed;
|
||||||
|
/// <summary>
|
||||||
|
/// When false the range is watch-only: managed writes still dirty it via
|
||||||
|
/// <see cref="NotifyManagedWrite"/>, but pages are never write-protected
|
||||||
|
/// so native CPU stores do not fault.
|
||||||
|
/// </summary>
|
||||||
|
public bool Protect;
|
||||||
public int FirstCpuWriteSeen;
|
public int FirstCpuWriteSeen;
|
||||||
public int PendingFirstCpuWrite;
|
public int PendingFirstCpuWrite;
|
||||||
public long WriteGeneration;
|
public long WriteGeneration;
|
||||||
@@ -80,8 +87,11 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
|
|
||||||
private static RangeSnapshot _rangeSnapshot = RangeSnapshot.Empty;
|
private static RangeSnapshot _rangeSnapshot = RangeSnapshot.Empty;
|
||||||
|
|
||||||
private static readonly bool _enabled = !OperatingSystem.IsWindows() &&
|
private static readonly bool _enabled =
|
||||||
Environment.GetEnvironmentVariable("SHARPEMU_GUEST_IMAGE_CPU_SYNC") != "0";
|
string.Equals(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_GUEST_IMAGE_CPU_SYNC"),
|
||||||
|
"1",
|
||||||
|
StringComparison.Ordinal);
|
||||||
private static readonly (bool Wildcard, ulong[] Addresses) _lifetimeTraceFilter =
|
private static readonly (bool Wildcard, ulong[] Addresses) _lifetimeTraceFilter =
|
||||||
ParseAddressList(Environment.GetEnvironmentVariable("SHARPEMU_TRACE_GUEST_IMAGE_ADDRS"));
|
ParseAddressList(Environment.GetEnvironmentVariable("SHARPEMU_TRACE_GUEST_IMAGE_ADDRS"));
|
||||||
private static readonly (bool Wildcard, string[] Sources) _lifetimeSourceTraceFilter =
|
private static readonly (bool Wildcard, string[] Sources) _lifetimeSourceTraceFilter =
|
||||||
@@ -95,14 +105,67 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
_enabled && _lifetimeTraceEnabled ? GetMonotonicNanoseconds() : 0;
|
_enabled && _lifetimeTraceEnabled ? GetMonotonicNanoseconds() : 0;
|
||||||
private static long _lifetimeTraceSequence;
|
private static long _lifetimeTraceSequence;
|
||||||
|
|
||||||
|
private const uint PageReadonly = 0x02;
|
||||||
|
private const uint PageReadWrite = 0x04;
|
||||||
|
|
||||||
[DllImport("libc", EntryPoint = "mprotect", SetLastError = true)]
|
[DllImport("libc", EntryPoint = "mprotect", SetLastError = true)]
|
||||||
private static extern int Mprotect(nint address, nuint length, int protection);
|
private static extern int Mprotect(nint address, nuint length, int protection);
|
||||||
|
|
||||||
[DllImport("libc", EntryPoint = "clock_gettime", SetLastError = false)]
|
[DllImport("libc", EntryPoint = "clock_gettime", SetLastError = false)]
|
||||||
private static extern int ClockGetTime(int clockId, Timespec* time);
|
private static extern int ClockGetTime(int clockId, Timespec* time);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern int VirtualProtect(
|
||||||
|
nint lpAddress,
|
||||||
|
nuint dwSize,
|
||||||
|
uint flNewProtect,
|
||||||
|
out uint lpflOldProtect);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern nint VirtualAlloc(
|
||||||
|
nint lpAddress,
|
||||||
|
nuint dwSize,
|
||||||
|
uint flAllocationType,
|
||||||
|
uint flProtect);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern int VirtualFree(nint lpAddress, nuint dwSize, uint dwFreeType);
|
||||||
|
|
||||||
|
private const uint MemCommit = 0x1000;
|
||||||
|
private const uint MemReserve = 0x2000;
|
||||||
|
private const uint MemRelease = 0x8000;
|
||||||
|
|
||||||
public static bool Enabled => _enabled;
|
public static bool Enabled => _enabled;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test/diagnostics helper: whether <paramref name="address"/> is tracked
|
||||||
|
/// with write protection armed (watch-only ranges report protect=false).
|
||||||
|
/// </summary>
|
||||||
|
public static bool TryGetProtectionState(
|
||||||
|
ulong address,
|
||||||
|
out bool protect,
|
||||||
|
out bool armed)
|
||||||
|
{
|
||||||
|
protect = false;
|
||||||
|
armed = false;
|
||||||
|
if (!_enabled)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_gate)
|
||||||
|
{
|
||||||
|
if (!_rangesByAddress.TryGetValue(address, out var range))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protect = range.Protect;
|
||||||
|
armed = Volatile.Read(ref range.Armed) != 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exercises the fault-handling path once outside signal context so every
|
/// Exercises the fault-handling path once outside signal context so every
|
||||||
/// branch is JIT-compiled (and, under Rosetta 2, translated) before a real
|
/// branch is JIT-compiled (and, under Rosetta 2, translated) before a real
|
||||||
@@ -115,7 +178,17 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var scratch = NativeMemory.AllocZeroed(4096);
|
// VirtualProtect only belongs on VirtualAlloc/mmap pages. Warming on
|
||||||
|
// CRT heap memory makes neighbouring heap metadata read-only and
|
||||||
|
// crashes the process on Windows.
|
||||||
|
var scratch = OperatingSystem.IsWindows()
|
||||||
|
? VirtualAlloc(0, 4096, MemCommit | MemReserve, PageReadWrite)
|
||||||
|
: (nint)NativeMemory.AllocZeroed(4096);
|
||||||
|
if (scratch == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Warm the timestamp P/Invoke used by the signal-safe scalar
|
// Warm the timestamp P/Invoke used by the signal-safe scalar
|
||||||
@@ -129,16 +202,29 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
NativeMemory.Free(scratch);
|
if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
_ = VirtualFree(scratch, 0, MemRelease);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NativeMemory.Free((void*)scratch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Registers a range and arms write protection on it.</summary>
|
/// <summary>
|
||||||
|
/// Registers a range. When <paramref name="protect"/> is true, arms write
|
||||||
|
/// protection so native stores fault and mark the range dirty. When false,
|
||||||
|
/// the range is watch-only (managed HLE writes still dirty via
|
||||||
|
/// <see cref="NotifyManagedWrite"/>) and never <c>VirtualProtect</c>'d.
|
||||||
|
/// </summary>
|
||||||
public static void Track(
|
public static void Track(
|
||||||
ulong address,
|
ulong address,
|
||||||
ulong byteCount,
|
ulong byteCount,
|
||||||
long sourceSequence = 0,
|
long sourceSequence = 0,
|
||||||
string source = "unspecified")
|
string source = "unspecified",
|
||||||
|
bool protect = true)
|
||||||
{
|
{
|
||||||
if (!_enabled || address == 0 || byteCount == 0)
|
if (!_enabled || address == 0 || byteCount == 0)
|
||||||
{
|
{
|
||||||
@@ -159,6 +245,7 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
// a fresh immutable range, carrying the write generation so
|
// a fresh immutable range, carrying the write generation so
|
||||||
// resizes do not hide guest CPU rewrites from cache owners.
|
// resizes do not hide guest CPU rewrites from cache owners.
|
||||||
var writeGeneration = Volatile.Read(ref range.WriteGeneration);
|
var writeGeneration = Volatile.Read(ref range.WriteGeneration);
|
||||||
|
var keepProtect = range.Protect || protect;
|
||||||
DisarmLocked(range, "replace-range");
|
DisarmLocked(range, "replace-range");
|
||||||
_rangesByAddress.Remove(address);
|
_rangesByAddress.Remove(address);
|
||||||
range = new TrackedRange
|
range = new TrackedRange
|
||||||
@@ -167,6 +254,7 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
ByteCount = byteCount,
|
ByteCount = byteCount,
|
||||||
Start = start,
|
Start = start,
|
||||||
End = start + length,
|
End = start + length,
|
||||||
|
Protect = keepProtect,
|
||||||
WriteGeneration = writeGeneration,
|
WriteGeneration = writeGeneration,
|
||||||
};
|
};
|
||||||
_rangesByAddress[address] = range;
|
_rangesByAddress[address] = range;
|
||||||
@@ -181,6 +269,7 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
ByteCount = byteCount,
|
ByteCount = byteCount,
|
||||||
Start = start,
|
Start = start,
|
||||||
End = start + length,
|
End = start + length,
|
||||||
|
Protect = protect,
|
||||||
TraceLifetime =
|
TraceLifetime =
|
||||||
ShouldTraceRange(start, start + length) || ShouldTraceSource(source),
|
ShouldTraceRange(start, start + length) || ShouldTraceSource(source),
|
||||||
SourceSequence = sourceSequence,
|
SourceSequence = sourceSequence,
|
||||||
@@ -192,13 +281,22 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FlushPendingFirstCpuWrite(range);
|
FlushPendingFirstCpuWrite(range);
|
||||||
|
// Protect is sticky: a later watch-only Track (texture cache)
|
||||||
|
// must not disarm an RT that already needs page faults.
|
||||||
|
if (protect && !range.Protect)
|
||||||
|
{
|
||||||
|
range.Protect = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
range.SourceSequence = sourceSequence;
|
range.SourceSequence = sourceSequence;
|
||||||
range.Source = source;
|
range.Source = source;
|
||||||
range.TraceLifetime =
|
range.TraceLifetime =
|
||||||
ShouldTraceRange(range.Start, range.End) || ShouldTraceSource(source);
|
ShouldTraceRange(range.Start, range.End) || ShouldTraceSource(source);
|
||||||
ArmLocked(range, "arm");
|
if (range.Protect)
|
||||||
|
{
|
||||||
|
ArmLocked(range, "arm");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +375,8 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
|
|
||||||
lock (_gate)
|
lock (_gate)
|
||||||
{
|
{
|
||||||
if (_rangesByAddress.TryGetValue(address, out var range))
|
if (_rangesByAddress.TryGetValue(address, out var range) &&
|
||||||
|
range.Protect)
|
||||||
{
|
{
|
||||||
ArmLocked(range, "rearm");
|
ArmLocked(range, "rearm");
|
||||||
}
|
}
|
||||||
@@ -445,10 +544,7 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needsUnprotect &&
|
if (needsUnprotect &&
|
||||||
Mprotect(
|
!TrySetProtection(writableStart, writableEnd - writableStart, writable: true))
|
||||||
(nint)writableStart,
|
|
||||||
(nuint)(writableEnd - writableStart),
|
|
||||||
ProtRead | ProtWrite) != 0)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -462,7 +558,11 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
}
|
}
|
||||||
|
|
||||||
var wasArmed = Interlocked.Exchange(ref range.Armed, 0) != 0;
|
var wasArmed = Interlocked.Exchange(ref range.Armed, 0) != 0;
|
||||||
if (wasArmed)
|
var wasDirty = Interlocked.Exchange(ref range.Dirty, 1) != 0;
|
||||||
|
// Protected ranges bump generation once per arm/fault cycle.
|
||||||
|
// Watch-only ranges never arm, so bump on the first dirty mark
|
||||||
|
// (NotifyManagedWrite) so cache owners still see a rewrite.
|
||||||
|
if (wasArmed || (!range.Protect && !wasDirty))
|
||||||
{
|
{
|
||||||
Interlocked.Increment(ref range.WriteGeneration);
|
Interlocked.Increment(ref range.WriteGeneration);
|
||||||
}
|
}
|
||||||
@@ -480,8 +580,6 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
Volatile.Write(ref range.PendingFirstCpuWrite, 1);
|
Volatile.Write(ref range.PendingFirstCpuWrite, 1);
|
||||||
Volatile.Write(ref range.FirstCpuWriteSeen, 2);
|
Volatile.Write(ref range.FirstCpuWriteSeen, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Volatile.Write(ref range.Dirty, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -497,10 +595,7 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
|
|
||||||
// A new publication/rearm starts a new first-write lifetime.
|
// A new publication/rearm starts a new first-write lifetime.
|
||||||
Volatile.Write(ref range.FirstCpuWriteSeen, 0);
|
Volatile.Write(ref range.FirstCpuWriteSeen, 0);
|
||||||
var failed = Mprotect(
|
var failed = !TrySetProtection(range.Start, range.End - range.Start, writable: false);
|
||||||
(nint)range.Start,
|
|
||||||
(nuint)(range.End - range.Start),
|
|
||||||
ProtRead) != 0;
|
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
Volatile.Write(ref range.Armed, 0);
|
Volatile.Write(ref range.Armed, 0);
|
||||||
@@ -520,10 +615,7 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
var wasArmed = Interlocked.Exchange(ref range.Armed, 0) == 1;
|
var wasArmed = Interlocked.Exchange(ref range.Armed, 0) == 1;
|
||||||
if (wasArmed)
|
if (wasArmed)
|
||||||
{
|
{
|
||||||
_ = Mprotect(
|
_ = TrySetProtection(range.Start, range.End - range.Start, writable: true);
|
||||||
(nint)range.Start,
|
|
||||||
(nuint)(range.End - range.Start),
|
|
||||||
ProtRead | ProtWrite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (range.TraceLifetime)
|
if (range.TraceLifetime)
|
||||||
@@ -534,7 +626,13 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
|
|
||||||
private static void RebuildSnapshotLocked()
|
private static void RebuildSnapshotLocked()
|
||||||
{
|
{
|
||||||
Volatile.Write(ref _rangeSnapshot, new RangeSnapshot(_rangesByAddress.Values.ToArray()));
|
// Fault / NotifyManagedWrite hot paths must only see protected ranges.
|
||||||
|
// Watch-only texture-cache registrations used to widen Start..End across
|
||||||
|
// nearly all GPU memory so every managed guest write walked this path.
|
||||||
|
var protectedRanges = _rangesByAddress.Values
|
||||||
|
.Where(static range => range.Protect)
|
||||||
|
.ToArray();
|
||||||
|
Volatile.Write(ref _rangeSnapshot, new RangeSnapshot(protectedRanges));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (ulong Start, ulong Length) PageAlign(ulong address, ulong byteCount)
|
private static (ulong Start, ulong Length) PageAlign(ulong address, ulong byteCount)
|
||||||
@@ -679,8 +777,35 @@ public static unsafe class GuestImageWriteTracker
|
|||||||
$"fault=0x{faultAddress:X16} page=0x{faultPage:X16}");
|
$"fault=0x{faultAddress:X16} page=0x{faultPage:X16}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool TrySetProtection(ulong start, ulong length, bool writable)
|
||||||
|
{
|
||||||
|
if (length == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
return VirtualProtect(
|
||||||
|
(nint)start,
|
||||||
|
(nuint)length,
|
||||||
|
writable ? PageReadWrite : PageReadonly,
|
||||||
|
out _) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Mprotect(
|
||||||
|
(nint)start,
|
||||||
|
(nuint)length,
|
||||||
|
writable ? ProtRead | ProtWrite : ProtRead) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static long GetMonotonicNanoseconds()
|
private static long GetMonotonicNanoseconds()
|
||||||
{
|
{
|
||||||
|
if (OperatingSystem.IsWindows())
|
||||||
|
{
|
||||||
|
return Stopwatch.GetTimestamp() * 1_000_000_000L / Stopwatch.Frequency;
|
||||||
|
}
|
||||||
|
|
||||||
Timespec time;
|
Timespec time;
|
||||||
return ClockGetTime(ClockMonotonicRaw, &time) == 0
|
return ClockGetTime(ClockMonotonicRaw, &time) == 0
|
||||||
? unchecked((time.Seconds * 1_000_000_000L) + time.Nanoseconds)
|
? unchecked((time.Seconds * 1_000_000_000L) + time.Nanoseconds)
|
||||||
|
|||||||
@@ -221,6 +221,29 @@ public static class GuestThreadExecution
|
|||||||
|
|
||||||
public static IGuestThreadScheduler? Scheduler { get; set; }
|
public static IGuestThreadScheduler? Scheduler { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fired when a guest thread is torn down without a clean pthread_exit
|
||||||
|
/// (e.g. TBB execute-AV → worker_abort). Libs use this to abandon mutexes.
|
||||||
|
/// </summary>
|
||||||
|
public static event Func<ulong, string, int>? GuestThreadAbandoned;
|
||||||
|
|
||||||
|
public static int NotifyGuestThreadAbandoned(ulong threadHandle, string reason)
|
||||||
|
{
|
||||||
|
if (threadHandle == 0 || GuestThreadAbandoned is null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return GuestThreadAbandoned.Invoke(threadHandle, reason);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsGuestThread => _currentGuestThreadHandle != 0;
|
public static bool IsGuestThread => _currentGuestThreadHandle != 0;
|
||||||
|
|
||||||
public static ulong CurrentGuestThreadHandle => _currentGuestThreadHandle;
|
public static ulong CurrentGuestThreadHandle => _currentGuestThreadHandle;
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace SharpEmu.HLE.Host;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How much guest audio the host device has actually played, in seconds.
|
||||||
|
///
|
||||||
|
/// This is the only clock in the emulator that advances at the rate the player
|
||||||
|
/// hears. Wall clock runs ahead of it whenever the guest cannot feed the device
|
||||||
|
/// (the stream underruns and the missing time is never played), so anything
|
||||||
|
/// that has to stay in step with the guest's audio — host-decoded video being
|
||||||
|
/// the case that matters — has to follow this rather than <see cref="Stopwatch"/>.
|
||||||
|
///
|
||||||
|
/// Reported per stream and kept as the furthest-along value: the guest's ports
|
||||||
|
/// all carry one mix, and the leading port is the one whose position the
|
||||||
|
/// listener perceives.
|
||||||
|
/// </summary>
|
||||||
|
public static class GuestAudioClock
|
||||||
|
{
|
||||||
|
private static long _playedMicroseconds;
|
||||||
|
private static long _lastAdvanceTimestamp;
|
||||||
|
|
||||||
|
/// <summary>Seconds of guest audio the device has played. Monotonic.</summary>
|
||||||
|
public static double PlayedSeconds =>
|
||||||
|
Interlocked.Read(ref _playedMicroseconds) / 1_000_000.0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True while a stream has reported progress recently. False means no guest
|
||||||
|
/// audio is playing, and callers must fall back to wall clock rather than
|
||||||
|
/// stalling on a clock that will never advance.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsRunning
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var last = Interlocked.Read(ref _lastAdvanceTimestamp);
|
||||||
|
return last != 0 &&
|
||||||
|
Stopwatch.GetElapsedTime(last) < TimeSpan.FromMilliseconds(250);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Report(double playedSeconds)
|
||||||
|
{
|
||||||
|
if (double.IsNaN(playedSeconds) || playedSeconds < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var microseconds = (long)(playedSeconds * 1_000_000.0);
|
||||||
|
var current = Interlocked.Read(ref _playedMicroseconds);
|
||||||
|
while (microseconds > current)
|
||||||
|
{
|
||||||
|
var seen = Interlocked.CompareExchange(
|
||||||
|
ref _playedMicroseconds,
|
||||||
|
microseconds,
|
||||||
|
current);
|
||||||
|
if (seen == current)
|
||||||
|
{
|
||||||
|
Interlocked.Exchange(ref _lastAdvanceTimestamp, Stopwatch.GetTimestamp());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
current = seen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,8 +28,44 @@ public enum HostGamepadButtons : uint
|
|||||||
R3 = 1 << 13,
|
R3 = 1 << 13,
|
||||||
Options = 1 << 14,
|
Options = 1 << 14,
|
||||||
TouchPad = 1 << 15,
|
TouchPad = 1 << 15,
|
||||||
|
Create = 1 << 16,
|
||||||
|
Ps = 1 << 17,
|
||||||
|
Mic = 1 << 18,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum HostGamepadType : byte
|
||||||
|
{
|
||||||
|
Generic,
|
||||||
|
DualShock4,
|
||||||
|
DualSense,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum HostGamepadConnection : byte
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Wired,
|
||||||
|
Wireless,
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly record struct HostMotionState(
|
||||||
|
bool Available,
|
||||||
|
float AccelerationX,
|
||||||
|
float AccelerationY,
|
||||||
|
float AccelerationZ,
|
||||||
|
float AngularVelocityX,
|
||||||
|
float AngularVelocityY,
|
||||||
|
float AngularVelocityZ);
|
||||||
|
|
||||||
|
public readonly record struct HostTouchPoint(
|
||||||
|
bool Active,
|
||||||
|
byte Id,
|
||||||
|
float X,
|
||||||
|
float Y);
|
||||||
|
|
||||||
|
public readonly record struct HostTouchState(
|
||||||
|
HostTouchPoint First,
|
||||||
|
HostTouchPoint Second);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Snapshot of one host gamepad: sticks are 0..255 with 128 centered and Y growing
|
/// Snapshot of one host gamepad: sticks are 0..255 with 128 centered and Y growing
|
||||||
/// downward; triggers 0..255. Unmanaged on purpose so per-frame polls can stackalloc
|
/// downward; triggers 0..255. Unmanaged on purpose so per-frame polls can stackalloc
|
||||||
@@ -43,4 +79,57 @@ public readonly record struct HostGamepadState(
|
|||||||
byte RightX,
|
byte RightX,
|
||||||
byte RightY,
|
byte RightY,
|
||||||
byte LeftTrigger,
|
byte LeftTrigger,
|
||||||
byte RightTrigger);
|
byte RightTrigger,
|
||||||
|
HostGamepadType Type = HostGamepadType.Generic,
|
||||||
|
HostGamepadConnection Connection = HostGamepadConnection.Unknown,
|
||||||
|
HostMotionState Motion = default,
|
||||||
|
HostTouchState Touch = default,
|
||||||
|
byte BatteryPercent = 0);
|
||||||
|
|
||||||
|
/// <summary>A complete 11-byte DualSense adaptive-trigger command.</summary>
|
||||||
|
public readonly record struct HostAdaptiveTriggerEffect(
|
||||||
|
byte B0,
|
||||||
|
byte B1,
|
||||||
|
byte B2,
|
||||||
|
byte B3,
|
||||||
|
byte B4,
|
||||||
|
byte B5,
|
||||||
|
byte B6,
|
||||||
|
byte B7,
|
||||||
|
byte B8,
|
||||||
|
byte B9,
|
||||||
|
byte B10,
|
||||||
|
byte FallbackStrength = 0)
|
||||||
|
{
|
||||||
|
public static HostAdaptiveTriggerEffect FromBytes(ReadOnlySpan<byte> source, byte fallbackStrength = 0)
|
||||||
|
{
|
||||||
|
if (source.Length < 11)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Adaptive-trigger source is too small.", nameof(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HostAdaptiveTriggerEffect(
|
||||||
|
source[0], source[1], source[2], source[3], source[4], source[5],
|
||||||
|
source[6], source[7], source[8], source[9], source[10], fallbackStrength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(Span<byte> destination)
|
||||||
|
{
|
||||||
|
if (destination.Length < 11)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Adaptive-trigger destination is too small.", nameof(destination));
|
||||||
|
}
|
||||||
|
|
||||||
|
destination[0] = B0;
|
||||||
|
destination[1] = B1;
|
||||||
|
destination[2] = B2;
|
||||||
|
destination[3] = B3;
|
||||||
|
destination[4] = B4;
|
||||||
|
destination[5] = B5;
|
||||||
|
destination[6] = B6;
|
||||||
|
destination[7] = B7;
|
||||||
|
destination[8] = B8;
|
||||||
|
destination[9] = B9;
|
||||||
|
destination[10] = B10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,5 +19,11 @@ public interface IHostAudioOutput
|
|||||||
/// Throws when the host has no usable output device; callers degrade to a silent
|
/// Throws when the host has no usable output device; callers degrade to a silent
|
||||||
/// port and pace the guest instead.
|
/// port and pace the guest instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IHostAudioStream OpenStereoPcm16Stream(uint sampleRate);
|
/// <param name="sampleRate">Host stream sample rate in Hz.</param>
|
||||||
|
/// <param name="maxQueuedPcmBytes">
|
||||||
|
/// Soft backpressure cap for queued stereo PCM16. Default 32 KiB (~171 ms at
|
||||||
|
/// 48 kHz) matches classic AudioOut latency. Bursty AudioOut2 / FMOD feeders
|
||||||
|
/// may pass a deeper cap to avoid underruns.
|
||||||
|
/// </param>
|
||||||
|
IHostAudioStream OpenStereoPcm16Stream(uint sampleRate, int maxQueuedPcmBytes = 32 * 1024);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,17 @@ public interface IHostAudioStream : IDisposable
|
|||||||
/// audio, in which case the caller paces the guest itself.
|
/// audio, in which case the caller paces the guest itself.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Submit(ReadOnlySpan<byte> stereoPcm16);
|
bool Submit(ReadOnlySpan<byte> stereoPcm16);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Audio already handed to the device and not yet played, in milliseconds —
|
||||||
|
/// the cushion protecting playback from a late submission. Zero means the
|
||||||
|
/// device has run dry and is emitting silence.
|
||||||
|
///
|
||||||
|
/// Callers that pace the guest against an emulated hardware queue need this:
|
||||||
|
/// pacing purely on wall clock releases exactly one buffer per buffer-period
|
||||||
|
/// and so keeps the cushion at zero, which turns any scheduling jitter into
|
||||||
|
/// an audible dropout. Returns -1 when the backend cannot report a depth, in
|
||||||
|
/// which case callers must fall back to their own pacing.
|
||||||
|
/// </summary>
|
||||||
|
int QueuedMilliseconds => -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ public interface IHostInput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger);
|
void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger);
|
||||||
|
|
||||||
|
/// <summary>Applies native DualSense trigger effects when supported.</summary>
|
||||||
|
void SetAdaptiveTriggerEffect(
|
||||||
|
HostAdaptiveTriggerEffect? leftTrigger,
|
||||||
|
HostAdaptiveTriggerEffect? rightTrigger);
|
||||||
|
|
||||||
void SetLightbar(byte red, byte green, byte blue);
|
void SetLightbar(byte red, byte green, byte blue);
|
||||||
|
|
||||||
void ResetLightbar();
|
void ResetLightbar();
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
namespace SharpEmu.HLE.Host;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional host-audio extension for backends that can accept the guest's
|
||||||
|
/// interleaved PCM layout directly and perform device conversion themselves.
|
||||||
|
/// </summary>
|
||||||
|
public interface IHostPcmAudioOutput : IHostAudioOutput
|
||||||
|
{
|
||||||
|
IHostAudioStream OpenPcmStream(uint sampleRate, int channels, HostPcmFormat format);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum HostPcmFormat
|
||||||
|
{
|
||||||
|
Signed16,
|
||||||
|
Float32,
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
namespace SharpEmu.HLE.Host;
|
||||||
|
|
||||||
|
/// <summary>Input snapshots produced by the active host window.</summary>
|
||||||
|
public interface IHostWindowInputSource
|
||||||
|
{
|
||||||
|
bool HasKeyboardFocus { get; }
|
||||||
|
|
||||||
|
bool IsKeyDown(int virtualKey);
|
||||||
|
|
||||||
|
int GetGamepadStates(Span<HostGamepadState> destination);
|
||||||
|
|
||||||
|
string? DescribeConnectedGamepad();
|
||||||
|
|
||||||
|
void SetRumble(byte largeMotor, byte smallMotor);
|
||||||
|
|
||||||
|
void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger);
|
||||||
|
|
||||||
|
void SetAdaptiveTriggerEffect(
|
||||||
|
HostAdaptiveTriggerEffect? leftTrigger,
|
||||||
|
HostAdaptiveTriggerEffect? rightTrigger);
|
||||||
|
|
||||||
|
void SetLightbar(byte red, byte green, byte blue);
|
||||||
|
|
||||||
|
void ResetLightbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Process-wide bridge between the window layer and host input.</summary>
|
||||||
|
public static class HostWindowInputSource
|
||||||
|
{
|
||||||
|
private static IHostWindowInputSource? _current;
|
||||||
|
|
||||||
|
public static IHostWindowInputSource? Current => Volatile.Read(ref _current);
|
||||||
|
|
||||||
|
public static void Set(IHostWindowInputSource source) =>
|
||||||
|
Volatile.Write(ref _current, source);
|
||||||
|
|
||||||
|
public static void Clear(IHostWindowInputSource source) =>
|
||||||
|
Interlocked.CompareExchange(ref _current, null, source);
|
||||||
|
}
|
||||||
@@ -14,9 +14,6 @@ namespace SharpEmu.HLE.Host.Posix;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed unsafe class PosixAlsaAudioStream : IHostAudioStream
|
internal sealed unsafe class PosixAlsaAudioStream : IHostAudioStream
|
||||||
{
|
{
|
||||||
// 32KB of stereo PCM16 at 48kHz is ~170ms; keep the same device-side
|
|
||||||
// queue depth the WinMM/CoreAudio ports enforce in managed code.
|
|
||||||
private const uint DeviceLatencyMicroseconds = 170_000;
|
|
||||||
private const int StreamPlayback = 0;
|
private const int StreamPlayback = 0;
|
||||||
private const int FormatS16LittleEndian = 2;
|
private const int FormatS16LittleEndian = 2;
|
||||||
private const int AccessReadWriteInterleaved = 3;
|
private const int AccessReadWriteInterleaved = 3;
|
||||||
@@ -27,7 +24,7 @@ internal sealed unsafe class PosixAlsaAudioStream : IHostAudioStream
|
|||||||
private nint _pcm;
|
private nint _pcm;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public PosixAlsaAudioStream(uint sampleRate)
|
public PosixAlsaAudioStream(uint sampleRate, int maxQueuedPcmBytes = 32 * 1024)
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsLinux())
|
if (!OperatingSystem.IsLinux())
|
||||||
{
|
{
|
||||||
@@ -47,6 +44,14 @@ internal sealed unsafe class PosixAlsaAudioStream : IHostAudioStream
|
|||||||
$"snd_pcm_open(\"{device}\") failed: {DescribeError(status)}.");
|
$"snd_pcm_open(\"{device}\") failed: {DescribeError(status)}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Match WinMM/CoreAudio soft queue depth: 32 KiB stereo PCM16 @ 48 kHz
|
||||||
|
// is ~170 ms. AudioOut2 may request a deeper bed.
|
||||||
|
var queuedBytes = Math.Max(maxQueuedPcmBytes, 4 * 1024);
|
||||||
|
var latencyMicroseconds = (uint)Math.Clamp(
|
||||||
|
(long)queuedBytes * 1_000_000L / Math.Max(sampleRate * 4u, 1u),
|
||||||
|
20_000L,
|
||||||
|
2_000_000L);
|
||||||
|
|
||||||
status = snd_pcm_set_params(
|
status = snd_pcm_set_params(
|
||||||
_pcm,
|
_pcm,
|
||||||
FormatS16LittleEndian,
|
FormatS16LittleEndian,
|
||||||
@@ -54,7 +59,7 @@ internal sealed unsafe class PosixAlsaAudioStream : IHostAudioStream
|
|||||||
2,
|
2,
|
||||||
sampleRate,
|
sampleRate,
|
||||||
1,
|
1,
|
||||||
DeviceLatencyMicroseconds);
|
latencyMicroseconds);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
{
|
{
|
||||||
_ = snd_pcm_close(_pcm);
|
_ = snd_pcm_close(_pcm);
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ namespace SharpEmu.HLE.Host.Posix;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed unsafe class PosixCoreAudioStream : IHostAudioStream
|
internal sealed unsafe class PosixCoreAudioStream : IHostAudioStream
|
||||||
{
|
{
|
||||||
private const int MaximumQueuedPcmBytes = 32 * 1024;
|
|
||||||
private const uint FormatLinearPcm = 0x6C70636D; // 'lpcm'
|
private const uint FormatLinearPcm = 0x6C70636D; // 'lpcm'
|
||||||
private const uint FlagIsSignedInteger = 0x4;
|
private const uint FlagIsSignedInteger = 0x4;
|
||||||
private const uint FlagIsPacked = 0x8;
|
private const uint FlagIsPacked = 0x8;
|
||||||
|
|
||||||
|
private readonly int _maximumQueuedPcmBytes;
|
||||||
private readonly object _gate = new();
|
private readonly object _gate = new();
|
||||||
private readonly AutoResetEvent _completion = new(false);
|
private readonly AutoResetEvent _completion = new(false);
|
||||||
private readonly Queue<nint> _freeBuffers = new();
|
private readonly Queue<nint> _freeBuffers = new();
|
||||||
@@ -27,13 +27,15 @@ internal sealed unsafe class PosixCoreAudioStream : IHostAudioStream
|
|||||||
private bool _started;
|
private bool _started;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public PosixCoreAudioStream(uint sampleRate)
|
public PosixCoreAudioStream(uint sampleRate, int maxQueuedPcmBytes = 32 * 1024)
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsMacOS())
|
if (!OperatingSystem.IsMacOS())
|
||||||
{
|
{
|
||||||
throw new PlatformNotSupportedException("CoreAudio is only available on macOS.");
|
throw new PlatformNotSupportedException("CoreAudio is only available on macOS.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_maximumQueuedPcmBytes = Math.Max(maxQueuedPcmBytes, 4 * 1024);
|
||||||
|
|
||||||
var format = new AudioStreamBasicDescription
|
var format = new AudioStreamBasicDescription
|
||||||
{
|
{
|
||||||
SampleRate = sampleRate,
|
SampleRate = sampleRate,
|
||||||
@@ -73,7 +75,7 @@ internal sealed unsafe class PosixCoreAudioStream : IHostAudioStream
|
|||||||
|
|
||||||
var outputLength = stereoPcm16.Length;
|
var outputLength = stereoPcm16.Length;
|
||||||
while (_queuedPcmBytes != 0 &&
|
while (_queuedPcmBytes != 0 &&
|
||||||
_queuedPcmBytes + outputLength > MaximumQueuedPcmBytes)
|
_queuedPcmBytes + outputLength > _maximumQueuedPcmBytes)
|
||||||
{
|
{
|
||||||
Monitor.Exit(_gate);
|
Monitor.Exit(_gate);
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ internal sealed class PosixHostAudio : IHostAudioOutput
|
|||||||
{
|
{
|
||||||
public string BackendName => OperatingSystem.IsMacOS() ? "coreaudio" : "alsa";
|
public string BackendName => OperatingSystem.IsMacOS() ? "coreaudio" : "alsa";
|
||||||
|
|
||||||
public IHostAudioStream OpenStereoPcm16Stream(uint sampleRate)
|
public IHostAudioStream OpenStereoPcm16Stream(uint sampleRate, int maxQueuedPcmBytes = 32 * 1024)
|
||||||
{
|
{
|
||||||
return OperatingSystem.IsMacOS()
|
return OperatingSystem.IsMacOS()
|
||||||
? new PosixCoreAudioStream(sampleRate)
|
? new PosixCoreAudioStream(sampleRate, maxQueuedPcmBytes)
|
||||||
: new PosixAlsaAudioStream(sampleRate);
|
: new PosixAlsaAudioStream(sampleRate, maxQueuedPcmBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,186 +0,0 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Posix;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bridges a window-provided input source into the host input seam. POSIX
|
|
||||||
/// hosts have no user32/XInput/raw-HID readers; keyboard and gamepad state
|
|
||||||
/// come from the presenter's GLFW window instead, which registers itself via
|
|
||||||
/// <see cref="SetSource"/> once the window exists. Until then (and with no
|
|
||||||
/// window at all, e.g. headless runs) every query reports neutral input.
|
|
||||||
/// Rumble and lightbar are unsupported by the GLFW input layer and no-op.
|
|
||||||
/// </summary>
|
|
||||||
public interface IPosixWindowInputSource
|
|
||||||
{
|
|
||||||
/// <summary>True while the window's keyboard is delivering events.</summary>
|
|
||||||
bool HasKeyboardFocus { get; }
|
|
||||||
|
|
||||||
/// <summary>Windows virtual-key semantics; the source translates.</summary>
|
|
||||||
bool IsKeyDown(int virtualKey);
|
|
||||||
|
|
||||||
/// <summary>Same contract as <see cref="IHostInput.GetGamepadStates"/>.</summary>
|
|
||||||
int GetGamepadStates(Span<HostGamepadState> destination);
|
|
||||||
|
|
||||||
string? DescribeConnectedGamepad();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Public so the presenter's window layer (SharpEmu.Libs) can register its
|
|
||||||
// input source; the platform still constructs the singleton itself.
|
|
||||||
public sealed class PosixHostInput : IHostInput
|
|
||||||
{
|
|
||||||
private static volatile IPosixWindowInputSource? _source;
|
|
||||||
|
|
||||||
/// <summary>Called by the presenter's window layer when input is ready.</summary>
|
|
||||||
public static void SetSource(IPosixWindowInputSource source)
|
|
||||||
{
|
|
||||||
_source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EnsureStarted()
|
|
||||||
{
|
|
||||||
// Device readers are event-driven off the window thread; nothing to start.
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetGamepadStates(Span<HostGamepadState> destination)
|
|
||||||
{
|
|
||||||
return _source?.GetGamepadStates(destination) ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string? DescribeConnectedGamepad() => _source?.DescribeConnectedGamepad();
|
|
||||||
|
|
||||||
public void SetRumble(byte largeMotor, byte smallMotor)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetLightbar(byte red, byte green, byte blue)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetLightbar()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsHostWindowFocused()
|
|
||||||
{
|
|
||||||
// GLFW only delivers key events to the focused window, so a
|
|
||||||
// delivering keyboard implies focus.
|
|
||||||
return _source?.HasKeyboardFocus ?? IsEmbeddedX11WindowFocused();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsKeyDown(int virtualKey)
|
|
||||||
{
|
|
||||||
var source = _source;
|
|
||||||
if (source is not null)
|
|
||||||
{
|
|
||||||
return source.IsKeyDown(virtualKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
return IsEmbeddedX11WindowFocused() && IsEmbeddedX11KeyDown(virtualKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsEmbeddedX11WindowFocused()
|
|
||||||
{
|
|
||||||
if (!OperatingSystem.IsLinux())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var display = HostSessionControl.EmbeddedHostDisplay;
|
|
||||||
var window = HostSessionControl.EmbeddedHostWindow;
|
|
||||||
if (display == 0 || window == 0 || XGetInputFocus(display, out var focusedWindow, out _) == 0 || focusedWindow == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetTopLevelWindow(display, focusedWindow) == GetTopLevelWindow(display, window);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsEmbeddedX11KeyDown(int virtualKey)
|
|
||||||
{
|
|
||||||
var display = HostSessionControl.EmbeddedHostDisplay;
|
|
||||||
var keysym = ToX11Keysym(virtualKey);
|
|
||||||
if (display == 0 || keysym == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var keycode = XKeysymToKeycode(display, keysym);
|
|
||||||
if (keycode == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var keymap = new byte[32];
|
|
||||||
XQueryKeymap(display, keymap);
|
|
||||||
return (keymap[keycode >> 3] & (1 << (keycode & 7))) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static nint GetTopLevelWindow(nint display, nint window)
|
|
||||||
{
|
|
||||||
var current = window;
|
|
||||||
for (var depth = 0; depth < 16; depth++)
|
|
||||||
{
|
|
||||||
if (XQueryTree(display, current, out var root, out var parent, out var children, out _) == 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (children != 0)
|
|
||||||
{
|
|
||||||
XFree(children);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent == 0 || parent == root)
|
|
||||||
{
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
current = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static nuint ToX11Keysym(int virtualKey)
|
|
||||||
{
|
|
||||||
return virtualKey switch
|
|
||||||
{
|
|
||||||
0x08 => 0xFF08, // Backspace
|
|
||||||
0x09 => 0xFF09, // Tab
|
|
||||||
0x0D => 0xFF0D, // Return
|
|
||||||
0x1B => 0xFF1B, // Escape
|
|
||||||
0x25 => 0xFF51, // Left
|
|
||||||
0x26 => 0xFF52, // Up
|
|
||||||
0x27 => 0xFF53, // Right
|
|
||||||
0x28 => 0xFF54, // Down
|
|
||||||
>= 0x41 and <= 0x5A => (nuint)virtualKey,
|
|
||||||
_ => 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("libX11.so.6")]
|
|
||||||
private static extern int XGetInputFocus(nint display, out nint focus, out int revertTo);
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("libX11.so.6")]
|
|
||||||
private static extern int XQueryKeymap(nint display, [System.Runtime.InteropServices.Out] byte[] keysReturn);
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("libX11.so.6")]
|
|
||||||
private static extern byte XKeysymToKeycode(nint display, nuint keysym);
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("libX11.so.6")]
|
|
||||||
private static extern int XQueryTree(
|
|
||||||
nint display,
|
|
||||||
nint window,
|
|
||||||
out nint root,
|
|
||||||
out nint parent,
|
|
||||||
out nint children,
|
|
||||||
out uint childCount);
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("libX11.so.6")]
|
|
||||||
private static extern int XFree(nint data);
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using SharpEmu.HLE.Host.Sdl;
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Posix;
|
namespace SharpEmu.HLE.Host.Posix;
|
||||||
|
|
||||||
internal sealed class PosixHostPlatform : IHostPlatform
|
internal sealed class PosixHostPlatform : IHostPlatform
|
||||||
@@ -11,7 +13,7 @@ internal sealed class PosixHostPlatform : IHostPlatform
|
|||||||
|
|
||||||
public IHostSymbolResolver Symbols { get; } = new PosixHostSymbolResolver();
|
public IHostSymbolResolver Symbols { get; } = new PosixHostSymbolResolver();
|
||||||
|
|
||||||
public IHostAudioOutput Audio { get; } = new PosixHostAudio();
|
public IHostAudioOutput Audio { get; } = new SdlHostAudio();
|
||||||
|
|
||||||
public IHostInput Input { get; } = new PosixHostInput();
|
public IHostInput Input { get; } = new WindowHostInput();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,325 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using SDL;
|
||||||
|
using static SDL.SDL3;
|
||||||
|
|
||||||
|
namespace SharpEmu.HLE.Host.Sdl;
|
||||||
|
|
||||||
|
internal sealed unsafe class SdlHostAudio : IHostPcmAudioOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Cap for streams this class paces itself (AudioOut). Blocking the guest
|
||||||
|
/// here is that path's only pacing, so the device settles at this depth —
|
||||||
|
/// it is the playback latency, and the floor under it is how much jitter the
|
||||||
|
/// stream can absorb before it runs dry.
|
||||||
|
/// </summary>
|
||||||
|
private static readonly int TargetQueuedMilliseconds =
|
||||||
|
int.TryParse(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_AUDIO_LATENCY_MS"),
|
||||||
|
out var latencyMs) && latencyMs > 0
|
||||||
|
? latencyMs
|
||||||
|
: 60;
|
||||||
|
|
||||||
|
private const int MaximumWaitMilliseconds = 250;
|
||||||
|
private static readonly object InitGate = new();
|
||||||
|
private static bool _initialized;
|
||||||
|
|
||||||
|
public string BackendName => "sdl3";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stereo PCM16 stream with a caller-chosen backpressure cap. Callers that
|
||||||
|
/// pace the guest themselves pass a deeper cap so this class's backpressure
|
||||||
|
/// does not fight their pacing.
|
||||||
|
/// </summary>
|
||||||
|
public IHostAudioStream OpenStereoPcm16Stream(uint sampleRate, int maxQueuedPcmBytes = 32 * 1024)
|
||||||
|
=> OpenStream(
|
||||||
|
sampleRate,
|
||||||
|
channels: 2,
|
||||||
|
HostPcmFormat.Signed16,
|
||||||
|
maxQueuedPcmBytes > 0 ? maxQueuedPcmBytes : 32 * 1024);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Guest-format stream for AudioOut, which has no queue model of its own:
|
||||||
|
/// blocking here is that path's only pacing, so the device settles at
|
||||||
|
/// TargetQueuedMilliseconds and that depth is the playback latency.
|
||||||
|
/// </summary>
|
||||||
|
public IHostAudioStream OpenPcmStream(uint sampleRate, int channels, HostPcmFormat format)
|
||||||
|
{
|
||||||
|
var bytesPerSample = format == HostPcmFormat.Float32 ? sizeof(float) : sizeof(short);
|
||||||
|
var cap = checked((int)((long)sampleRate * channels * bytesPerSample *
|
||||||
|
TargetQueuedMilliseconds / 1_000));
|
||||||
|
return OpenStream(sampleRate, channels, format, cap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IHostAudioStream OpenStream(
|
||||||
|
uint sampleRate,
|
||||||
|
int channels,
|
||||||
|
HostPcmFormat format,
|
||||||
|
int maximumQueuedBytes)
|
||||||
|
{
|
||||||
|
if (sampleRate is < 8_000 or > 384_000 || channels is < 1 or > 8)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException(
|
||||||
|
sampleRate is < 8_000 or > 384_000 ? nameof(sampleRate) : nameof(channels));
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureInitialized();
|
||||||
|
return new AudioStream(sampleRate, channels, format, maximumQueuedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureInitialized()
|
||||||
|
{
|
||||||
|
lock (InitGate)
|
||||||
|
{
|
||||||
|
if (_initialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((SDL_WasInit(SDL_InitFlags.SDL_INIT_AUDIO) & SDL_InitFlags.SDL_INIT_AUDIO) == 0 &&
|
||||||
|
!SDL_InitSubSystem(SDL_InitFlags.SDL_INIT_AUDIO))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"SDL audio initialization failed: {GetError()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetError()
|
||||||
|
{
|
||||||
|
var error = Unsafe_SDL_GetError();
|
||||||
|
return error is null ? "unknown SDL error" : Marshal.PtrToStringUTF8((nint)error) ?? "unknown SDL error";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly bool _traceQueue = string.Equals(
|
||||||
|
Environment.GetEnvironmentVariable("SHARPEMU_LOG_AUDIO_QUEUE"),
|
||||||
|
"1",
|
||||||
|
StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static int _nextStreamId;
|
||||||
|
|
||||||
|
private sealed class AudioStream : IHostAudioStream
|
||||||
|
{
|
||||||
|
private readonly object _gate = new();
|
||||||
|
private readonly int _maximumQueuedBytes;
|
||||||
|
private readonly int _bytesPerFrame;
|
||||||
|
private readonly uint _sampleRate;
|
||||||
|
private readonly int _streamId = Interlocked.Increment(ref _nextStreamId);
|
||||||
|
private SDL_AudioStream* _stream;
|
||||||
|
private bool _disposed;
|
||||||
|
private long _totalSubmittedBytes;
|
||||||
|
|
||||||
|
// Queue diagnostics for the current report window.
|
||||||
|
private long _windowStart = Stopwatch.GetTimestamp();
|
||||||
|
private long _submissions;
|
||||||
|
private long _submittedBytes;
|
||||||
|
private long _blockedTicks;
|
||||||
|
private long _drops;
|
||||||
|
private long _emptyObservations;
|
||||||
|
private int _minQueuedBytes = int.MaxValue;
|
||||||
|
private int _maxQueuedBytes;
|
||||||
|
private long _queuedByteSum;
|
||||||
|
|
||||||
|
public AudioStream(
|
||||||
|
uint sampleRate,
|
||||||
|
int channels,
|
||||||
|
HostPcmFormat format,
|
||||||
|
int maximumQueuedBytes)
|
||||||
|
{
|
||||||
|
var bytesPerSample = format == HostPcmFormat.Float32 ? sizeof(float) : sizeof(short);
|
||||||
|
_bytesPerFrame = channels * bytesPerSample;
|
||||||
|
_sampleRate = sampleRate;
|
||||||
|
var spec = new SDL_AudioSpec
|
||||||
|
{
|
||||||
|
format = format == HostPcmFormat.Float32
|
||||||
|
? SDL_AudioFormat.SDL_AUDIO_F32LE
|
||||||
|
: SDL_AudioFormat.SDL_AUDIO_S16LE,
|
||||||
|
channels = checked((byte)channels),
|
||||||
|
freq = checked((int)sampleRate),
|
||||||
|
};
|
||||||
|
|
||||||
|
_stream = SDL_OpenAudioDeviceStream(
|
||||||
|
SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK,
|
||||||
|
&spec,
|
||||||
|
null,
|
||||||
|
IntPtr.Zero);
|
||||||
|
if (_stream is null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"SDL audio stream creation failed: {GetError()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SDL_ResumeAudioStreamDevice(_stream))
|
||||||
|
{
|
||||||
|
SDL_DestroyAudioStream(_stream);
|
||||||
|
_stream = null;
|
||||||
|
throw new InvalidOperationException($"SDL audio stream start failed: {GetError()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
_maximumQueuedBytes = maximumQueuedBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int QueuedMilliseconds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_gate)
|
||||||
|
{
|
||||||
|
if (_disposed || _stream is null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bytesPerSecond = (double)_bytesPerFrame * _sampleRate;
|
||||||
|
return bytesPerSecond <= 0
|
||||||
|
? -1
|
||||||
|
: (int)(SDL_GetAudioStreamQueued(_stream) / bytesPerSecond * 1000.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Submit(ReadOnlySpan<byte> pcm)
|
||||||
|
{
|
||||||
|
if (pcm.IsEmpty)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_gate)
|
||||||
|
{
|
||||||
|
if (_disposed || _stream is null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var blockStart = Stopwatch.GetTimestamp();
|
||||||
|
var deadline = blockStart +
|
||||||
|
(Stopwatch.Frequency * MaximumWaitMilliseconds / 1_000);
|
||||||
|
int queued;
|
||||||
|
var overrun = false;
|
||||||
|
while ((queued = SDL_GetAudioStreamQueued(_stream)) > _maximumQueuedBytes)
|
||||||
|
{
|
||||||
|
if (Stopwatch.GetTimestamp() >= deadline)
|
||||||
|
{
|
||||||
|
// Enqueue anyway rather than discarding the buffer. A gap in
|
||||||
|
// the stream is an audible click; the extra latency of one
|
||||||
|
// over-deep submission is not, and the queue recovers as soon
|
||||||
|
// as the device drains back under the cap.
|
||||||
|
overrun = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordSubmission(queued, blockStart, dropped: overrun, bytes: pcm.Length);
|
||||||
|
bool submitted;
|
||||||
|
fixed (byte* data = pcm)
|
||||||
|
{
|
||||||
|
submitted = SDL_PutAudioStreamData(_stream, (nint)data, pcm.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (submitted)
|
||||||
|
{
|
||||||
|
// Everything handed over minus what the device still holds is
|
||||||
|
// what the player has actually heard.
|
||||||
|
_totalSubmittedBytes += pcm.Length;
|
||||||
|
var bytesPerSecond = (double)_bytesPerFrame * _sampleRate;
|
||||||
|
if (bytesPerSecond > 0)
|
||||||
|
{
|
||||||
|
GuestAudioClock.Report(
|
||||||
|
Math.Max(0, _totalSubmittedBytes - queued - pcm.Length) / bytesPerSecond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return submitted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Samples the queue depth at the moment the guest was allowed to write.
|
||||||
|
/// That depth is the playback latency the guest's audio is subject to, so
|
||||||
|
/// it is the number to look at when the sound is late; an observed depth
|
||||||
|
/// of zero is a genuine underrun, which is what a crackle sounds like.
|
||||||
|
/// Caller holds <see cref="_gate"/>.
|
||||||
|
/// </summary>
|
||||||
|
private void RecordSubmission(int queuedBytes, long blockStart, bool dropped, int bytes)
|
||||||
|
{
|
||||||
|
if (!_traceQueue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var now = Stopwatch.GetTimestamp();
|
||||||
|
_submissions++;
|
||||||
|
_submittedBytes += bytes;
|
||||||
|
_blockedTicks += now - blockStart;
|
||||||
|
_queuedByteSum += queuedBytes;
|
||||||
|
_minQueuedBytes = Math.Min(_minQueuedBytes, queuedBytes);
|
||||||
|
_maxQueuedBytes = Math.Max(_maxQueuedBytes, queuedBytes);
|
||||||
|
if (dropped)
|
||||||
|
{
|
||||||
|
_drops++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queuedBytes == 0)
|
||||||
|
{
|
||||||
|
_emptyObservations++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var elapsedTicks = now - _windowStart;
|
||||||
|
if (elapsedTicks < Stopwatch.Frequency)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_windowStart = now;
|
||||||
|
var seconds = elapsedTicks / (double)Stopwatch.Frequency;
|
||||||
|
var bytesPerSecond = (double)_bytesPerFrame * _sampleRate;
|
||||||
|
Console.Error.WriteLine(
|
||||||
|
$"[PERF][AUDIO] stream#{_streamId} {seconds:F1}s " +
|
||||||
|
$"queued_ms min={ToMilliseconds(_minQueuedBytes, bytesPerSecond):F0} " +
|
||||||
|
$"avg={ToMilliseconds((int)(_queuedByteSum / Math.Max(1, _submissions)), bytesPerSecond):F0} " +
|
||||||
|
$"max={ToMilliseconds(_maxQueuedBytes, bytesPerSecond):F0} " +
|
||||||
|
$"cap={ToMilliseconds(_maximumQueuedBytes, bytesPerSecond):F0} " +
|
||||||
|
$"submits/s={_submissions / seconds:F0} " +
|
||||||
|
$"fill={_submittedBytes / seconds / bytesPerSecond * 100.0:F0}% " +
|
||||||
|
$"blocked={_blockedTicks * 100.0 / elapsedTicks:F0}% " +
|
||||||
|
$"empty={_emptyObservations} drops={_drops}");
|
||||||
|
|
||||||
|
_submissions = 0;
|
||||||
|
_submittedBytes = 0;
|
||||||
|
_blockedTicks = 0;
|
||||||
|
_drops = 0;
|
||||||
|
_emptyObservations = 0;
|
||||||
|
_minQueuedBytes = int.MaxValue;
|
||||||
|
_maxQueuedBytes = 0;
|
||||||
|
_queuedByteSum = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double ToMilliseconds(int bytes, double bytesPerSecond) =>
|
||||||
|
bytesPerSecond <= 0 ? 0 : bytes / bytesPerSecond * 1000.0;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
lock (_gate)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_disposed = true;
|
||||||
|
if (_stream is not null)
|
||||||
|
{
|
||||||
|
SDL_ClearAudioStream(_stream);
|
||||||
|
SDL_DestroyAudioStream(_stream);
|
||||||
|
_stream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
namespace SharpEmu.HLE.Host;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Routes emulated input through the active cross-platform host window.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class WindowHostInput : IHostInput
|
||||||
|
{
|
||||||
|
public void EnsureStarted()
|
||||||
|
{
|
||||||
|
// SDL owns device discovery and pumps it on the window thread.
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetGamepadStates(Span<HostGamepadState> destination) =>
|
||||||
|
HostWindowInputSource.Current?.GetGamepadStates(destination) ?? 0;
|
||||||
|
|
||||||
|
public string? DescribeConnectedGamepad() =>
|
||||||
|
HostWindowInputSource.Current?.DescribeConnectedGamepad();
|
||||||
|
|
||||||
|
public void SetRumble(byte largeMotor, byte smallMotor) =>
|
||||||
|
HostWindowInputSource.Current?.SetRumble(largeMotor, smallMotor);
|
||||||
|
|
||||||
|
public void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger) =>
|
||||||
|
HostWindowInputSource.Current?.SetTriggerRumble(leftTrigger, rightTrigger);
|
||||||
|
|
||||||
|
public void SetAdaptiveTriggerEffect(
|
||||||
|
HostAdaptiveTriggerEffect? leftTrigger,
|
||||||
|
HostAdaptiveTriggerEffect? rightTrigger) =>
|
||||||
|
HostWindowInputSource.Current?.SetAdaptiveTriggerEffect(leftTrigger, rightTrigger);
|
||||||
|
|
||||||
|
public void SetLightbar(byte red, byte green, byte blue) =>
|
||||||
|
HostWindowInputSource.Current?.SetLightbar(red, green, blue);
|
||||||
|
|
||||||
|
public void ResetLightbar() => HostWindowInputSource.Current?.ResetLightbar();
|
||||||
|
|
||||||
|
public bool IsHostWindowFocused() =>
|
||||||
|
HostWindowInputSource.Current?.HasKeyboardFocus ?? false;
|
||||||
|
|
||||||
|
public bool IsKeyDown(int virtualKey) =>
|
||||||
|
HostWindowInputSource.Current?.IsKeyDown(virtualKey) ?? false;
|
||||||
|
}
|
||||||
@@ -1,439 +0,0 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
using Microsoft.Win32.SafeHandles;
|
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Windows;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads a DualSense controller over raw HID on a background thread.
|
|
||||||
/// Supports USB (input report 0x01) and Bluetooth (extended report 0x31,
|
|
||||||
/// activated by requesting feature report 0x05), with hot-plug retry.
|
|
||||||
/// </summary>
|
|
||||||
public static class WindowsDualSenseReader
|
|
||||||
{
|
|
||||||
private const ushort SonyVendorId = 0x054C;
|
|
||||||
private const ushort DualSenseProductId = 0x0CE6;
|
|
||||||
private const ushort DualSenseEdgeProductId = 0x0DF2;
|
|
||||||
|
|
||||||
private static readonly object Gate = new();
|
|
||||||
private static HostGamepadState _state;
|
|
||||||
private static bool _started;
|
|
||||||
|
|
||||||
// Output (rumble/lightbar) state, all guarded by Gate.
|
|
||||||
private static string? _devicePath;
|
|
||||||
private static bool _bluetooth;
|
|
||||||
private static bool _outputReady;
|
|
||||||
private static bool _lightbarSetupPending;
|
|
||||||
private static byte _outputSequence;
|
|
||||||
private static FileStream? _outputStream;
|
|
||||||
private static byte _motorLeft;
|
|
||||||
private static byte _motorRight;
|
|
||||||
private static byte _lightbarRed;
|
|
||||||
private static byte _lightbarGreen;
|
|
||||||
private static byte _lightbarBlue = 64; // PS-style blue default
|
|
||||||
private static byte _playerLeds = 0x04; // center LED = player 1
|
|
||||||
|
|
||||||
/// <summary>Starts the background reader once; safe to call repeatedly.</summary>
|
|
||||||
public static void EnsureStarted()
|
|
||||||
{
|
|
||||||
// The GUI source-links this reader and calls it directly, without the
|
|
||||||
// host-platform resolution that otherwise guarantees Windows.
|
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
if (_started)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_started = true;
|
|
||||||
var thread = new Thread(ReadLoop)
|
|
||||||
{
|
|
||||||
IsBackground = true,
|
|
||||||
Name = "DualSenseReader",
|
|
||||||
};
|
|
||||||
thread.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryGetState(out HostGamepadState state)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
state = _state;
|
|
||||||
}
|
|
||||||
|
|
||||||
return state.Connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetState(in HostGamepadState state)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
_state = state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Sets rumble; large = left/strong motor, small = right/weak.</summary>
|
|
||||||
internal static void SetRumble(byte largeMotor, byte smallMotor)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
if (_motorLeft == largeMotor && _motorRight == smallMotor)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_motorLeft = largeMotor;
|
|
||||||
_motorRight = smallMotor;
|
|
||||||
SendOutputLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void SetLightbar(byte red, byte green, byte blue)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
if (_lightbarRed == red && _lightbarGreen == green && _lightbarBlue == blue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_lightbarRed = red;
|
|
||||||
_lightbarGreen = green;
|
|
||||||
_lightbarBlue = blue;
|
|
||||||
SendOutputLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void ResetLightbar() => SetLightbar(0, 0, 64);
|
|
||||||
|
|
||||||
private static void OnDeviceIdentified(string path, bool bluetooth)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
_devicePath = path;
|
|
||||||
_bluetooth = bluetooth;
|
|
||||||
_outputReady = true;
|
|
||||||
_lightbarSetupPending = true;
|
|
||||||
// Announce ourselves on the hardware: default lightbar + player 1 LED.
|
|
||||||
SendOutputLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnDeviceLost()
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
_devicePath = null;
|
|
||||||
_outputReady = false;
|
|
||||||
_motorLeft = 0;
|
|
||||||
_motorRight = 0;
|
|
||||||
_outputStream?.Dispose();
|
|
||||||
_outputStream = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SendOutputLocked()
|
|
||||||
{
|
|
||||||
if (!_outputReady || _devicePath is null)
|
|
||||||
{
|
|
||||||
return; // flushed by OnDeviceIdentified once connected
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_outputStream is null)
|
|
||||||
{
|
|
||||||
var handle = WindowsHidNative.CreateFile(
|
|
||||||
_devicePath,
|
|
||||||
WindowsHidNative.GenericRead | WindowsHidNative.GenericWrite,
|
|
||||||
WindowsHidNative.FileShareRead | WindowsHidNative.FileShareWrite,
|
|
||||||
0, WindowsHidNative.OpenExisting, 0, 0);
|
|
||||||
if (handle.IsInvalid)
|
|
||||||
{
|
|
||||||
handle.Dispose();
|
|
||||||
return; // read-only device access: outputs unavailable
|
|
||||||
}
|
|
||||||
|
|
||||||
_outputStream = new FileStream(handle, FileAccess.Write, bufferSize: 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var report = BuildOutputReportLocked();
|
|
||||||
_outputStream.Write(report, 0, report.Length);
|
|
||||||
_outputStream.Flush();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
_outputStream?.Dispose();
|
|
||||||
_outputStream = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] BuildOutputReportLocked()
|
|
||||||
{
|
|
||||||
// Common 47-byte output payload (offsets per the DualSense output
|
|
||||||
// report layout, same as Linux hid-playstation).
|
|
||||||
Span<byte> common = stackalloc byte[47];
|
|
||||||
common[0] = 0x03; // valid_flag0: compatible vibration + haptics select
|
|
||||||
common[1] = 0x04 | 0x10; // valid_flag1: lightbar + player indicator
|
|
||||||
common[2] = _motorRight; // right (weak) motor
|
|
||||||
common[3] = _motorLeft; // left (strong) motor
|
|
||||||
if (_lightbarSetupPending)
|
|
||||||
{
|
|
||||||
common[38] |= 0x02; // valid_flag2: lightbar setup control enable
|
|
||||||
common[41] = 0x01; // lightbar_setup: light on
|
|
||||||
_lightbarSetupPending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
common[43] = _playerLeds;
|
|
||||||
common[44] = _lightbarRed;
|
|
||||||
common[45] = _lightbarGreen;
|
|
||||||
common[46] = _lightbarBlue;
|
|
||||||
|
|
||||||
if (!_bluetooth)
|
|
||||||
{
|
|
||||||
var usbReport = new byte[48];
|
|
||||||
usbReport[0] = 0x02;
|
|
||||||
common.CopyTo(usbReport.AsSpan(1));
|
|
||||||
return usbReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bluetooth: 0x31 wrapper with sequence tag and CRC32 over a 0xA2
|
|
||||||
// seed byte plus the first 74 report bytes.
|
|
||||||
var btReport = new byte[78];
|
|
||||||
btReport[0] = 0x31;
|
|
||||||
btReport[1] = (byte)((_outputSequence & 0x0F) << 4);
|
|
||||||
_outputSequence = (byte)((_outputSequence + 1) & 0x0F);
|
|
||||||
btReport[2] = 0x10;
|
|
||||||
common.CopyTo(btReport.AsSpan(3));
|
|
||||||
var crc = Crc32(0xA2, btReport.AsSpan(0, 74));
|
|
||||||
btReport[74] = (byte)crc;
|
|
||||||
btReport[75] = (byte)(crc >> 8);
|
|
||||||
btReport[76] = (byte)(crc >> 16);
|
|
||||||
btReport[77] = (byte)(crc >> 24);
|
|
||||||
return btReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static uint Crc32(byte seed, ReadOnlySpan<byte> data)
|
|
||||||
{
|
|
||||||
var crc = Crc32Update(0xFFFFFFFFu, seed);
|
|
||||||
foreach (var value in data)
|
|
||||||
{
|
|
||||||
crc = Crc32Update(crc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ~crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static uint Crc32Update(uint crc, byte value)
|
|
||||||
{
|
|
||||||
crc ^= value;
|
|
||||||
for (var bit = 0; bit < 8; bit++)
|
|
||||||
{
|
|
||||||
crc = (crc >> 1) ^ (0xEDB88320u & (uint)-(int)(crc & 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ReadLoop()
|
|
||||||
{
|
|
||||||
var announcedConnect = false;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
SafeFileHandle? handle = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
handle = OpenDualSense(out var devicePath);
|
|
||||||
if (handle is null || devicePath is null)
|
|
||||||
{
|
|
||||||
SetState(default);
|
|
||||||
announcedConnect = false;
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bluetooth quirk: the DualSense sends a simplified report
|
|
||||||
// until feature report 0x05 is requested, which switches it
|
|
||||||
// to the full 0x31 input report. Harmless over USB.
|
|
||||||
var feature = new byte[41];
|
|
||||||
feature[0] = 0x05;
|
|
||||||
_ = WindowsHidNative.HidD_GetFeature(handle, feature, feature.Length);
|
|
||||||
|
|
||||||
if (!announcedConnect)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("[LOADER][INFO] DualSense controller connected.");
|
|
||||||
announcedConnect = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var stream = new FileStream(handle, FileAccess.Read, bufferSize: 1);
|
|
||||||
handle = null; // stream owns it now
|
|
||||||
var buffer = new byte[256];
|
|
||||||
var transportKnown = false;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var read = stream.Read(buffer, 0, buffer.Length);
|
|
||||||
if (read <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TryParseReport(buffer.AsSpan(0, read), out var state))
|
|
||||||
{
|
|
||||||
if (!transportKnown)
|
|
||||||
{
|
|
||||||
// The first parsed report tells us the transport,
|
|
||||||
// which the output (rumble/lightbar) path needs.
|
|
||||||
transportKnown = true;
|
|
||||||
OnDeviceIdentified(devicePath, bluetooth: buffer[0] == 0x31);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetState(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// Unplugged or read error: fall through and retry.
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
handle?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (announcedConnect)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("[LOADER][INFO] DualSense controller disconnected.");
|
|
||||||
announcedConnect = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnDeviceLost();
|
|
||||||
SetState(default);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SafeFileHandle? OpenDualSense(out string? devicePath)
|
|
||||||
{
|
|
||||||
devicePath = null;
|
|
||||||
foreach (var path in WindowsHidNative.EnumerateHidDevicePaths())
|
|
||||||
{
|
|
||||||
// Open without access rights just to query VID/PID.
|
|
||||||
using var probe = WindowsHidNative.CreateFile(
|
|
||||||
path, 0, WindowsHidNative.FileShareRead | WindowsHidNative.FileShareWrite, 0, WindowsHidNative.OpenExisting, 0, 0);
|
|
||||||
if (probe.IsInvalid)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var attributes = new WindowsHidNative.HiddAttributes { Size = 12 };
|
|
||||||
if (!WindowsHidNative.HidD_GetAttributes(probe, ref attributes) ||
|
|
||||||
attributes.VendorId != SonyVendorId ||
|
|
||||||
(attributes.ProductId != DualSenseProductId && attributes.ProductId != DualSenseEdgeProductId))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read+write so feature reports work; fall back to read-only.
|
|
||||||
var handle = WindowsHidNative.CreateFile(
|
|
||||||
path,
|
|
||||||
WindowsHidNative.GenericRead | WindowsHidNative.GenericWrite,
|
|
||||||
WindowsHidNative.FileShareRead | WindowsHidNative.FileShareWrite,
|
|
||||||
0, WindowsHidNative.OpenExisting, 0, 0);
|
|
||||||
if (handle.IsInvalid)
|
|
||||||
{
|
|
||||||
handle.Dispose();
|
|
||||||
handle = WindowsHidNative.CreateFile(
|
|
||||||
path,
|
|
||||||
WindowsHidNative.GenericRead,
|
|
||||||
WindowsHidNative.FileShareRead | WindowsHidNative.FileShareWrite,
|
|
||||||
0, WindowsHidNative.OpenExisting, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handle.IsInvalid)
|
|
||||||
{
|
|
||||||
devicePath = path;
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool TryParseReport(ReadOnlySpan<byte> report, out HostGamepadState state)
|
|
||||||
{
|
|
||||||
// USB: report id 0x01, payload starts at [1].
|
|
||||||
// Bluetooth extended: report id 0x31, sequence byte at [1], payload at [2].
|
|
||||||
int offset;
|
|
||||||
if (report.Length >= 11 && report[0] == 0x01)
|
|
||||||
{
|
|
||||||
offset = 1;
|
|
||||||
}
|
|
||||||
else if (report.Length >= 12 && report[0] == 0x31)
|
|
||||||
{
|
|
||||||
offset = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
state = default;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var leftX = report[offset + 0];
|
|
||||||
var leftY = report[offset + 1];
|
|
||||||
var rightX = report[offset + 2];
|
|
||||||
var rightY = report[offset + 3];
|
|
||||||
var l2 = report[offset + 4];
|
|
||||||
var r2 = report[offset + 5];
|
|
||||||
var buttons0 = report[offset + 7];
|
|
||||||
var buttons1 = report[offset + 8];
|
|
||||||
var buttons2 = report[offset + 9];
|
|
||||||
|
|
||||||
var buttons = HostGamepadButtons.None;
|
|
||||||
buttons |= (buttons0 & 0x10) != 0 ? HostGamepadButtons.Square : 0;
|
|
||||||
buttons |= (buttons0 & 0x20) != 0 ? HostGamepadButtons.Cross : 0;
|
|
||||||
buttons |= (buttons0 & 0x40) != 0 ? HostGamepadButtons.Circle : 0;
|
|
||||||
buttons |= (buttons0 & 0x80) != 0 ? HostGamepadButtons.Triangle : 0;
|
|
||||||
buttons |= HatToButtons(buttons0 & 0x0F);
|
|
||||||
buttons |= (buttons1 & 0x01) != 0 ? HostGamepadButtons.L1 : 0;
|
|
||||||
buttons |= (buttons1 & 0x02) != 0 ? HostGamepadButtons.R1 : 0;
|
|
||||||
buttons |= (buttons1 & 0x04) != 0 ? HostGamepadButtons.L2 : 0;
|
|
||||||
buttons |= (buttons1 & 0x08) != 0 ? HostGamepadButtons.R2 : 0;
|
|
||||||
buttons |= (buttons1 & 0x20) != 0 ? HostGamepadButtons.Options : 0;
|
|
||||||
buttons |= (buttons1 & 0x40) != 0 ? HostGamepadButtons.L3 : 0;
|
|
||||||
buttons |= (buttons1 & 0x80) != 0 ? HostGamepadButtons.R3 : 0;
|
|
||||||
buttons |= (buttons2 & 0x02) != 0 ? HostGamepadButtons.TouchPad : 0;
|
|
||||||
|
|
||||||
state = new HostGamepadState(
|
|
||||||
Connected: true,
|
|
||||||
Buttons: buttons,
|
|
||||||
LeftX: leftX,
|
|
||||||
LeftY: leftY,
|
|
||||||
RightX: rightX,
|
|
||||||
RightY: rightY,
|
|
||||||
LeftTrigger: l2,
|
|
||||||
RightTrigger: r2);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HostGamepadButtons HatToButtons(int hat) => hat switch
|
|
||||||
{
|
|
||||||
0 => HostGamepadButtons.Up,
|
|
||||||
1 => HostGamepadButtons.Up | HostGamepadButtons.Right,
|
|
||||||
2 => HostGamepadButtons.Right,
|
|
||||||
3 => HostGamepadButtons.Right | HostGamepadButtons.Down,
|
|
||||||
4 => HostGamepadButtons.Down,
|
|
||||||
5 => HostGamepadButtons.Down | HostGamepadButtons.Left,
|
|
||||||
6 => HostGamepadButtons.Left,
|
|
||||||
7 => HostGamepadButtons.Left | HostGamepadButtons.Up,
|
|
||||||
_ => 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Microsoft.Win32.SafeHandles;
|
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Windows;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Minimal Win32 HID interop used to talk to a DualSense controller
|
|
||||||
/// directly, without any external input library.
|
|
||||||
/// </summary>
|
|
||||||
internal static partial class WindowsHidNative
|
|
||||||
{
|
|
||||||
internal const int DigcfPresent = 0x02;
|
|
||||||
internal const int DigcfDeviceInterface = 0x10;
|
|
||||||
internal const uint GenericRead = 0x80000000;
|
|
||||||
internal const uint GenericWrite = 0x40000000;
|
|
||||||
internal const uint FileShareRead = 0x1;
|
|
||||||
internal const uint FileShareWrite = 0x2;
|
|
||||||
internal const uint OpenExisting = 3;
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
internal struct SpDeviceInterfaceData
|
|
||||||
{
|
|
||||||
public int CbSize;
|
|
||||||
public Guid InterfaceClassGuid;
|
|
||||||
public int Flags;
|
|
||||||
public nint Reserved;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
internal struct HiddAttributes
|
|
||||||
{
|
|
||||||
public int Size;
|
|
||||||
public ushort VendorId;
|
|
||||||
public ushort ProductId;
|
|
||||||
public ushort VersionNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
[LibraryImport("hid.dll")]
|
|
||||||
internal static partial void HidD_GetHidGuid(out Guid hidGuid);
|
|
||||||
|
|
||||||
[LibraryImport("hid.dll")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
internal static partial bool HidD_GetAttributes(SafeFileHandle hidDeviceObject, ref HiddAttributes attributes);
|
|
||||||
|
|
||||||
[LibraryImport("hid.dll")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
internal static partial bool HidD_GetFeature(SafeFileHandle hidDeviceObject, [In, Out] byte[] reportBuffer, int reportBufferLength);
|
|
||||||
|
|
||||||
[LibraryImport("setupapi.dll", EntryPoint = "SetupDiGetClassDevsW")]
|
|
||||||
internal static partial nint SetupDiGetClassDevs(ref Guid classGuid, nint enumerator, nint hwndParent, int flags);
|
|
||||||
|
|
||||||
[LibraryImport("setupapi.dll")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
internal static partial bool SetupDiEnumDeviceInterfaces(
|
|
||||||
nint deviceInfoSet,
|
|
||||||
nint deviceInfoData,
|
|
||||||
ref Guid interfaceClassGuid,
|
|
||||||
int memberIndex,
|
|
||||||
ref SpDeviceInterfaceData deviceInterfaceData);
|
|
||||||
|
|
||||||
[LibraryImport("setupapi.dll", EntryPoint = "SetupDiGetDeviceInterfaceDetailW")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
internal static partial bool SetupDiGetDeviceInterfaceDetail(
|
|
||||||
nint deviceInfoSet,
|
|
||||||
ref SpDeviceInterfaceData deviceInterfaceData,
|
|
||||||
nint deviceInterfaceDetailData,
|
|
||||||
int deviceInterfaceDetailDataSize,
|
|
||||||
out int requiredSize,
|
|
||||||
nint deviceInfoData);
|
|
||||||
|
|
||||||
[LibraryImport("setupapi.dll")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
internal static partial bool SetupDiDestroyDeviceInfoList(nint deviceInfoSet);
|
|
||||||
|
|
||||||
[LibraryImport("kernel32.dll", EntryPoint = "CreateFileW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
|
|
||||||
internal static partial SafeFileHandle CreateFile(
|
|
||||||
string fileName,
|
|
||||||
uint desiredAccess,
|
|
||||||
uint shareMode,
|
|
||||||
nint securityAttributes,
|
|
||||||
uint creationDisposition,
|
|
||||||
uint flagsAndAttributes,
|
|
||||||
nint templateFile);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enumerates the device paths of all present HID interfaces.
|
|
||||||
/// </summary>
|
|
||||||
internal static List<string> EnumerateHidDevicePaths()
|
|
||||||
{
|
|
||||||
var paths = new List<string>();
|
|
||||||
HidD_GetHidGuid(out var hidGuid);
|
|
||||||
var deviceInfoSet = SetupDiGetClassDevs(ref hidGuid, 0, 0, DigcfPresent | DigcfDeviceInterface);
|
|
||||||
if (deviceInfoSet == -1 || deviceInfoSet == 0)
|
|
||||||
{
|
|
||||||
return paths;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var interfaceData = new SpDeviceInterfaceData
|
|
||||||
{
|
|
||||||
CbSize = Marshal.SizeOf<SpDeviceInterfaceData>(),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var index = 0; SetupDiEnumDeviceInterfaces(deviceInfoSet, 0, ref hidGuid, index, ref interfaceData); index++)
|
|
||||||
{
|
|
||||||
SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref interfaceData, 0, 0, out var requiredSize, 0);
|
|
||||||
if (requiredSize <= 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var detailBuffer = Marshal.AllocHGlobal(requiredSize);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// SP_DEVICE_INTERFACE_DETAIL_DATA_W.cbSize is 8 on x64
|
|
||||||
// (DWORD + aligned WCHAR[1]); the path string follows it.
|
|
||||||
Marshal.WriteInt32(detailBuffer, 8);
|
|
||||||
if (SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref interfaceData, detailBuffer, requiredSize, out _, 0) &&
|
|
||||||
Marshal.PtrToStringUni(detailBuffer + 4) is { Length: > 0 } path)
|
|
||||||
{
|
|
||||||
paths.Add(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal.FreeHGlobal(detailBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
SetupDiDestroyDeviceInfoList(deviceInfoSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
return paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Windows;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Windows input backend: DualSense over raw HID plus XInput controllers for gamepads,
|
|
||||||
/// user32 for the keyboard-fallback queries. Rumble fans out to every reader; lightbar
|
|
||||||
/// only exists on the DualSense.
|
|
||||||
/// </summary>
|
|
||||||
internal sealed partial class WindowsHostInput : IHostInput
|
|
||||||
{
|
|
||||||
public void EnsureStarted()
|
|
||||||
{
|
|
||||||
WindowsDualSenseReader.EnsureStarted();
|
|
||||||
WindowsXInputReader.EnsureStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetGamepadStates(Span<HostGamepadState> destination)
|
|
||||||
{
|
|
||||||
var count = 0;
|
|
||||||
if (count < destination.Length && WindowsDualSenseReader.TryGetState(out var dualSense))
|
|
||||||
{
|
|
||||||
destination[count++] = dualSense;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count < destination.Length && WindowsXInputReader.TryGetState(out var xinput))
|
|
||||||
{
|
|
||||||
destination[count++] = xinput;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string? DescribeConnectedGamepad()
|
|
||||||
{
|
|
||||||
if (WindowsDualSenseReader.TryGetState(out _))
|
|
||||||
{
|
|
||||||
return "DualSense";
|
|
||||||
}
|
|
||||||
|
|
||||||
return WindowsXInputReader.TryGetState(out _) ? "Xbox controller" : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRumble(byte largeMotor, byte smallMotor)
|
|
||||||
{
|
|
||||||
WindowsDualSenseReader.SetRumble(largeMotor, smallMotor);
|
|
||||||
WindowsXInputReader.SetRumble(largeMotor, smallMotor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger) =>
|
|
||||||
WindowsXInputReader.SetTriggerRumble(leftTrigger, rightTrigger);
|
|
||||||
|
|
||||||
public void SetLightbar(byte red, byte green, byte blue) =>
|
|
||||||
WindowsDualSenseReader.SetLightbar(red, green, blue);
|
|
||||||
|
|
||||||
public void ResetLightbar() => WindowsDualSenseReader.ResetLightbar();
|
|
||||||
|
|
||||||
public bool IsHostWindowFocused()
|
|
||||||
{
|
|
||||||
var foregroundWindow = GetForegroundWindow();
|
|
||||||
if (foregroundWindow == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetWindowThreadProcessId(foregroundWindow, out var processId);
|
|
||||||
if (processId == (uint)Environment.ProcessId)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The GUI runs the emulator in an isolated child process. Its native
|
|
||||||
// Vulkan surface is a child of the GUI window, so the foreground
|
|
||||||
// window belongs to the launcher process rather than this one.
|
|
||||||
var embeddedHostWindow = HostSessionControl.EmbeddedHostWindow;
|
|
||||||
var hostTopLevelWindow = embeddedHostWindow == 0
|
|
||||||
? 0
|
|
||||||
: GetAncestor(embeddedHostWindow, GetAncestorRoot);
|
|
||||||
return hostTopLevelWindow != 0 && foregroundWindow == hostTopLevelWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsKeyDown(int virtualKey) =>
|
|
||||||
(GetAsyncKeyState(virtualKey) & 0x8000) != 0;
|
|
||||||
|
|
||||||
[LibraryImport("user32.dll")]
|
|
||||||
private static partial short GetAsyncKeyState(int vKey);
|
|
||||||
|
|
||||||
[LibraryImport("user32.dll")]
|
|
||||||
private static partial nint GetForegroundWindow();
|
|
||||||
|
|
||||||
[LibraryImport("user32.dll")]
|
|
||||||
private static partial uint GetWindowThreadProcessId(nint hWnd, out uint processId);
|
|
||||||
|
|
||||||
[LibraryImport("user32.dll")]
|
|
||||||
private static partial nint GetAncestor(nint hWnd, uint gaFlags);
|
|
||||||
|
|
||||||
private const uint GetAncestorRoot = 2;
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
using SharpEmu.HLE.Host.Sdl;
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Windows;
|
namespace SharpEmu.HLE.Host.Windows;
|
||||||
|
|
||||||
internal sealed class WindowsHostPlatform : IHostPlatform
|
internal sealed class WindowsHostPlatform : IHostPlatform
|
||||||
@@ -11,7 +13,7 @@ internal sealed class WindowsHostPlatform : IHostPlatform
|
|||||||
|
|
||||||
public IHostSymbolResolver Symbols { get; } = new WindowsHostSymbolResolver();
|
public IHostSymbolResolver Symbols { get; } = new WindowsHostSymbolResolver();
|
||||||
|
|
||||||
public IHostAudioOutput Audio { get; } = new WindowsWaveOutAudio();
|
public IHostAudioOutput Audio { get; } = new SdlHostAudio();
|
||||||
|
|
||||||
public IHostInput Input { get; } = new WindowsHostInput();
|
public IHostInput Input { get; } = new WindowHostInput();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ internal sealed partial class WindowsWaveOutAudio : IHostAudioOutput
|
|||||||
{
|
{
|
||||||
public string BackendName => "winmm";
|
public string BackendName => "winmm";
|
||||||
|
|
||||||
public IHostAudioStream OpenStereoPcm16Stream(uint sampleRate) => new WaveOutStream(sampleRate);
|
public IHostAudioStream OpenStereoPcm16Stream(uint sampleRate, int maxQueuedPcmBytes = 32 * 1024) =>
|
||||||
|
new WaveOutStream(sampleRate, maxQueuedPcmBytes);
|
||||||
|
|
||||||
private sealed partial class WaveOutStream : IHostAudioStream
|
private sealed partial class WaveOutStream : IHostAudioStream
|
||||||
{
|
{
|
||||||
@@ -17,8 +18,8 @@ internal sealed partial class WindowsWaveOutAudio : IHostAudioOutput
|
|||||||
private const uint CallbackEvent = 0x0005_0000;
|
private const uint CallbackEvent = 0x0005_0000;
|
||||||
private const ushort WaveFormatPcm = 1;
|
private const ushort WaveFormatPcm = 1;
|
||||||
private const uint WaveHeaderDone = 0x0000_0001;
|
private const uint WaveHeaderDone = 0x0000_0001;
|
||||||
private const int MaximumQueuedPcmBytes = 32 * 1024;
|
|
||||||
|
|
||||||
|
private readonly int _maximumQueuedPcmBytes;
|
||||||
private readonly object _gate = new();
|
private readonly object _gate = new();
|
||||||
private readonly AutoResetEvent _completion = new(false);
|
private readonly AutoResetEvent _completion = new(false);
|
||||||
private readonly Queue<NativeBuffer> _buffers = new();
|
private readonly Queue<NativeBuffer> _buffers = new();
|
||||||
@@ -26,8 +27,9 @@ internal sealed partial class WindowsWaveOutAudio : IHostAudioOutput
|
|||||||
private int _queuedPcmBytes;
|
private int _queuedPcmBytes;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public WaveOutStream(uint sampleRate)
|
public WaveOutStream(uint sampleRate, int maxQueuedPcmBytes)
|
||||||
{
|
{
|
||||||
|
_maximumQueuedPcmBytes = Math.Max(maxQueuedPcmBytes, 4 * 1024);
|
||||||
var format = new WaveFormat
|
var format = new WaveFormat
|
||||||
{
|
{
|
||||||
FormatTag = WaveFormatPcm,
|
FormatTag = WaveFormatPcm,
|
||||||
@@ -62,7 +64,7 @@ internal sealed partial class WindowsWaveOutAudio : IHostAudioOutput
|
|||||||
|
|
||||||
ReapCompletedBuffers();
|
ReapCompletedBuffers();
|
||||||
while (_queuedPcmBytes != 0 &&
|
while (_queuedPcmBytes != 0 &&
|
||||||
_queuedPcmBytes + stereoPcm16.Length > MaximumQueuedPcmBytes)
|
_queuedPcmBytes + stereoPcm16.Length > _maximumQueuedPcmBytes)
|
||||||
{
|
{
|
||||||
if (!_completion.WaitOne(TimeSpan.FromSeconds(1)))
|
if (!_completion.WaitOne(TimeSpan.FromSeconds(1)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,277 +0,0 @@
|
|||||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace SharpEmu.HLE.Host.Windows;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads Xbox 360 / Xbox One (and other XInput-compatible) controllers via
|
|
||||||
/// the Windows XInput API on a background thread, translated to
|
|
||||||
/// <see cref="HostGamepadState"/> conventions. Supports rumble and hot-plug
|
|
||||||
/// retry; the first connected slot (of four) is used.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class WindowsXInputReader
|
|
||||||
{
|
|
||||||
private const uint ErrorSuccess = 0;
|
|
||||||
private const int SlotCount = 4;
|
|
||||||
private const byte TriggerThreshold = 30; // XINPUT_GAMEPAD_TRIGGER_THRESHOLD
|
|
||||||
|
|
||||||
// XINPUT_GAMEPAD wButtons bit values.
|
|
||||||
private const ushort XinputDpadUp = 0x0001;
|
|
||||||
private const ushort XinputDpadDown = 0x0002;
|
|
||||||
private const ushort XinputDpadLeft = 0x0004;
|
|
||||||
private const ushort XinputDpadRight = 0x0008;
|
|
||||||
private const ushort XinputStart = 0x0010;
|
|
||||||
private const ushort XinputBack = 0x0020;
|
|
||||||
private const ushort XinputLeftThumb = 0x0040;
|
|
||||||
private const ushort XinputRightThumb = 0x0080;
|
|
||||||
private const ushort XinputLeftShoulder = 0x0100;
|
|
||||||
private const ushort XinputRightShoulder = 0x0200;
|
|
||||||
private const ushort XinputA = 0x1000;
|
|
||||||
private const ushort XinputB = 0x2000;
|
|
||||||
private const ushort XinputX = 0x4000;
|
|
||||||
private const ushort XinputY = 0x8000;
|
|
||||||
|
|
||||||
private static readonly object Gate = new();
|
|
||||||
private static HostGamepadState _state;
|
|
||||||
private static bool _started;
|
|
||||||
private static int _slot = -1; // connected XInput user index, -1 when none
|
|
||||||
private static byte _motorLeft;
|
|
||||||
private static byte _motorRight;
|
|
||||||
private static byte _triggerLeft;
|
|
||||||
private static byte _triggerRight;
|
|
||||||
|
|
||||||
/// <summary>Starts the background reader once; safe to call repeatedly.</summary>
|
|
||||||
public static void EnsureStarted()
|
|
||||||
{
|
|
||||||
// The GUI source-links this reader and calls it directly, without the
|
|
||||||
// host-platform resolution that otherwise guarantees Windows.
|
|
||||||
if (!OperatingSystem.IsWindows())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
if (_started)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_started = true;
|
|
||||||
var thread = new Thread(ReadLoop)
|
|
||||||
{
|
|
||||||
IsBackground = true,
|
|
||||||
Name = "XInputReader",
|
|
||||||
};
|
|
||||||
thread.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryGetState(out HostGamepadState state)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
state = _state;
|
|
||||||
}
|
|
||||||
|
|
||||||
return state.Connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetState(in HostGamepadState state)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
_state = state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Sets rumble; large = left/strong motor, small = right/weak.</summary>
|
|
||||||
internal static void SetRumble(byte largeMotor, byte smallMotor)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
if (_motorLeft == largeMotor && _motorRight == smallMotor)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_motorLeft = largeMotor;
|
|
||||||
_motorRight = smallMotor;
|
|
||||||
SendRumbleLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Approximates per-trigger vibration on the two XInput body motors.</summary>
|
|
||||||
internal static void SetTriggerRumble(byte? leftTrigger, byte? rightTrigger)
|
|
||||||
{
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
var changed = false;
|
|
||||||
if (leftTrigger is { } left)
|
|
||||||
{
|
|
||||||
changed |= _triggerLeft != left;
|
|
||||||
_triggerLeft = left;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rightTrigger is { } right)
|
|
||||||
{
|
|
||||||
changed |= _triggerRight != right;
|
|
||||||
_triggerRight = right;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed)
|
|
||||||
{
|
|
||||||
SendRumbleLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SendRumbleLocked()
|
|
||||||
{
|
|
||||||
if (_slot < 0)
|
|
||||||
{
|
|
||||||
return; // resent on connect
|
|
||||||
}
|
|
||||||
|
|
||||||
var vibration = new XInputVibration
|
|
||||||
{
|
|
||||||
LeftMotorSpeed = (ushort)(Math.Max(_motorLeft, _triggerLeft) * 257),
|
|
||||||
RightMotorSpeed = (ushort)(Math.Max(_motorRight, _triggerRight) * 257),
|
|
||||||
};
|
|
||||||
_ = XInputSetState((uint)_slot, ref vibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ReadLoop()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var slot = FindConnectedSlot();
|
|
||||||
if (slot < 0)
|
|
||||||
{
|
|
||||||
SetState(default);
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
_slot = slot;
|
|
||||||
SendRumbleLocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.Error.WriteLine("[LOADER][INFO] XInput (Xbox) controller connected.");
|
|
||||||
while (XInputGetState((uint)slot, out var state) == ErrorSuccess)
|
|
||||||
{
|
|
||||||
SetState(Translate(state.Gamepad));
|
|
||||||
Thread.Sleep(8);
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.Error.WriteLine("[LOADER][INFO] XInput (Xbox) controller disconnected.");
|
|
||||||
lock (Gate)
|
|
||||||
{
|
|
||||||
_slot = -1;
|
|
||||||
_motorLeft = 0;
|
|
||||||
_motorRight = 0;
|
|
||||||
_triggerLeft = 0;
|
|
||||||
_triggerRight = 0;
|
|
||||||
_state = default;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (DllNotFoundException)
|
|
||||||
{
|
|
||||||
// XInput unavailable on this system; leave the reader disconnected.
|
|
||||||
}
|
|
||||||
catch (EntryPointNotFoundException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int FindConnectedSlot()
|
|
||||||
{
|
|
||||||
for (var index = 0; index < SlotCount; index++)
|
|
||||||
{
|
|
||||||
if (XInputGetState((uint)index, out _) == ErrorSuccess)
|
|
||||||
{
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HostGamepadState Translate(in XInputGamepad pad)
|
|
||||||
{
|
|
||||||
var buttons = HostGamepadButtons.None;
|
|
||||||
buttons |= (pad.Buttons & XinputDpadUp) != 0 ? HostGamepadButtons.Up : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputDpadDown) != 0 ? HostGamepadButtons.Down : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputDpadLeft) != 0 ? HostGamepadButtons.Left : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputDpadRight) != 0 ? HostGamepadButtons.Right : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputStart) != 0 ? HostGamepadButtons.Options : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputBack) != 0 ? HostGamepadButtons.TouchPad : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputLeftThumb) != 0 ? HostGamepadButtons.L3 : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputRightThumb) != 0 ? HostGamepadButtons.R3 : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputLeftShoulder) != 0 ? HostGamepadButtons.L1 : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputRightShoulder) != 0 ? HostGamepadButtons.R1 : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputA) != 0 ? HostGamepadButtons.Cross : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputB) != 0 ? HostGamepadButtons.Circle : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputX) != 0 ? HostGamepadButtons.Square : 0;
|
|
||||||
buttons |= (pad.Buttons & XinputY) != 0 ? HostGamepadButtons.Triangle : 0;
|
|
||||||
buttons |= pad.LeftTrigger > TriggerThreshold ? HostGamepadButtons.L2 : 0;
|
|
||||||
buttons |= pad.RightTrigger > TriggerThreshold ? HostGamepadButtons.R2 : 0;
|
|
||||||
|
|
||||||
return new HostGamepadState(
|
|
||||||
Connected: true,
|
|
||||||
Buttons: buttons,
|
|
||||||
LeftX: AxisToByte(pad.ThumbLX),
|
|
||||||
LeftY: AxisToByteInverted(pad.ThumbLY),
|
|
||||||
RightX: AxisToByte(pad.ThumbRX),
|
|
||||||
RightY: AxisToByteInverted(pad.ThumbRY),
|
|
||||||
LeftTrigger: pad.LeftTrigger,
|
|
||||||
RightTrigger: pad.RightTrigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte AxisToByte(short value) => (byte)((value + 32768) >> 8);
|
|
||||||
|
|
||||||
// XInput Y grows upward, host pad conventions report Y growing downward.
|
|
||||||
private static byte AxisToByteInverted(short value) => (byte)(255 - ((value + 32768) >> 8));
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
private struct XInputGamepad
|
|
||||||
{
|
|
||||||
public ushort Buttons;
|
|
||||||
public byte LeftTrigger;
|
|
||||||
public byte RightTrigger;
|
|
||||||
public short ThumbLX;
|
|
||||||
public short ThumbLY;
|
|
||||||
public short ThumbRX;
|
|
||||||
public short ThumbRY;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
private struct XInputState
|
|
||||||
{
|
|
||||||
public uint PacketNumber;
|
|
||||||
public XInputGamepad Gamepad;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
private struct XInputVibration
|
|
||||||
{
|
|
||||||
public ushort LeftMotorSpeed;
|
|
||||||
public ushort RightMotorSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// xinput1_4.dll ships with Windows 8 and later.
|
|
||||||
[LibraryImport("xinput1_4.dll")]
|
|
||||||
private static partial uint XInputGetState(uint userIndex, out XInputState state);
|
|
||||||
|
|
||||||
[LibraryImport("xinput1_4.dll")]
|
|
||||||
private static partial uint XInputSetState(uint userIndex, ref XInputVibration vibration);
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,8 @@ using System.Collections.Concurrent;
|
|||||||
namespace SharpEmu.HLE;
|
namespace SharpEmu.HLE;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs work on the real process main thread. macOS only allows AppKit (and
|
/// Runs work on the real process main thread. macOS requires its windowing
|
||||||
/// therefore GLFW windowing) on that thread, so the CLI moves emulation onto
|
/// event loop on that thread, so the CLI moves emulation onto
|
||||||
/// a worker thread, parks the main thread in <see cref="Pump"/>, and the
|
/// a worker thread, parks the main thread in <see cref="Pump"/>, and the
|
||||||
/// video presenter posts its window loop here. On other platforms
|
/// video presenter posts its window loop here. On other platforms
|
||||||
/// <see cref="IsAvailable"/> stays false and nothing changes.
|
/// <see cref="IsAvailable"/> stays false and nothing changes.
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ public static class HostSessionControl
|
|||||||
private static Action<string>? _shutdownHandler;
|
private static Action<string>? _shutdownHandler;
|
||||||
private static string? _pendingShutdownReason;
|
private static string? _pendingShutdownReason;
|
||||||
private static int _shutdownRequested;
|
private static int _shutdownRequested;
|
||||||
private static long _embeddedHostWindow;
|
|
||||||
private static long _embeddedHostDisplay;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates that the active host session is being stopped. Runtime code
|
/// Indicates that the active host session is being stopped. Runtime code
|
||||||
@@ -22,21 +20,6 @@ public static class HostSessionControl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsShutdownRequested => Volatile.Read(ref _shutdownRequested) != 0;
|
public static bool IsShutdownRequested => Volatile.Read(ref _shutdownRequested) != 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Native GUI surface used by an isolated emulator child. Input backends
|
|
||||||
/// use it to treat the launcher window as the active game window.
|
|
||||||
/// </summary>
|
|
||||||
public static nint EmbeddedHostWindow => unchecked((nint)Interlocked.Read(ref _embeddedHostWindow));
|
|
||||||
|
|
||||||
/// <summary>X11 Display* paired with <see cref="EmbeddedHostWindow"/> when available.</summary>
|
|
||||||
public static nint EmbeddedHostDisplay => unchecked((nint)Interlocked.Read(ref _embeddedHostDisplay));
|
|
||||||
|
|
||||||
public static void SetEmbeddedHostSurface(nint window, nint display = 0)
|
|
||||||
{
|
|
||||||
Interlocked.Exchange(ref _embeddedHostDisplay, unchecked((long)display));
|
|
||||||
Interlocked.Exchange(ref _embeddedHostWindow, unchecked((long)window));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts a fresh session after the previous guest has fully left its
|
/// Starts a fresh session after the previous guest has fully left its
|
||||||
/// execution backend.
|
/// execution backend.
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<ProjectReference Include="..\SharpEmu.Logging\SharpEmu.Logging.csproj" />
|
<ProjectReference Include="..\SharpEmu.Logging\SharpEmu.Logging.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ppy.SDL3-CS" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Forces build ordering for the aerolib task below; loaded as a build component,
|
<!-- Forces build ordering for the aerolib task below; loaded as a build component,
|
||||||
never a runtime dependency. -->
|
never a runtime dependency. -->
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using LibAtrac9.Utilities;
|
using LibAtrac9.Utilities;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System;
|
using System;
|
||||||
using LibAtrac9.Utilities;
|
using LibAtrac9.Utilities;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
namespace LibAtrac9
|
namespace LibAtrac9
|
||||||
{
|
{
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
namespace LibAtrac9
|
namespace LibAtrac9
|
||||||
{
|
{
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using LibAtrac9.Utilities;
|
using LibAtrac9.Utilities;
|
||||||
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
namespace LibAtrac9
|
namespace LibAtrac9
|
||||||
{
|
{
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
namespace LibAtrac9
|
namespace LibAtrac9
|
||||||
{
|
{
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
using System;
|
using System;
|
||||||
using LibAtrac9.Utilities;
|
using LibAtrac9.Utilities;
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
#nullable disable
|
#nullable disable
|
||||||
namespace LibAtrac9
|
namespace LibAtrac9
|
||||||
{
|
{
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user