Compare commits

...

6 Commits

Author SHA1 Message Date
Fa1dz 418eb7ecea fix(audioout2): wire skipped-submit trace counter (#761) 2026-08-04 03:22:39 +03:00
Foued Attar c086e32f3d Fix GuestDataPool lease leak on non-GPU compute dispatch paths (#759)
ObserveComputeDispatch only returned evaluation's pooled arrays when
evaluationHandledByCpu was set. Dispatches rejected before submission
(empty resource tables, oversized workgroup, compile failure) or a
compute submit that got dropped instead of enqueued (workSequence == 0)
never handed those buffers to a consumer that would return them,
leaking one lease per occurrence and growing GuestDataPool.Shared
without bound over a long session.

Adds GuestDataPool.DiagnosticStats() (outstanding lease count, idle
cached bytes) surfaced in the periodic [LOADER][PERF] line, to catch
this class of regression going forward.

Verified on Ghost of Yotei and Demon's Souls: pool_leases grew
unbounded before the fix (525 in 5 min on Demon's Souls, 1114 in 180s
on Yotei) and stays flat/bounded after (0-6 and 2-18 respectively),
with no behavioral regression observed.
2026-08-03 21:18:23 +03:00
shpeenut22 9e10d7c44a Functions exports in kernel and NpTrophy2 (#749)
* sceNpTrophy2GetTrophyInfoArray export

* sceNpTrophy2GetTrophyInfoArray comment changed

* sceKernelIsTrinityMode & sceKernelGetOpenPsId exports

* deleted console log in KernelIsTrinityMode

* sceKernelGetOpenPsId: fix ORBIS_GEN2_ERROR_INVALID_ARGUMENT casts with uint.
2026-08-03 12:54:07 +03:00
ParantezTech 207441ca95 [asset] upload transparent logo image 2026-08-03 10:43:43 +03:00
ParantezTech 6b8f11a468 [asset] Add logo.psd file for future edits and modifications 2026-08-03 10:37:44 +03:00
Berk da0de5cf92 chore: bump version to 0.0.3-release.2 (#756) 2026-08-03 10:15:53 +03:00
10 changed files with 81 additions and 3 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SharpEmuVersion>0.0.3-hotfix-2</SharpEmuVersion>
<SharpEmuVersion>0.0.3-release.2</SharpEmuVersion>
<Version>$(SharpEmuVersion)</Version>
<RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)'))</RepoRoot>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 656 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

+3 -1
View File
@@ -11307,7 +11307,9 @@ public static partial class AgcExports
}
}
if (evaluationHandledByCpu)
// Rejected/CPU-handled dispatches never hand evaluation's pooled buffers to a
// consumer that would return them; reclaim here to keep GuestDataPool.Shared bounded.
if (evaluationHandledByCpu || !gpuDispatch)
{
ReturnPooledEvaluationArrays(evaluation);
}
@@ -921,6 +921,7 @@ public static class AudioOut2Exports
if (mixedPorts == 0)
{
TraceSubmitSkipped(context, frames, "no-ports");
return false;
}
@@ -942,6 +943,7 @@ public static class AudioOut2Exports
var backend = ResolveContextBackend(context, out var backendName);
if (backend is null)
{
TraceSubmitSkipped(context, frames, "no-backend");
return false;
}
@@ -1212,4 +1214,14 @@ public static class AudioOut2Exports
Console.Error.WriteLine($"[LOADER][TRACE] audio_out2.{message}");
}
}
private static void TraceSubmitSkipped(ContextState context, int frames, string reason)
{
var n = Interlocked.Increment(ref _submitSkipTraceCount);
if (n <= 8 || n % 500 == 0)
{
TraceAudioOut2(
$"context-submit-skip#{n} handle=0x{context.Handle:X} frames={frames} reason={reason}");
}
}
}
+12
View File
@@ -23,6 +23,10 @@ internal static class GuestDataPool
public static void Trim() => ((BoundedByteArrayPool)Shared).Trim();
/// <summary>Outstanding lease count and idle cached bytes, for leak diagnostics.</summary>
public static (int LeaseCount, ulong CachedBytes) DiagnosticStats() =>
((BoundedByteArrayPool)Shared).Stats();
private sealed class BoundedByteArrayPool : ArrayPool<byte>
{
private readonly object _gate = new();
@@ -119,6 +123,14 @@ internal static class GuestDataPool
}
}
public (int LeaseCount, ulong CachedBytes) Stats()
{
lock (_gate)
{
return (_leases.Count, _cachedBytes);
}
}
private int GetAllocationLength(int minimumLength)
{
if (minimumLength <= 16)
+41
View File
@@ -466,4 +466,45 @@ public static class KernelExports
ctx[CpuRegister.Rax] = unchecked((ulong)(-1L));
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
}
[SysAbiExport(
Nid = "tU5e3f9gSiU",
ExportName = "sceKernelIsTrinityMode",
Target = Generation.Gen4 | Generation.Gen5,
LibraryName = "libKernel")]
public static int KernelIsTrinityMode(CpuContext ctx)
{
ctx[CpuRegister.Rax] = 0;
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
}
[SysAbiExport(
Nid = "DLORcroUqbc",
ExportName = "sceKernelGetOpenPsId",
Target = Generation.Gen4 | Generation.Gen5,
LibraryName = "libKernel")]
public static int KernelGetOpenPsId(CpuContext ctx)
{
ulong bufferPtr = ctx[CpuRegister.Rdi];
if (bufferPtr == 0)
{
ctx[CpuRegister.Rax] = unchecked((ulong)(int)OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT;
}
Span<byte> openPsId = stackalloc byte[16];
if (!ctx.Memory.TryWrite(bufferPtr, openPsId))
{
ctx[CpuRegister.Rax] = unchecked((ulong)(int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
}
ctx[CpuRegister.Rax] = 0;
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
}
}
+9
View File
@@ -99,6 +99,15 @@ public static class NpTrophy2Exports
public static int NpTrophy2GetTrophyInfo(CpuContext ctx) =>
SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_FOUND);
[SysAbiExport(
Nid = "y3zHpdZO6ME",
ExportName = "sceNpTrophy2GetTrophyInfoArray",
Target = Generation.Gen5,
LibraryName = "libSceNpTrophy2")]
public static int NpTrophy2GetTrophyInfoArray(CpuContext ctx) =>
SetReturn(ctx, OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_FOUND);
private static int WriteIdAndReturn(CpuContext ctx, ulong outAddress, ref int nextId)
{
if (outAddress == 0)
@@ -1300,10 +1300,12 @@ public static class VideoOutExports
var submitted = Interlocked.Exchange(ref _submittedFrameCount, 0);
var presentedCount = Interlocked.Exchange(ref _presentedFrameCount, 0);
var (draws, drawMs, pipelines, spirvCompiles) = GuestGpu.Current.ReadAndResetPerfCounters();
var (poolLeases, poolCachedBytes) = SharpEmu.Libs.Gpu.GuestDataPool.DiagnosticStats();
Console.Error.WriteLine(
$"[LOADER][PERF] videoout submitted_fps={submitted / elapsedSeconds:F1} " +
$"presented_fps={presentedCount / elapsedSeconds:F1} " +
$"draws={draws} draw_ms={drawMs:F0} pipelines={pipelines} spirv={spirvCompiles}");
$"draws={draws} draw_ms={drawMs:F0} pipelines={pipelines} spirv={spirvCompiles} " +
$"pool_leases={poolLeases} pool_cached_mb={poolCachedBytes / 1024.0 / 1024.0:F1}");
}
private static readonly bool _flipPacingDisabled = string.Equals(