mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-30 14:39:42 +08:00
Sdl backend (#670)
* [audio] added sdl audio backend and in-tree atrac9 decoder * [input] replaced per-platform pad readers with sdl gamepad input * [video] added sdl window and host display plumbing * [gui] added host display options and per-game render settings * [bink] synced host movie playback to the guest audio clock * [cpu] hooked windows write faults into guest image tracking * [perf] added guest and render profiling, reserved host cpu lanes * [kernel] fixed stale pthread mutex handle alias * [host] wired the sdl session, save-data paths and project references * [audio] hoisted ajm trace stackalloc out of its loop * [video] Add guest image sync setting * [build] Strip native symbols * reuse
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
using SharpEmu.Libs.VideoOut;
|
||||
using Xunit;
|
||||
|
||||
namespace SharpEmu.Libs.Tests.VideoOut;
|
||||
|
||||
public sealed class HostVideoOptionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void NormalizeClampsUnsafeHostValues()
|
||||
{
|
||||
var options = new HostVideoOptions
|
||||
{
|
||||
Width = 1,
|
||||
Height = 99_999,
|
||||
DisplayIndex = -2,
|
||||
RefreshRate = 5000,
|
||||
HdrMode = (HostHdrMode)99,
|
||||
}.Normalize();
|
||||
|
||||
Assert.Equal(640, options.Width);
|
||||
Assert.Equal(16384, options.Height);
|
||||
Assert.Equal(0, options.DisplayIndex);
|
||||
Assert.Equal(1000, options.RefreshRate);
|
||||
Assert.Equal(HostHdrMode.Auto, options.HdrMode);
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,24 @@ public sealed class VideoOutPixelFormatTests
|
||||
Assert.Equal(56u, InvokeMapPixelFormat(0xDEADBEEFUL));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0x88740000UL)]
|
||||
[InlineData(0x8100070422000000UL)]
|
||||
[InlineData(0x8100070400000000UL)]
|
||||
public void IsHdrPixelFormat_PqFormats_ReturnTrue(ulong pixelFormat)
|
||||
{
|
||||
Assert.True(VideoOutExports.IsHdrPixelFormat(pixelFormat));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0x80000000UL)]
|
||||
[InlineData(0x88060000UL)]
|
||||
[InlineData(0x8100000622000000UL)]
|
||||
public void IsHdrPixelFormat_SdrFormats_ReturnFalse(ulong pixelFormat)
|
||||
{
|
||||
Assert.False(VideoOutExports.IsHdrPixelFormat(pixelFormat));
|
||||
}
|
||||
|
||||
// ---- Self-check activation ----
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
using SharpEmu.Libs.VideoOut;
|
||||
using Xunit;
|
||||
|
||||
namespace SharpEmu.Libs.Tests.VideoOut;
|
||||
|
||||
public sealed class VulkanPipelineCacheStorageTests
|
||||
{
|
||||
[Fact]
|
||||
public void ResolvePathUsesExecutableUserDirectoryAndTitleId()
|
||||
{
|
||||
var path = VulkanPipelineCacheStorage.ResolvePath("PPSA02929", configuredPath: null);
|
||||
|
||||
Assert.Equal(
|
||||
Path.GetFullPath(Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
"user",
|
||||
"pipeline_cache",
|
||||
"PPSA02929",
|
||||
"vulkan-pipeline-cache.bin")),
|
||||
path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePathSanitizesTitleId()
|
||||
{
|
||||
var path = VulkanPipelineCacheStorage.ResolvePath("ppsa/02:929", configuredPath: null);
|
||||
|
||||
Assert.EndsWith(
|
||||
Path.Combine("PPSA_02_929", "vulkan-pipeline-cache.bin"),
|
||||
path,
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePathPreservesConfiguredOverride()
|
||||
{
|
||||
var configured = Path.Combine(Path.GetTempPath(), "SharpEmuTests", "custom-cache.bin");
|
||||
|
||||
Assert.Equal(
|
||||
Path.GetFullPath(configured),
|
||||
VulkanPipelineCacheStorage.ResolvePath("PPSA02929", configured));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImportLegacyCacheDoesNotOverwriteExistingTitleCache()
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), "SharpEmuTests", Guid.NewGuid().ToString("N"));
|
||||
var legacyPath = Path.Combine(root, "legacy.bin");
|
||||
var destinationPath = Path.Combine(root, "user", "pipeline_cache", "PPSA02929", "cache.bin");
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(root);
|
||||
File.WriteAllBytes(legacyPath, [1, 2, 3]);
|
||||
|
||||
Assert.True(VulkanPipelineCacheStorage.ImportLegacyCache(legacyPath, destinationPath));
|
||||
Assert.Equal(new byte[] { 1, 2, 3 }, File.ReadAllBytes(destinationPath));
|
||||
Assert.False(File.Exists(legacyPath));
|
||||
|
||||
File.WriteAllBytes(legacyPath, [4, 5, 6]);
|
||||
Assert.False(VulkanPipelineCacheStorage.ImportLegacyCache(legacyPath, destinationPath));
|
||||
Assert.Equal(new byte[] { 1, 2, 3 }, File.ReadAllBytes(destinationPath));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(root))
|
||||
{
|
||||
Directory.Delete(root, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user