mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-26 04:39:17 +08:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85cc2b9892 | |||
| 293194c40b | |||
| 1f09de8896 | |||
| ddc452b4fc | |||
| 61a97baf85 | |||
| e80f96ecf5 | |||
| d49c0f1f10 | |||
| 1d33ef90fc | |||
| 26a570633c | |||
| e4f89445b9 | |||
| 1254cc1564 | |||
| 503b3f4d6b | |||
| 6b37ab54f2 | |||
| a84d2344fb | |||
| 787d3a1efb | |||
| 884584da67 |
@@ -736,6 +736,9 @@ public sealed partial class DirectExecutionBackend
|
||||
var expectedEqueueTimeout =
|
||||
string.Equals(nid, "fzyMKs9kim0", StringComparison.Ordinal) &&
|
||||
result == OrbisGen2Result.ORBIS_GEN2_ERROR_TIMED_OUT;
|
||||
var expectedEventFlagTimeout =
|
||||
string.Equals(nid, "JTvBflhYazQ", StringComparison.Ordinal) &&
|
||||
result == OrbisGen2Result.ORBIS_GEN2_ERROR_TIMED_OUT;
|
||||
var expectedMutexTrylockBusy =
|
||||
string.Equals(nid, "K-jXhbt2gn4", StringComparison.Ordinal) &&
|
||||
result == OrbisGen2Result.ORBIS_GEN2_ERROR_BUSY;
|
||||
@@ -748,6 +751,7 @@ public sealed partial class DirectExecutionBackend
|
||||
if (!expectedFileProbeMiss &&
|
||||
!expectedTimedWaitTimeout &&
|
||||
!expectedEqueueTimeout &&
|
||||
!expectedEventFlagTimeout &&
|
||||
!expectedMutexTrylockBusy &&
|
||||
!expectedUserServiceNoEvent &&
|
||||
!expectedPrivacyInvalidParameter)
|
||||
@@ -877,7 +881,7 @@ public sealed partial class DirectExecutionBackend
|
||||
"Q2V+iqvjgC0" or // vsnprintf
|
||||
"j4ViWNHEgww" or // strlen
|
||||
"5jNubw4vlAA" or // strnlen
|
||||
"LHMrG7e8G78" or // wcslen
|
||||
"LHMrG7e8G78" or // wcsmisc
|
||||
"WkkeywLJcgU" or // wcslen
|
||||
"Ovb2dSJOAuE" or // strcmp
|
||||
"aesyjrHVWy4" or // strncmp
|
||||
@@ -1082,7 +1086,7 @@ public sealed partial class DirectExecutionBackend
|
||||
"1jfXLRVzisc" => true, // sceKernelUsleep
|
||||
"QcteRwbsnV0" => true, // usleep
|
||||
"n88vx3C5nW8" => true, // gettimeofday
|
||||
"Zxa0VhQVIsk" => true,
|
||||
"Zxa0VhQVTsk" => true, // sceKernelWaitSema
|
||||
"T72hz6ffq08" => true, // scePthreadYield
|
||||
_ => false
|
||||
};
|
||||
|
||||
@@ -45,7 +45,13 @@ public static class Ps5ParamJsonReader
|
||||
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(data);
|
||||
ReadOnlyMemory<byte> json = data;
|
||||
if (json.Span.StartsWith("\uFEFF"u8))
|
||||
{
|
||||
json = json[3..];
|
||||
}
|
||||
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
return TryReadPs5Param(doc.RootElement);
|
||||
}
|
||||
catch (JsonException)
|
||||
@@ -56,12 +62,15 @@ public static class Ps5ParamJsonReader
|
||||
|
||||
private static (string? Title, string? TitleId, string? Version) TryReadPs5Param(JsonElement root)
|
||||
{
|
||||
string? titleId = root.TryGetProperty("titleId", out var eTid) ? eTid.GetString() : null;
|
||||
if (root.ValueKind != JsonValueKind.Object)
|
||||
return (null, null, null);
|
||||
|
||||
var titleId = GetString(root, "titleId");
|
||||
|
||||
string? ver =
|
||||
(root.TryGetProperty("contentVersion", out var cv) ? cv.GetString() : null)
|
||||
?? (root.TryGetProperty("masterVersion", out var mv) ? mv.GetString() : null)
|
||||
?? (root.TryGetProperty("targetContentVersion", out var tv) ? tv.GetString() : null);
|
||||
GetString(root, "contentVersion")
|
||||
?? GetString(root, "masterVersion")
|
||||
?? GetString(root, "targetContentVersion");
|
||||
|
||||
string? title = ExtractTitleName(root);
|
||||
|
||||
@@ -70,34 +79,49 @@ public static class Ps5ParamJsonReader
|
||||
|
||||
private static string? ExtractTitleName(JsonElement root)
|
||||
{
|
||||
if (!root.TryGetProperty("localizedParameters", out var lp))
|
||||
if ((!root.TryGetProperty("localizedParameters", out var lp) || lp.ValueKind != JsonValueKind.Object) &&
|
||||
root.TryGetProperty("disc", out var disc) && disc.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
if (root.TryGetProperty("disc", out var disc) && disc.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
disc.TryGetProperty("localizedParameters", out lp);
|
||||
}
|
||||
disc.TryGetProperty("localizedParameters", out lp);
|
||||
}
|
||||
|
||||
if (lp.ValueKind != JsonValueKind.Object)
|
||||
return null;
|
||||
|
||||
string? defLang = lp.TryGetProperty("defaultLanguage", out var dl) ? dl.GetString() : null;
|
||||
var defLang = GetString(lp, "defaultLanguage");
|
||||
|
||||
if (!string.IsNullOrEmpty(defLang))
|
||||
{
|
||||
if (lp.TryGetProperty(defLang, out var langObj) && langObj.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
if (langObj.TryGetProperty("titleName", out var tn))
|
||||
return tn.GetString();
|
||||
var title = GetString(langObj, "titleName");
|
||||
if (!string.IsNullOrWhiteSpace(title))
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
if (lp.TryGetProperty("en-US", out var en) && en.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
if (en.TryGetProperty("titleName", out var tn2))
|
||||
return tn2.GetString();
|
||||
var title = GetString(en, "titleName");
|
||||
if (!string.IsNullOrWhiteSpace(title))
|
||||
return title;
|
||||
}
|
||||
|
||||
foreach (var property in lp.EnumerateObject())
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
var title = GetString(property.Value, "titleName");
|
||||
if (!string.IsNullOrWhiteSpace(title))
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string? GetString(JsonElement parent, string propertyName) =>
|
||||
parent.TryGetProperty(propertyName, out var value) && value.ValueKind == JsonValueKind.String
|
||||
? value.GetString()
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"_languageName": "العربية",
|
||||
|
||||
"Page.Library": "المكتبة",
|
||||
"Page.Options": "الخيارات",
|
||||
"Page.GameCount.One": "لعبة واحدة",
|
||||
"Page.GameCount.Other": "{0} لعبة",
|
||||
|
||||
"Library.SearchWatermark": "ابحث في المكتبة...",
|
||||
"Library.AddFolder": "+ إضافة مجلد",
|
||||
"Library.Rescan": "⟳ إعادة الفحص",
|
||||
"Library.OpenFile": "فتح ملف...",
|
||||
|
||||
"Library.Context.Launch": "تشغيل",
|
||||
"Library.Context.OpenFolder": "فتح مجلد اللعبة",
|
||||
"Library.Context.CopyPath": "نسخ المسار",
|
||||
"Library.Context.CopyTitleId": "نسخ معرف العنوان",
|
||||
"Library.Context.Remove": "إزالة من المكتبة",
|
||||
|
||||
"Library.Empty.Title": "مكتبتك فارغة",
|
||||
"Library.Empty.Hint": "أضف مجلداً يحتوي على ألعابك للبدء.",
|
||||
"Library.Empty.SearchTitle": "لا توجد ألعاب تطابق بحثك",
|
||||
"Library.Empty.SearchHint": "لا شيء في المكتبة يطابق “{0}”.",
|
||||
"Library.Empty.AddFolder": "+ إضافة مجلد ألعاب",
|
||||
|
||||
"Library.Loading": "جارٍ تحميل المكتبة...",
|
||||
|
||||
"Options.General": "عام",
|
||||
"Options.Section.Emulation": "المحاكاة",
|
||||
"Options.Section.Logging": "التسجيل",
|
||||
"Options.Section.Launcher": "المُشغِّل",
|
||||
|
||||
"Options.CpuEngine.Label": "محرك المعالج",
|
||||
"Options.CpuEngine.Desc": "محرك التنفيذ المستخدم لتشغيل كود اللعبة.",
|
||||
"Options.CpuEngine.Native": "أصلي",
|
||||
|
||||
"Options.Strict.Label": "ربط صارم للمكتبات الديناميكية (dynlib)",
|
||||
"Options.Strict.Desc": "إفشال التشغيل عندما يتعذر التعرف على رمز مستورد.",
|
||||
|
||||
"Options.LogLevel.Label": "مستوى التسجيل",
|
||||
"Options.LogLevel.Desc": "مدى تفصيل مخرجات نافذة سجلات المحاكي.",
|
||||
"Options.LogLevel.Trace": "تتبع",
|
||||
"Options.LogLevel.Debug": "تصحيح الأخطاء",
|
||||
"Options.LogLevel.Info": "معلومات",
|
||||
"Options.LogLevel.Warning": "تحذير",
|
||||
"Options.LogLevel.Error": "خطأ",
|
||||
"Options.LogLevel.Critical": "حرج",
|
||||
|
||||
"Options.TraceImports.Label": "حد تتبع الاستيراد",
|
||||
"Options.TraceImports.Desc": "تتبع أول N استيراد لكل وحدة (0 = إيقاف).",
|
||||
|
||||
"Options.LogToFile.Label": "التسجيل في ملف",
|
||||
"Options.LogToFile.Desc": "نسخ مخرجات المحاكي إلى ملف سجل.",
|
||||
|
||||
"Options.LogFilePath.Label": "مسار ملف السجل",
|
||||
"Options.LogFilePath.Default": "لا يوجد مسار مخصص — تُحفظ السجلات في user/logs بجوار المحاكي.",
|
||||
"Options.LogFilePath.Select": "تحديد...",
|
||||
|
||||
"Options.OverrideLogFile.Label": "الكتابة فوق ملف السجل",
|
||||
"Options.OverrideLogFile.Desc": "استخدام مسار الملف الدقيق بدلاً من إلحاق معرف العنوان والطابع الزمني.",
|
||||
|
||||
"Options.TitleMusic.Label": "موسيقى اللعبة",
|
||||
"Options.TitleMusic.Desc": "تكرار موسيقى المعاينة للعبة المحددة في المكتبة.",
|
||||
|
||||
"Options.Discord.Label": "حالة دسكورد",
|
||||
"Options.Discord.Desc": "إظهار اللعبة قيد التشغيل في ملفك الشخصي على دسكورد.",
|
||||
|
||||
"Options.Language.Label": "لغة المحاكي",
|
||||
"Options.Language.Desc": "اللغة المستخدمة في جميع أنحاء المشغل. تُطبق فوراً.",
|
||||
|
||||
"Common.On": "تشغيل",
|
||||
"Common.Off": "إيقاف",
|
||||
|
||||
"Console.Title": "نافذة السجلات",
|
||||
"Console.SearchWatermark": "بحث...",
|
||||
"Console.AutoScroll": "تمرير تلقائي",
|
||||
"Console.Split": "تقسيم",
|
||||
"Console.Copy": "نسخ",
|
||||
"Console.Clear": "مسح",
|
||||
"Console.WindowTitle": "نافذة سجلات SharpEmu",
|
||||
|
||||
"Launch.NoGameSelected": "لم تُحدد أي لعبة",
|
||||
"Launch.NoGameHint": "اختر لعبة من المكتبة، أو افتح ملف eboot.bin مباشرة.",
|
||||
"Launch.Idle": "خامل",
|
||||
"Launch.Console": "≡ نافذة السجلات",
|
||||
"Launch.Launch": "▶ تشغيل",
|
||||
"Launch.Stop": "■ إيقاف",
|
||||
"Launch.Running": "قيد التشغيل — {0}",
|
||||
"Launch.Stopping": "جارٍ الإيقاف...",
|
||||
"Launch.Exited": "انتهى برمز {0} ({1})",
|
||||
"Launch.ExeNotFound": "لم يُعثر على الملف التنفيذي SharpEmu. ابنِ مشروع SharpEmu.CLI أولاً (dotnet build).",
|
||||
"Launch.LogFile": "ملف السجل: {0}",
|
||||
"Launch.Command": "$ SharpEmu {0}",
|
||||
"Launch.StartFailed": "فشل بدء تشغيل المحاكي: {0}",
|
||||
"Launch.ProcessExited": "انتهت العملية برمز {0} ({1}).",
|
||||
|
||||
"Exit.Ok": "موافق",
|
||||
"Exit.InvalidArguments": "معطيات غير صالحة",
|
||||
"Exit.EbootNotFound": "لم يُعثر على eboot",
|
||||
"Exit.RuntimeException": "استثناء وقت التشغيل",
|
||||
"Exit.EmulationError": "خطأ في المحاكاة",
|
||||
"Exit.Unknown": "غير معروف",
|
||||
|
||||
"Status.EmulatorLocating": "المحاكي: جارٍ تحديد الموقع...",
|
||||
"Status.EmulatorPath": "المحاكي: {0}",
|
||||
"Status.EmulatorNotFound": "المحاكي: لم يُعثر على الملف التنفيذي SharpEmu — ابنِ SharpEmu.CLI أولاً.",
|
||||
"Status.ScanningLibrary": "جارٍ فحص المكتبة...",
|
||||
"Status.AddFolderPrompt": "أضف مجلد ألعاب لملء المكتبة.",
|
||||
"Status.LibraryScanned": "فُحصت المكتبة: {0} لعبة في {1} مجلد.",
|
||||
"Status.CouldNotOpenFolder": "تعذر فتح المجلد: {0}",
|
||||
"Status.CopiedToClipboard": "نُسخ {0} إلى الحافظة.",
|
||||
"Status.RemovedFromLibrary": "أُزيل “{0}” من المكتبة. أعد إضافة مجلده لاستعادته.",
|
||||
"Status.Running": "جارٍ تشغيل {0}",
|
||||
"Status.Stopping": "جارٍ الإيقاف...",
|
||||
"Status.Idle": "خامل",
|
||||
|
||||
"Clipboard.Path": "المسار",
|
||||
"Clipboard.TitleId": "معرف العنوان",
|
||||
|
||||
"Discord.Playing": "يلعب {0}",
|
||||
"Discord.Browsing": "يتصفح المكتبة",
|
||||
|
||||
"Dialog.ChooseGameFolder": "اختر مجلداً يحتوي على ألعاب",
|
||||
"Dialog.OpenExecutable": "افتح ملفاً تنفيذياً لتشغيله",
|
||||
"Dialog.PsExecutables": "ملفات PS التنفيذية",
|
||||
"Dialog.SaveLogFile": "حدد مكان حفظ ملف السجل",
|
||||
"Dialog.PlainTextFiles": "ملفات نصية عادية",
|
||||
"Dialog.LogFiles": "ملفات السجل"
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"_languageName": "Deutsch",
|
||||
|
||||
"Page.Library": "Bibliothek",
|
||||
"Page.Options": "Optionen",
|
||||
"Page.GameCount.One": "1 Spiel",
|
||||
"Page.GameCount.Other": "{0} Spiele",
|
||||
|
||||
"Library.SearchWatermark": "Bibliothek durchsuchen…",
|
||||
"Library.AddFolder": "+ Spielordner hinzufügen",
|
||||
"Library.Rescan": "⟳ Neu scannen",
|
||||
"Library.OpenFile": "Datei öffnen…",
|
||||
|
||||
"Library.Context.Launch": "Starten",
|
||||
"Library.Context.OpenFolder": "Spielordner öffnen",
|
||||
"Library.Context.CopyPath": "Pfad kopieren",
|
||||
"Library.Context.CopyTitleId": "Title ID kopieren",
|
||||
"Library.Context.Remove": "Aus Bibliothek entfernen",
|
||||
|
||||
"Library.Empty.Title": "Deine Bibliothek ist leer",
|
||||
"Library.Empty.Hint": "Füge einen Ordner mit deinen Spielen hinzu, um zu beginnen.",
|
||||
"Library.Empty.SearchTitle": "Keine Spiele gefunden",
|
||||
"Library.Empty.SearchHint": "Nichts in der Bibliothek entspricht "{0}".",
|
||||
"Library.Empty.AddFolder": "+ Spielordner hinzufügen",
|
||||
|
||||
"Library.Loading": "Bibliothek wird geladen…",
|
||||
|
||||
"Options.General": "Allgemein",
|
||||
"Options.Section.Emulation": "EMULATION",
|
||||
"Options.Section.Logging": "PROTOKOLLIERUNG",
|
||||
"Options.Section.Launcher": "LAUNCHER",
|
||||
|
||||
"Options.CpuEngine.Label": "CPU-Engine",
|
||||
"Options.CpuEngine.Desc": "Ausführungs-Engine, die zum Ausführen des Spiel-Codes verwendet wird.",
|
||||
"Options.CpuEngine.Native": "Nativ",
|
||||
|
||||
"Options.Strict.Label": "Strikte dynlib-Auflösung",
|
||||
"Options.Strict.Desc": "Starten abbrechen, wenn ein importiertes Symbol nicht aufgelöst werden kann.",
|
||||
|
||||
"Options.LogLevel.Label": "Protokollstufe",
|
||||
"Options.LogLevel.Desc": "Ausführlichkeit der Emulator-Konsolenausgabe.",
|
||||
"Options.LogLevel.Trace": "Trace",
|
||||
"Options.LogLevel.Debug": "Debug",
|
||||
"Options.LogLevel.Info": "Info",
|
||||
"Options.LogLevel.Warning": "Warnung",
|
||||
"Options.LogLevel.Error": "Fehler",
|
||||
"Options.LogLevel.Critical": "Kritisch",
|
||||
|
||||
"Options.TraceImports.Label": "Import-Trace-Limit",
|
||||
"Options.TraceImports.Desc": "Die ersten N Imports pro Modul verfolgen (0 = aus).",
|
||||
|
||||
"Options.LogToFile.Label": "In Datei protokollieren",
|
||||
"Options.LogToFile.Desc": "Emulator-Ausgabe zusätzlich in eine Log-Datei schreiben.",
|
||||
|
||||
"Options.LogFilePath.Label": "Protokolldatei-Pfad",
|
||||
"Options.LogFilePath.Default": "Kein benutzerdefinierter Pfad – Logs werden im Ordner user/logs neben dem Emulator gespeichert.",
|
||||
"Options.LogFilePath.Select": "Auswählen…",
|
||||
|
||||
"Options.OverrideLogFile.Label": "Protokolldatei überschreiben",
|
||||
"Options.OverrideLogFile.Desc": "Genauen Dateipfad verwenden, statt Title-ID und Zeitstempel anzuhängen.",
|
||||
|
||||
"Options.TitleMusic.Label": "Titel-Musik",
|
||||
"Options.TitleMusic.Desc": "Die Vorschau-Musik des ausgewählten Spiels in der Bibliothek loopend abspielen.",
|
||||
|
||||
"Options.Discord.Label": "Discord-Präsenz",
|
||||
"Options.Discord.Desc": "Zeigt das aktuell gespielte Spiel in deinem Discord-Profil an.",
|
||||
|
||||
"Options.Language.Label": "Emulator-Sprache",
|
||||
"Options.Language.Desc": "Sprache der Benutzeroberfläche. Wird sofort angewendet.",
|
||||
|
||||
"Common.On": "An",
|
||||
"Common.Off": "Aus",
|
||||
|
||||
"Console.Title": "KONSOLE",
|
||||
"Console.SearchWatermark": "Suchen...",
|
||||
"Console.AutoScroll": "Auto-Scroll",
|
||||
"Console.Split": "Teilen",
|
||||
"Console.Copy": "Kopieren",
|
||||
"Console.Clear": "Leeren",
|
||||
"Console.WindowTitle": "SharpEmu Konsole",
|
||||
|
||||
"Launch.NoGameSelected": "Kein Spiel ausgewählt",
|
||||
"Launch.NoGameHint": "Wähle ein Spiel aus der Bibliothek aus oder öffne eine eboot.bin direkt.",
|
||||
"Launch.Idle": "Bereit",
|
||||
"Launch.Console": "≡ Konsole",
|
||||
"Launch.Launch": "▶ Starten",
|
||||
"Launch.Stop": "■ Stoppen",
|
||||
"Launch.Running": "Läuft -- {0}",
|
||||
"Launch.Stopping": "Wird beendet…",
|
||||
"Launch.Exited": "Beendet mit Code {0} ({1})",
|
||||
"Launch.ExeNotFound": "SharpEmu-Executable wurde nicht gefunden. Baue zuerst das SharpEmu.CLI-Projekt (dotnet build).",
|
||||
"Launch.LogFile": "Log-Datei: {0}",
|
||||
"Launch.Command": "$ SharpEmu {0}",
|
||||
"Launch.StartFailed": "Emulator konnte nicht gestartet werden: {0}",
|
||||
"Launch.ProcessExited": "Prozess wurde mit Code {0} ({1}) beendet.",
|
||||
|
||||
"Exit.Ok": "OK",
|
||||
"Exit.InvalidArguments": "Ungültige Argumente",
|
||||
"Exit.EbootNotFound": "eboot nicht gefunden",
|
||||
"Exit.RuntimeException": "Laufzeitfehler",
|
||||
"Exit.EmulationError": "Emulationsfehler",
|
||||
"Exit.Unknown": "unbekannt",
|
||||
|
||||
"Status.EmulatorLocating": "Emulator: wird gesucht…",
|
||||
"Status.EmulatorPath": "Emulator: {0}",
|
||||
"Status.EmulatorNotFound": "Emulator: SharpEmu-Executable nicht gefunden -- baue zuerst SharpEmu.CLI.",
|
||||
"Status.ScanningLibrary": "Bibliothek wird gescannt…",
|
||||
"Status.AddFolderPrompt": "Füge einen Spielordner hinzu, um die Bibliothek zu füllen.",
|
||||
"Status.LibraryScanned": "Bibliothek gescannt: {0} Spiel(e) in {1} Ordner(n).",
|
||||
"Status.CouldNotOpenFolder": "Ordner konnte nicht geöffnet werden: {0}",
|
||||
"Status.CopiedToClipboard": "{0} in die Zwischenablage kopiert.",
|
||||
"Status.RemovedFromLibrary": ""{0}" wurde aus der Bibliothek entfernt. Füge den Ordner erneut hinzu, um es wiederherzustellen.",
|
||||
"Status.Running": "Läuft {0}",
|
||||
"Status.Stopping": "Wird gestoppt…",
|
||||
"Status.Idle": "Bereit",
|
||||
|
||||
"Clipboard.Path": "Pfad",
|
||||
"Clipboard.TitleId": "Title ID",
|
||||
|
||||
"Discord.Playing": "Spielt {0}",
|
||||
"Discord.Browsing": "Durchsucht die Bibliothek",
|
||||
|
||||
"Dialog.ChooseGameFolder": "Spielordner auswählen",
|
||||
"Dialog.OpenExecutable": "Ausführbare Datei zum Starten öffnen",
|
||||
"Dialog.PsExecutables": "PS-Ausführbare Dateien",
|
||||
"Dialog.SaveLogFile": "Protokolldatei speichern unter",
|
||||
"Dialog.PlainTextFiles": "Textdateien",
|
||||
"Dialog.LogFiles": "Protokolldateien"
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"_languageName": "Dansk",
|
||||
|
||||
"Page.Library": "Bibliotek",
|
||||
"Page.Options": "Indstillinger",
|
||||
"Page.GameCount.One": "1 spil",
|
||||
"Page.GameCount.Other": "{0} spil",
|
||||
|
||||
"Library.SearchWatermark": "Søg i biblioteket…",
|
||||
"Library.AddFolder": "+ Tilføj mappe",
|
||||
"Library.Rescan": "⟳ Genindlæs",
|
||||
"Library.OpenFile": "Åbn fil…",
|
||||
|
||||
"Library.Context.Launch": "Start",
|
||||
"Library.Context.OpenFolder": "Åbn spilmappe",
|
||||
"Library.Context.CopyPath": "Kopiér sti",
|
||||
"Library.Context.CopyTitleId": "Kopiér titel-ID",
|
||||
"Library.Context.Remove": "Fjern fra bibliotek",
|
||||
|
||||
"Library.Empty.Title": "Dit bibliotek er tomt",
|
||||
"Library.Empty.Hint": "Tilføj en mappe med dine spil for at komme i gang.",
|
||||
"Library.Empty.SearchTitle": "Ingen spil matcher din søgning",
|
||||
"Library.Empty.SearchHint": "Intet i biblioteket matcher “{0}”.",
|
||||
"Library.Empty.AddFolder": "+ Tilføj spilmappe",
|
||||
|
||||
"Library.Loading": "Indlæser bibliotek…",
|
||||
|
||||
"Options.General": "Generelt",
|
||||
"Options.Section.Emulation": "EMULERING",
|
||||
"Options.Section.Logging": "LOGGING",
|
||||
"Options.Section.Launcher": "LAUNCHER",
|
||||
|
||||
"Options.CpuEngine.Label": "CPU-engine",
|
||||
"Options.CpuEngine.Desc": "Den eksekveringsengine der bruges til at køre spilkode.",
|
||||
"Options.CpuEngine.Native": "Native",
|
||||
|
||||
"Options.Strict.Label": "Streng dynlib-opløsning",
|
||||
"Options.Strict.Desc": "Afbryd opstarten, når et importeret symbol ikke kan findes.",
|
||||
|
||||
"Options.LogLevel.Label": "Logniveau",
|
||||
"Options.LogLevel.Desc": "Detaljeringsgrad for emulatorens konsoloutput.",
|
||||
"Options.LogLevel.Trace": "Trace",
|
||||
"Options.LogLevel.Debug": "Debug",
|
||||
"Options.LogLevel.Info": "Info",
|
||||
"Options.LogLevel.Warning": "Advarsel",
|
||||
"Options.LogLevel.Error": "Fejl",
|
||||
"Options.LogLevel.Critical": "Kritisk",
|
||||
|
||||
"Options.TraceImports.Label": "Grænse for import-trace",
|
||||
"Options.TraceImports.Desc": "Spor de første N imports pr. modul (0 = fra).",
|
||||
|
||||
"Options.LogToFile.Label": "Log til fil",
|
||||
"Options.LogToFile.Desc": "Spejl emulatorens output til en logfil.",
|
||||
|
||||
"Options.LogFilePath.Label": "Sti til logfil",
|
||||
"Options.LogFilePath.Default": "Ingen brugerdefineret sti — logs gemmes i user/logs ved siden af emulatoren.",
|
||||
"Options.LogFilePath.Select": "Vælg…",
|
||||
|
||||
"Options.OverrideLogFile.Label": "Tilsidesæt logfil",
|
||||
"Options.OverrideLogFile.Desc": "Brug den præcise filsti i stedet for at tilføje titel-ID og tidsstempel.",
|
||||
|
||||
"Options.TitleMusic.Label": "Titelmusik",
|
||||
"Options.TitleMusic.Desc": "Gentag det valgte spils forhåndsvisningsmusik i biblioteket.",
|
||||
|
||||
"Options.Discord.Label": "Discord-tilstedeværelse",
|
||||
"Options.Discord.Desc": "Vis det kørende spil på din Discord-profil.",
|
||||
|
||||
"Options.Language.Label": "Emulatorsprog",
|
||||
"Options.Language.Desc": "Sprog der bruges i hele launcheren. Anvendes med det samme.",
|
||||
|
||||
"Common.On": "Til",
|
||||
"Common.Off": "Fra",
|
||||
|
||||
"Console.Title": "KONSOL",
|
||||
"Console.SearchWatermark": "Søg...",
|
||||
"Console.AutoScroll": "Auto-scroll",
|
||||
"Console.Split": "Opdel",
|
||||
"Console.Copy": "Kopiér",
|
||||
"Console.Clear": "Ryd",
|
||||
"Console.WindowTitle": "SharpEmu-konsol",
|
||||
|
||||
"Launch.NoGameSelected": "Intet spil valgt",
|
||||
"Launch.NoGameHint": "Vælg et spil fra biblioteket, eller åbn en eboot.bin direkte.",
|
||||
"Launch.Idle": "Inaktiv",
|
||||
"Launch.Console": "≡ Konsol",
|
||||
"Launch.Launch": "▶ Start",
|
||||
"Launch.Stop": "■ Stop",
|
||||
"Launch.Running": "Kører — {0}",
|
||||
"Launch.Stopping": "Stopper…",
|
||||
"Launch.Exited": "Afsluttet med kode {0} ({1})",
|
||||
"Launch.ExeNotFound": "SharpEmu-programmet blev ikke fundet. Byg SharpEmu.CLI-projektet først (dotnet build).",
|
||||
"Launch.LogFile": "Logfil: {0}",
|
||||
"Launch.Command": "$ SharpEmu {0}",
|
||||
"Launch.StartFailed": "Kunne ikke starte emulatoren: {0}",
|
||||
"Launch.ProcessExited": "Processen afsluttede med kode {0} ({1}).",
|
||||
|
||||
"Exit.Ok": "OK",
|
||||
"Exit.InvalidArguments": "ugyldige argumenter",
|
||||
"Exit.EbootNotFound": "eboot ikke fundet",
|
||||
"Exit.RuntimeException": "runtime-fejl",
|
||||
"Exit.EmulationError": "emuleringsfejl",
|
||||
"Exit.Unknown": "ukendt",
|
||||
|
||||
"Status.EmulatorLocating": "Emulator: lokaliserer…",
|
||||
"Status.EmulatorPath": "Emulator: {0}",
|
||||
"Status.EmulatorNotFound": "Emulator: SharpEmu-programmet blev ikke fundet — byg SharpEmu.CLI først.",
|
||||
"Status.ScanningLibrary": "Skanner bibliotek…",
|
||||
"Status.AddFolderPrompt": "Tilføj en spilmappe for at udfylde biblioteket.",
|
||||
"Status.LibraryScanned": "Bibliotek skannet: {0} spil i {1} mappe(r).",
|
||||
"Status.CouldNotOpenFolder": "Kunne ikke åbne mappe: {0}",
|
||||
"Status.CopiedToClipboard": "{0} kopieret til udklipsholderen.",
|
||||
"Status.RemovedFromLibrary": "“{0}” fjernet fra biblioteket. Tilføj mappen igen for at gendanne det.",
|
||||
"Status.Running": "Kører {0}",
|
||||
"Status.Stopping": "Stopper…",
|
||||
"Status.Idle": "Inaktiv",
|
||||
|
||||
"Clipboard.Path": "Sti",
|
||||
"Clipboard.TitleId": "Titel-ID",
|
||||
|
||||
"Discord.Playing": "Spiller {0}",
|
||||
"Discord.Browsing": "Gennemser biblioteket",
|
||||
|
||||
"Dialog.ChooseGameFolder": "Vælg en mappe der indeholder spil",
|
||||
"Dialog.OpenExecutable": "Åbn et program der skal startes",
|
||||
"Dialog.PsExecutables": "PS-programmer",
|
||||
"Dialog.SaveLogFile": "Vælg hvor logfilen skal gemmes",
|
||||
"Dialog.PlainTextFiles": "Almindelige tekstfiler",
|
||||
"Dialog.LogFiles": "Logfiler"
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"_languageName": "Español",
|
||||
|
||||
"Page.Library": "Biblioteca",
|
||||
"Page.Options": "Opciones",
|
||||
"Page.GameCount.One": "1 juego",
|
||||
"Page.GameCount.Other": "{0} juegos",
|
||||
|
||||
"Library.SearchWatermark": "Buscar en la biblioteca…",
|
||||
"Library.AddFolder": "+ Añadir carpeta",
|
||||
"Library.Rescan": "⟳ Volver a escanear",
|
||||
"Library.OpenFile": "Abrir archivo…",
|
||||
|
||||
"Library.Context.Launch": "Iniciar",
|
||||
"Library.Context.OpenFolder": "Abrir carpeta de juegos",
|
||||
"Library.Context.CopyPath": "Copiar ruta",
|
||||
"Library.Context.CopyTitleId": "Copiar ID del título",
|
||||
"Library.Context.Remove": "Eliminar de la biblioteca",
|
||||
|
||||
"Library.Empty.Title": "Tu biblioteca está vacía",
|
||||
"Library.Empty.Hint": "Añade una carpeta que contenga tus juegos para empezar.",
|
||||
"Library.Empty.SearchTitle": "Ningún juego coincide con la búsqueda",
|
||||
"Library.Empty.SearchHint": "No se ha encontrado nada en la biblioteca que coincida con “{0}”.",
|
||||
"Library.Empty.AddFolder": "+ Añadir carpeta de juegos",
|
||||
|
||||
"Library.Loading": "Cargando biblioteca…",
|
||||
|
||||
"Options.General": "General",
|
||||
"Options.Section.Emulation": "EMULACIÓN",
|
||||
"Options.Section.Logging": "LOGS",
|
||||
"Options.Section.Launcher": "LAUNCHER",
|
||||
|
||||
"Options.CpuEngine.Label": "Motor de CPU",
|
||||
"Options.CpuEngine.Desc": "Motor utilizado para ejecutar el código del juego.",
|
||||
"Options.CpuEngine.Native": "Nativo",
|
||||
|
||||
"Options.Strict.Label": "Resolución estricta de dynlib (Bibliotecas dinámicas)",
|
||||
"Options.Strict.Desc": "Detener la ejecución cuando un símbolo importado no se pueda resolver.",
|
||||
|
||||
"Options.LogLevel.Label": "Nivel de Log",
|
||||
"Options.LogLevel.Desc": "Verbosidad de la salida en consola del emulador.",
|
||||
"Options.LogLevel.Trace": "Trazas",
|
||||
"Options.LogLevel.Debug": "Depuración",
|
||||
"Options.LogLevel.Info": "Información",
|
||||
"Options.LogLevel.Warning": "Advertencia",
|
||||
"Options.LogLevel.Error": "Error",
|
||||
"Options.LogLevel.Critical": "Crítico",
|
||||
|
||||
"Options.TraceImports.Label": "Límite de trazado de importaciones",
|
||||
"Options.TraceImports.Desc": "Trazar las primeras N importaciones por módulo (0 = off).",
|
||||
|
||||
"Options.LogToFile.Label": "Registrar log en archivo",
|
||||
"Options.LogToFile.Desc": "Duplicar la salida del emulador en un archivo de logs.",
|
||||
|
||||
"Options.LogFilePath.Label": "Ruta del archivo de Log",
|
||||
"Options.LogFilePath.Default": "Sin ruta personalizada — los logs van a user/logs al lado del emulador.",
|
||||
"Options.LogFilePath.Select": "Seleccionar…",
|
||||
|
||||
"Options.OverrideLogFile.Label": "Sobreescribir archivo de logs",
|
||||
"Options.OverrideLogFile.Desc": "Utilizar la misma ruta para el archivo de logs en vez de añadir la ID del título y marca de tiempo.",
|
||||
|
||||
"Options.TitleMusic.Label": "Música del título",
|
||||
"Options.TitleMusic.Desc": "Repetir en bucle la preview de la música del juego seleccionado en la biblioteca.",
|
||||
|
||||
"Options.Discord.Label": "Actividad de Discord",
|
||||
"Options.Discord.Desc": "Mostrar juego en ejecución en tu perfil de Discord.",
|
||||
|
||||
"Options.Language.Label": "Idioma del emulador",
|
||||
"Options.Language.Desc": "Idioma utilizado en todo el launcher. Se aplica inmediatamente.",
|
||||
|
||||
"Common.On": "Encendido",
|
||||
"Common.Off": "Apagado",
|
||||
|
||||
"Console.Title": "CONSOLA",
|
||||
"Console.SearchWatermark": "Buscar...",
|
||||
"Console.AutoScroll": "Desplazamiento automático",
|
||||
"Console.Split": "Desacoplar",
|
||||
"Console.Copy": "Copiar",
|
||||
"Console.Clear": "Limpiar",
|
||||
"Console.WindowTitle": "Consola SharpEmu",
|
||||
|
||||
"Launch.NoGameSelected": "No hay ningún juego seleccionado",
|
||||
"Launch.NoGameHint": "Selecciona un juego de la biblioteca o abre un eboot.bin directamente.",
|
||||
"Launch.Idle": "Inactivo",
|
||||
"Launch.Console": "≡ Consola",
|
||||
"Launch.Launch": "▶ Iniciar",
|
||||
"Launch.Stop": "■ Detener",
|
||||
"Launch.Running": "En ejecución — {0}",
|
||||
"Launch.Stopping": "Deteniendo…",
|
||||
"Launch.Exited": "Finalizó con el código {0} ({1})",
|
||||
"Launch.ExeNotFound": "No se ha encontrado el ejecutable de SharpEmu. Compila previamente el proyecto SharpEmu.CLI (dotnet build).",
|
||||
"Launch.LogFile": "Archivo de Log: {0}",
|
||||
"Launch.Command": "$ SharpEmu {0}",
|
||||
"Launch.StartFailed": "Error al iniciar el emulador: {0}",
|
||||
"Launch.ProcessExited": "El proceso finalizó con el código {0} ({1}).",
|
||||
|
||||
"Exit.Ok": "OK",
|
||||
"Exit.InvalidArguments": "argumentos no válidos",
|
||||
"Exit.EbootNotFound": "no se encontró eboot",
|
||||
"Exit.RuntimeException": "excepción en tiempo de ejecución",
|
||||
"Exit.EmulationError": "error de emulación",
|
||||
"Exit.Unknown": "desconocido",
|
||||
|
||||
"Status.EmulatorLocating": "Emulador: localizando…",
|
||||
"Status.EmulatorPath": "Emulador: {0}",
|
||||
"Status.EmulatorNotFound": "Emulador: No se encontró el ejecutable de SharpEmu — compila previamente SharpEmu.CLI.",
|
||||
"Status.ScanningLibrary": "Escaneando biblioteca…",
|
||||
"Status.AddFolderPrompt": "Añade una carpeta de juegos para poblar la biblioteca.",
|
||||
"Status.LibraryScanned": "Biblioteca escaneada: Se encontraron {0} juego(s) en {1} carpeta(s).",
|
||||
"Status.CouldNotOpenFolder": "No se ha podido abrir la carpeta: {0}",
|
||||
"Status.CopiedToClipboard": "{0} copiado al portapapeles.",
|
||||
"Status.RemovedFromLibrary": "Se eliminó “{0}” de la biblioteca. Vuelve a añadir su carpeta para restaurarlo.",
|
||||
"Status.Running": "Ejecutando {0}",
|
||||
"Status.Stopping": "Deteniendo…",
|
||||
"Status.Idle": "Inactivo",
|
||||
|
||||
"Clipboard.Path": "Ruta",
|
||||
"Clipboard.TitleId": "ID del título",
|
||||
|
||||
"Discord.Playing": "Jugando a {0}",
|
||||
"Discord.Browsing": "Navegando en la biblioteca, buscando un juego para divertirse.",
|
||||
|
||||
"Dialog.ChooseGameFolder": "Selecciona una carpeta que contenga juegos",
|
||||
"Dialog.OpenExecutable": "Abrir un ejecutable para iniciar",
|
||||
"Dialog.PsExecutables": "Ejecutables de PS",
|
||||
"Dialog.SaveLogFile": "Selecciona dónde guardar el archivo de Logs",
|
||||
"Dialog.PlainTextFiles": "Archivos en texto plano",
|
||||
"Dialog.LogFiles": "Archivos de Log"
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"_languageName": "Français",
|
||||
|
||||
"Page.Library": "Bibliothèque",
|
||||
"Page.Options": "Options",
|
||||
"Page.GameCount.One": "1 jeu",
|
||||
"Page.GameCount.Other": "{0} jeux",
|
||||
|
||||
"Library.SearchWatermark": "Rechercher dans la bibliothèque…",
|
||||
"Library.AddFolder": "+ Ajouter un dossier",
|
||||
"Library.Rescan": "⟳ Analyser à nouveau",
|
||||
"Library.OpenFile": "Ouvrir un fichier…",
|
||||
|
||||
"Library.Context.Launch": "Lancer",
|
||||
"Library.Context.OpenFolder": "Ouvrir le dossier du jeu",
|
||||
"Library.Context.CopyPath": "Copier le chemin",
|
||||
"Library.Context.CopyTitleId": "Copier l’identifiant du jeu",
|
||||
"Library.Context.Remove": "Retirer de la bibliothèque",
|
||||
|
||||
"Library.Empty.Title": "Votre bibliothèque est vide",
|
||||
"Library.Empty.Hint": "Ajoutez un dossier contenant vos jeux pour commencer.",
|
||||
"Library.Empty.SearchTitle": "Aucun jeu ne correspond à votre recherche",
|
||||
"Library.Empty.SearchHint": "Aucun élément de la bibliothèque ne correspond à « {0} ».",
|
||||
"Library.Empty.AddFolder": "+ Ajouter un dossier de jeux",
|
||||
|
||||
"Library.Loading": "Chargement de la bibliothèque…",
|
||||
|
||||
"Options.General": "Général",
|
||||
"Options.Section.Emulation": "ÉMULATION",
|
||||
"Options.Section.Logging": "JOURNALISATION",
|
||||
"Options.Section.Launcher": "LANCEUR",
|
||||
|
||||
"Options.CpuEngine.Label": "Moteur CPU",
|
||||
"Options.CpuEngine.Desc": "Moteur d’exécution utilisé pour exécuter le code du jeu.",
|
||||
"Options.CpuEngine.Native": "Natif",
|
||||
|
||||
"Options.Strict.Label": "Résolution stricte des bibliothèques dynamiques",
|
||||
"Options.Strict.Desc": "Interrompre le lancement lorsqu’un symbole importé ne peut pas être résolu.",
|
||||
|
||||
"Options.LogLevel.Label": "Niveau de journalisation",
|
||||
"Options.LogLevel.Desc": "Niveau de détail des messages affichés dans la console de l’émulateur.",
|
||||
"Options.LogLevel.Trace": "Traçage",
|
||||
"Options.LogLevel.Debug": "Débogage",
|
||||
"Options.LogLevel.Info": "Informations",
|
||||
"Options.LogLevel.Warning": "Avertissements",
|
||||
"Options.LogLevel.Error": "Erreurs",
|
||||
"Options.LogLevel.Critical": "Erreurs critiques",
|
||||
|
||||
"Options.TraceImports.Label": "Limite de traçage des imports",
|
||||
"Options.TraceImports.Desc": "Tracer les N premiers imports de chaque module (0 = désactivé).",
|
||||
|
||||
"Options.LogToFile.Label": "Enregistrer dans un fichier",
|
||||
"Options.LogToFile.Desc": "Copier la sortie de l’émulateur dans un fichier journal.",
|
||||
|
||||
"Options.LogFilePath.Label": "Chemin du fichier journal",
|
||||
"Options.LogFilePath.Default": "Aucun chemin personnalisé — les journaux sont enregistrés dans user/logs à côté de l’émulateur.",
|
||||
"Options.LogFilePath.Select": "Sélectionner…",
|
||||
|
||||
"Options.OverrideLogFile.Label": "Remplacer le fichier journal",
|
||||
"Options.OverrideLogFile.Desc": "Utiliser exactement ce chemin au lieu d’ajouter l’identifiant du jeu et l’horodatage.",
|
||||
|
||||
"Options.TitleMusic.Label": "Musique du jeu",
|
||||
"Options.TitleMusic.Desc": "Lire en boucle la musique d’aperçu du jeu sélectionné dans la bibliothèque.",
|
||||
|
||||
"Options.Discord.Label": "Présence Discord",
|
||||
"Options.Discord.Desc": "Afficher le jeu en cours d’exécution sur votre profil Discord.",
|
||||
|
||||
"Options.Language.Label": "Langue de l’émulateur",
|
||||
"Options.Language.Desc": "Langue utilisée dans l’ensemble du lanceur. Le changement est immédiat.",
|
||||
|
||||
"Common.On": "Activé",
|
||||
"Common.Off": "Désactivé",
|
||||
|
||||
"Console.Title": "CONSOLE",
|
||||
"Console.SearchWatermark": "Rechercher…",
|
||||
"Console.AutoScroll": "Défilement automatique",
|
||||
"Console.Split": "Détacher",
|
||||
"Console.Copy": "Copier",
|
||||
"Console.Clear": "Effacer",
|
||||
"Console.WindowTitle": "Console SharpEmu",
|
||||
|
||||
"Launch.NoGameSelected": "Aucun jeu sélectionné",
|
||||
"Launch.NoGameHint": "Choisissez un jeu dans la bibliothèque ou ouvrez directement un fichier eboot.bin.",
|
||||
"Launch.Idle": "Inactif",
|
||||
"Launch.Console": "≡ Console",
|
||||
"Launch.Launch": "▶ Lancer",
|
||||
"Launch.Stop": "■ Arrêter",
|
||||
"Launch.Running": "En cours d’exécution — {0}",
|
||||
"Launch.Stopping": "Arrêt en cours…",
|
||||
"Launch.Exited": "Processus terminé avec le code {0} ({1})",
|
||||
"Launch.ExeNotFound": "L’exécutable SharpEmu est introuvable. Compilez d’abord le projet SharpEmu.CLI (dotnet build).",
|
||||
"Launch.LogFile": "Fichier journal : {0}",
|
||||
"Launch.Command": "$ SharpEmu {0}",
|
||||
"Launch.StartFailed": "Impossible de démarrer l’émulateur : {0}",
|
||||
"Launch.ProcessExited": "Le processus s’est terminé avec le code {0} ({1}).",
|
||||
|
||||
"Exit.Ok": "OK",
|
||||
"Exit.InvalidArguments": "arguments non valides",
|
||||
"Exit.EbootNotFound": "eboot introuvable",
|
||||
"Exit.RuntimeException": "exception d’exécution",
|
||||
"Exit.EmulationError": "erreur d’émulation",
|
||||
"Exit.Unknown": "inconnu",
|
||||
|
||||
"Status.EmulatorLocating": "Émulateur : recherche en cours…",
|
||||
"Status.EmulatorPath": "Émulateur : {0}",
|
||||
"Status.EmulatorNotFound": "Émulateur : l’exécutable SharpEmu est introuvable — compilez d’abord SharpEmu.CLI.",
|
||||
"Status.ScanningLibrary": "Analyse de la bibliothèque…",
|
||||
"Status.AddFolderPrompt": "Ajoutez un dossier de jeux pour remplir la bibliothèque.",
|
||||
"Status.LibraryScanned": "Bibliothèque analysée : {0} jeu(x) dans {1} dossier(s).",
|
||||
"Status.CouldNotOpenFolder": "Impossible d’ouvrir le dossier : {0}",
|
||||
"Status.CopiedToClipboard": "{0} copié dans le presse-papiers.",
|
||||
"Status.RemovedFromLibrary": "« {0} » a été retiré de la bibliothèque. Ajoutez à nouveau son dossier pour le restaurer.",
|
||||
"Status.Running": "Exécution de {0}",
|
||||
"Status.Stopping": "Arrêt en cours…",
|
||||
"Status.Idle": "Inactif",
|
||||
|
||||
"Clipboard.Path": "Chemin",
|
||||
"Clipboard.TitleId": "Identifiant du jeu",
|
||||
|
||||
"Discord.Playing": "Joue à {0}",
|
||||
"Discord.Browsing": "Parcourt la bibliothèque",
|
||||
|
||||
"Dialog.ChooseGameFolder": "Choisir un dossier contenant des jeux",
|
||||
"Dialog.OpenExecutable": "Ouvrir un exécutable à lancer",
|
||||
"Dialog.PsExecutables": "Exécutables PlayStation",
|
||||
"Dialog.SaveLogFile": "Choisir l’emplacement du fichier journal",
|
||||
"Dialog.PlainTextFiles": "Fichiers texte brut",
|
||||
"Dialog.LogFiles": "Fichiers journaux"
|
||||
}
|
||||
+300
-278
@@ -52,8 +52,6 @@ public static class AgcExports
|
||||
private const uint RFlip = 0x17;
|
||||
private const uint RReleaseMem = 0x18;
|
||||
private const uint RDmaData = 0x19;
|
||||
private const uint RPredication = 0x1A;
|
||||
private const uint RJump = 0x1B;
|
||||
private const uint SpiShaderPgmLoPs = 0x8;
|
||||
private const uint SpiShaderPgmHiPs = 0x9;
|
||||
private const uint SpiShaderPgmLoEs = 0xC8;
|
||||
@@ -122,6 +120,9 @@ public static class AgcExports
|
||||
private const uint RegisterDefaultsVersion13 = 13;
|
||||
private const int RegisterDefaultsSize = 0x40;
|
||||
private const int RegisterDefaultBlockSize = 16 * 8;
|
||||
private const ulong ResourceRegistrationBytesPerResource = 0x118;
|
||||
private const ulong ResourceRegistrationBytesPerOwner = 0x1E0;
|
||||
private const int ResourceRegistrationMaxNameLength = 256;
|
||||
|
||||
private const ulong ShaderUserDataOffset = 0x08;
|
||||
private const ulong ShaderCodeOffset = 0x10;
|
||||
@@ -390,10 +391,26 @@ public static class AgcExports
|
||||
public SubmittedDcbState Graphics { get; } = new();
|
||||
public Dictionary<uint, SubmittedDcbState> ComputeQueues { get; } = new();
|
||||
public Dictionary<ulong, ComputeImageWriter> ComputeImageWriters { get; } = new();
|
||||
public Dictionary<uint, string> ResourceOwners { get; } = new();
|
||||
public Dictionary<uint, RegisteredAgcResource> RegisteredResources { get; } = new();
|
||||
public bool ResourceRegistrationInitialized { get; set; }
|
||||
public ulong ResourceRegistrationMemory { get; set; }
|
||||
public ulong ResourceRegistrationMemorySize { get; set; }
|
||||
public uint ResourceRegistrationMaxOwners { get; set; }
|
||||
public uint DefaultOwner { get; set; } = DefaultAgcOwner;
|
||||
public uint NextOwner { get; set; } = 1;
|
||||
public uint NextResource { get; set; } = 1;
|
||||
public ulong WorkSequence { get; set; }
|
||||
public ulong FlipSequence { get; set; }
|
||||
}
|
||||
|
||||
private readonly record struct RegisteredAgcResource(
|
||||
uint Owner,
|
||||
ulong Address,
|
||||
ulong Size,
|
||||
string Name,
|
||||
uint Type,
|
||||
uint Flags);
|
||||
|
||||
private readonly record struct RegisterDefaultValue(uint Offset, uint Value);
|
||||
|
||||
private readonly record struct RegisterDefaultGroup(
|
||||
@@ -1926,90 +1943,6 @@ public static class AgcExports
|
||||
return ReturnPointer(ctx, commandAddress);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "bbFueFP+J4k",
|
||||
ExportName = "sceAgcDcbSetPredication",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DcbSetPredication(CpuContext ctx)
|
||||
{
|
||||
var commandBufferAddress = ctx[CpuRegister.Rdi];
|
||||
var enable = (uint)ctx[CpuRegister.Rsi];
|
||||
var predicateType = (uint)ctx[CpuRegister.Rdx];
|
||||
var continuePredicate = (uint)ctx[CpuRegister.Rcx];
|
||||
var predicateAddress = ctx[CpuRegister.R8];
|
||||
if (commandBufferAddress == 0 || enable > 1 || continuePredicate > 1)
|
||||
{
|
||||
return ReturnPointer(ctx, 0);
|
||||
}
|
||||
|
||||
if (!TryAllocateCommandDwords(ctx, commandBufferAddress, 5, out var commandAddress) ||
|
||||
!ctx.TryWriteUInt32(commandAddress, Pm4(5, ItNop, RPredication)) ||
|
||||
!ctx.TryWriteUInt32(commandAddress + 4, enable) ||
|
||||
!ctx.TryWriteUInt32(commandAddress + 8, predicateType) ||
|
||||
!ctx.TryWriteUInt32(commandAddress + 12, continuePredicate) ||
|
||||
!ctx.TryWriteUInt32(commandAddress + 16, unchecked((uint)predicateAddress)))
|
||||
{
|
||||
return ReturnPointer(ctx, 0);
|
||||
}
|
||||
|
||||
TraceAgc(
|
||||
$"agc.dcb_set_predication buf=0x{commandBufferAddress:X16} cmd=0x{commandAddress:X16} " +
|
||||
$"enable={enable} type={predicateType} continue={continuePredicate} addr=0x{predicateAddress:X16}");
|
||||
return ReturnPointer(ctx, commandAddress);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "xSAR0LTcRKM",
|
||||
ExportName = "sceAgcDcbJump",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DcbJump(CpuContext ctx)
|
||||
{
|
||||
var commandBufferAddress = ctx[CpuRegister.Rdi];
|
||||
var targetAddress = ctx[CpuRegister.Rsi];
|
||||
if (commandBufferAddress == 0)
|
||||
{
|
||||
return ReturnPointer(ctx, 0);
|
||||
}
|
||||
|
||||
if (!TryAllocateCommandDwords(ctx, commandBufferAddress, 3, out var commandAddress) ||
|
||||
!ctx.TryWriteUInt32(commandAddress, Pm4(3, ItNop, RJump)) ||
|
||||
!ctx.TryWriteUInt32(commandAddress + 4, unchecked((uint)targetAddress)) ||
|
||||
!ctx.TryWriteUInt32(commandAddress + 8, unchecked((uint)(targetAddress >> 32))))
|
||||
{
|
||||
return ReturnPointer(ctx, 0);
|
||||
}
|
||||
|
||||
TraceAgc(
|
||||
$"agc.dcb_jump buf=0x{commandBufferAddress:X16} cmd=0x{commandAddress:X16} " +
|
||||
$"target=0x{targetAddress:X16}");
|
||||
return ReturnPointer(ctx, commandAddress);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "w6Dj1VJt5qY",
|
||||
ExportName = "sceAgcSetPacketPredication",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int SetPacketPredication(CpuContext ctx)
|
||||
{
|
||||
var packetAddress = ctx[CpuRegister.Rdi];
|
||||
var enabled = ctx[CpuRegister.Rsi] != 0;
|
||||
if (packetAddress == 0 || !ctx.TryReadUInt32(packetAddress, out var packetHeader))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
packetHeader = enabled ? packetHeader | 1u : packetHeader & ~1u;
|
||||
if (!ctx.TryWriteUInt32(packetAddress, packetHeader))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "w2rJhmD+dsE",
|
||||
ExportName = "sceAgcDriverAddEqEvent",
|
||||
@@ -2062,22 +1995,9 @@ public static class AgcExports
|
||||
public static int DriverSubmitDcb(CpuContext ctx)
|
||||
{
|
||||
var packetAddress = ctx[CpuRegister.Rdi];
|
||||
// Gen5 supports direct RSI/RDX and packed RDI submissions.
|
||||
var commandAddress = ctx[CpuRegister.Rsi];
|
||||
var directDwordCount = ctx[CpuRegister.Rdx];
|
||||
uint dwordCount;
|
||||
var directArguments = commandAddress != 0 &&
|
||||
directDwordCount is > 0 and <= 1_000_000UL;
|
||||
if (directArguments)
|
||||
{
|
||||
dwordCount = (uint)directDwordCount;
|
||||
}
|
||||
else if (packetAddress == 0 ||
|
||||
!ctx.TryReadUInt64(packetAddress, out commandAddress) ||
|
||||
!ctx.TryReadUInt32(packetAddress + 8, out dwordCount) ||
|
||||
commandAddress == 0 ||
|
||||
dwordCount == 0 ||
|
||||
dwordCount > 1_000_000)
|
||||
if (packetAddress == 0 ||
|
||||
!ctx.TryReadUInt64(packetAddress, out var commandAddress) ||
|
||||
!ctx.TryReadUInt32(packetAddress + 8, out var dwordCount))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
@@ -2093,29 +2013,16 @@ public static class AgcExports
|
||||
|
||||
if (tracePackets)
|
||||
{
|
||||
TraceAgc(
|
||||
$"agc.driver_submit_dcb abi={(directArguments ? "direct" : "packed")} " +
|
||||
$"packet=0x{packetAddress:X16} addr=0x{commandAddress:X16} dwords={dwordCount}");
|
||||
TraceAgc($"agc.driver_submit_dcb packet=0x{packetAddress:X16} addr=0x{commandAddress:X16} dwords={dwordCount}");
|
||||
}
|
||||
|
||||
var gpuState = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
ulong flipSequenceBefore;
|
||||
lock (gpuState.Gate)
|
||||
{
|
||||
flipSequenceBefore = gpuState.FlipSequence;
|
||||
ParseSubmittedDcb(ctx, gpuState, gpuState.Graphics, commandAddress, dwordCount, tracePackets);
|
||||
DrainResumableDcbs(ctx, gpuState, tracePackets);
|
||||
}
|
||||
|
||||
// Flip submissions are completed through VideoOut pacing.
|
||||
if (gpuState.FlipSequence == flipSequenceBefore)
|
||||
{
|
||||
KernelEventQueueCompatExports.TriggerRegisteredEvents(
|
||||
0,
|
||||
KernelEventQueueCompatExports.KernelEventFilterGraphics,
|
||||
0);
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = 0;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
@@ -2141,10 +2048,8 @@ public static class AgcExports
|
||||
Environment.GetEnvironmentVariable("SHARPEMU_LOG_AGC"), "1", StringComparison.Ordinal);
|
||||
|
||||
var gpuState = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
ulong flipSequenceBefore;
|
||||
lock (gpuState.Gate)
|
||||
{
|
||||
flipSequenceBefore = gpuState.FlipSequence;
|
||||
for (uint i = 0; i < bufferCount; i++)
|
||||
{
|
||||
if (!ctx.TryReadUInt64(addressArray + i * 8, out var commandAddress) ||
|
||||
@@ -2168,14 +2073,6 @@ public static class AgcExports
|
||||
DrainResumableDcbs(ctx, gpuState, tracePackets);
|
||||
}
|
||||
|
||||
if (gpuState.FlipSequence == flipSequenceBefore)
|
||||
{
|
||||
KernelEventQueueCompatExports.TriggerRegisteredEvents(
|
||||
0,
|
||||
KernelEventQueueCompatExports.KernelEventFilterGraphics,
|
||||
0);
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = 0;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
@@ -2243,12 +2140,87 @@ public static class AgcExports
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
if (!ctx.TryWriteUInt32(outAddress, 256))
|
||||
if (!ctx.TryWriteUInt32(outAddress, ResourceRegistrationMaxNameLength))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
TraceAgc($"agc.driver_get_resource_registration_max_name_length out=0x{outAddress:X16} value=256");
|
||||
TraceAgc(
|
||||
$"agc.driver_get_resource_registration_max_name_length " +
|
||||
$"out=0x{outAddress:X16} value={ResourceRegistrationMaxNameLength}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "AOLcoIkQDgM",
|
||||
ExportName = "sceAgcDriverQueryResourceRegistrationUserMemoryRequirements",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DriverQueryResourceRegistrationUserMemoryRequirements(CpuContext ctx)
|
||||
{
|
||||
var sizeAddress = ctx[CpuRegister.Rdi];
|
||||
var resourceCount = ctx[CpuRegister.Rsi];
|
||||
var ownerCount = ctx[CpuRegister.Rdx];
|
||||
if (sizeAddress == 0 || resourceCount == 0 || ownerCount == 0)
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
ulong requiredSize;
|
||||
try
|
||||
{
|
||||
requiredSize = checked(
|
||||
resourceCount * ResourceRegistrationBytesPerResource +
|
||||
ownerCount * ResourceRegistrationBytesPerOwner);
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
if (!ctx.TryWriteUInt64(sizeAddress, requiredSize))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
TraceAgc(
|
||||
$"agc.driver_query_resource_registration_memory resources={resourceCount} " +
|
||||
$"owners={ownerCount} bytes=0x{requiredSize:X}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "F0Y42t-3e18",
|
||||
ExportName = "sceAgcDriverInitResourceRegistration",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DriverInitResourceRegistration(CpuContext ctx)
|
||||
{
|
||||
var memoryAddress = ctx[CpuRegister.Rdi];
|
||||
var memorySize = ctx[CpuRegister.Rsi];
|
||||
var ownerCount = ctx[CpuRegister.Rdx];
|
||||
if (memoryAddress == 0 || memorySize == 0 || ownerCount == 0 || ownerCount > uint.MaxValue)
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
var state = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
lock (state.Gate)
|
||||
{
|
||||
state.ResourceRegistrationInitialized = true;
|
||||
state.ResourceRegistrationMemory = memoryAddress;
|
||||
state.ResourceRegistrationMemorySize = memorySize;
|
||||
state.ResourceRegistrationMaxOwners = (uint)ownerCount;
|
||||
state.ResourceOwners.Clear();
|
||||
state.RegisteredResources.Clear();
|
||||
state.DefaultOwner = DefaultAgcOwner;
|
||||
state.NextOwner = 1;
|
||||
state.NextResource = 1;
|
||||
}
|
||||
|
||||
TraceAgc(
|
||||
$"agc.driver_init_resource_registration memory=0x{memoryAddress:X16} " +
|
||||
$"bytes=0x{memorySize:X} owners={ownerCount}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
@@ -2267,12 +2239,97 @@ public static class AgcExports
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
if (!ctx.TryWriteUInt32(ownerAddress, DefaultAgcOwner))
|
||||
var state = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
uint owner;
|
||||
lock (state.Gate)
|
||||
{
|
||||
owner = state.DefaultOwner;
|
||||
}
|
||||
|
||||
if (!ctx.TryWriteUInt32(ownerAddress, owner))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
TraceAgc($"agc.driver_get_default_owner out=0x{ownerAddress:X16} owner={DefaultAgcOwner}");
|
||||
TraceAgc($"agc.driver_get_default_owner out=0x{ownerAddress:X16} owner={owner}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "U9ueyEhSkF4",
|
||||
ExportName = "sceAgcDriverRegisterDefaultOwner",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DriverRegisterDefaultOwner(CpuContext ctx)
|
||||
{
|
||||
var owner = (uint)ctx[CpuRegister.Rdi];
|
||||
var state = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
lock (state.Gate)
|
||||
{
|
||||
state.DefaultOwner = owner;
|
||||
}
|
||||
|
||||
TraceAgc($"agc.driver_register_default_owner owner={owner}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "X-Nm5KLREeg",
|
||||
ExportName = "sceAgcDriverRegisterOwner",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DriverRegisterOwner(CpuContext ctx)
|
||||
{
|
||||
var ownerAddress = ctx[CpuRegister.Rdi];
|
||||
var nameAddress = ctx[CpuRegister.Rsi];
|
||||
if (ownerAddress == 0 || nameAddress == 0 ||
|
||||
!TryReadGuestCString(
|
||||
ctx,
|
||||
nameAddress,
|
||||
ResourceRegistrationMaxNameLength,
|
||||
out var nameBytes))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
var state = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
uint owner;
|
||||
lock (state.Gate)
|
||||
{
|
||||
if (!state.ResourceRegistrationInitialized ||
|
||||
state.ResourceRegistrationMaxOwners != 0 &&
|
||||
state.ResourceOwners.Count >= state.ResourceRegistrationMaxOwners)
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
owner = state.NextOwner;
|
||||
while (owner == state.DefaultOwner || state.ResourceOwners.ContainsKey(owner))
|
||||
{
|
||||
owner++;
|
||||
if (owner == 0)
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
state.NextOwner = owner + 1;
|
||||
state.ResourceOwners.Add(owner, System.Text.Encoding.UTF8.GetString(nameBytes));
|
||||
}
|
||||
|
||||
if (!ctx.TryWriteUInt32(ownerAddress, owner))
|
||||
{
|
||||
lock (state.Gate)
|
||||
{
|
||||
state.ResourceOwners.Remove(owner);
|
||||
}
|
||||
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
TraceAgc(
|
||||
$"agc.driver_register_owner out=0x{ownerAddress:X16} owner={owner} " +
|
||||
$"name={System.Text.Encoding.UTF8.GetString(nameBytes)}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
@@ -2283,19 +2340,90 @@ public static class AgcExports
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DriverRegisterResource(CpuContext ctx)
|
||||
{
|
||||
var resourceAddress = ctx[CpuRegister.Rdi];
|
||||
var resourceHandleAddress = ctx[CpuRegister.Rdi];
|
||||
var owner = (uint)ctx[CpuRegister.Rsi];
|
||||
var nameAddress = ctx[CpuRegister.Rdx];
|
||||
var type = (uint)ctx[CpuRegister.R8];
|
||||
var flags = (uint)ctx[CpuRegister.R9];
|
||||
var resourceAddress = ctx[CpuRegister.Rdx];
|
||||
var resourceSize = ctx[CpuRegister.Rcx];
|
||||
var nameAddress = ctx[CpuRegister.R8];
|
||||
var type = (uint)ctx[CpuRegister.R9];
|
||||
if (resourceHandleAddress == 0 || resourceAddress == 0 || resourceSize == 0 ||
|
||||
!ctx.TryReadUInt32(ctx[CpuRegister.Rsp] + sizeof(ulong), out var flags) ||
|
||||
!TryReadGuestCString(
|
||||
ctx,
|
||||
nameAddress,
|
||||
ResourceRegistrationMaxNameLength,
|
||||
out var nameBytes))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
var state = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
uint resourceHandle;
|
||||
lock (state.Gate)
|
||||
{
|
||||
if (!state.ResourceRegistrationInitialized ||
|
||||
owner != state.DefaultOwner &&
|
||||
!state.ResourceOwners.ContainsKey(owner))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
resourceHandle = state.NextResource++;
|
||||
if (resourceHandle == 0)
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
state.RegisteredResources.Add(
|
||||
resourceHandle,
|
||||
new RegisteredAgcResource(
|
||||
owner,
|
||||
resourceAddress,
|
||||
resourceSize,
|
||||
System.Text.Encoding.UTF8.GetString(nameBytes),
|
||||
type,
|
||||
flags));
|
||||
}
|
||||
|
||||
if (!ctx.TryWriteUInt32(resourceHandleAddress, resourceHandle))
|
||||
{
|
||||
lock (state.Gate)
|
||||
{
|
||||
state.RegisteredResources.Remove(resourceHandle);
|
||||
}
|
||||
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
TraceAgc(
|
||||
$"agc.driver_register_resource resource=0x{resourceAddress:X16} owner={owner} " +
|
||||
$"name=0x{nameAddress:X16} type={type} flags={flags}");
|
||||
$"agc.driver_register_resource handle={resourceHandle} owner={owner} " +
|
||||
$"resource=0x{resourceAddress:X16} bytes=0x{resourceSize:X} " +
|
||||
$"name={System.Text.Encoding.UTF8.GetString(nameBytes)} type={type} flags={flags}");
|
||||
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "pWLG7WOpVcw",
|
||||
ExportName = "sceAgcDriverUnregisterResource",
|
||||
Target = Generation.Gen5,
|
||||
LibraryName = "libSceAgc")]
|
||||
public static int DriverUnregisterResource(CpuContext ctx)
|
||||
{
|
||||
var resourceHandle = (uint)ctx[CpuRegister.Rdi];
|
||||
var state = _submittedGpuStates.GetValue(ctx.Memory, static _ => new SubmittedGpuState());
|
||||
lock (state.Gate)
|
||||
{
|
||||
if (!state.RegisteredResources.Remove(resourceHandle))
|
||||
{
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
TraceAgc($"agc.driver_unregister_resource handle={resourceHandle}");
|
||||
return ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "-KRzWekV120",
|
||||
ExportName = "sceAgcDriverUnknown_KRzWekV120",
|
||||
@@ -2424,40 +2552,6 @@ public static class AgcExports
|
||||
}
|
||||
|
||||
var packetType = header >> 30;
|
||||
if (packetType == 0)
|
||||
{
|
||||
// Consume alignment padding one dword at a time.
|
||||
if (header == 0)
|
||||
{
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Preserve stream alignment across type-0 packets.
|
||||
var type0Length = ((header >> 16) & 0x3FFFu) + 2u;
|
||||
if (offset + type0Length > dwordCount)
|
||||
{
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
|
||||
offset += type0Length;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (packetType == 1)
|
||||
{
|
||||
const uint type1Length = 3;
|
||||
if (offset + type1Length > dwordCount)
|
||||
{
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
|
||||
offset += type1Length;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (packetType == 2)
|
||||
{
|
||||
if (tracePackets)
|
||||
@@ -2472,15 +2566,13 @@ public static class AgcExports
|
||||
|
||||
if (packetType != 3)
|
||||
{
|
||||
offset++;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
var length = Pm4Length(header);
|
||||
if (length == 0 || offset + length > dwordCount)
|
||||
{
|
||||
offset++;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
var op = (header >> 8) & 0xFFu;
|
||||
@@ -2718,7 +2810,6 @@ public static class AgcExports
|
||||
|
||||
if (op == ItNop && register == RFlip && length >= 6)
|
||||
{
|
||||
gpuState.FlipSequence++;
|
||||
if (!ctx.TryReadUInt32(currentAddress + 4, out var videoOutHandle) ||
|
||||
!ctx.TryReadUInt32(currentAddress + 8, out var displayBufferIndexRaw) ||
|
||||
!ctx.TryReadUInt32(currentAddress + 12, out var flipMode) ||
|
||||
@@ -2731,8 +2822,23 @@ public static class AgcExports
|
||||
var flipArg = unchecked((long)(((ulong)flipArgHi << 32) | flipArgLo));
|
||||
var displayBufferIndex = unchecked((int)displayBufferIndexRaw);
|
||||
var handle = unchecked((int)videoOutHandle);
|
||||
// Prefer output decoded from the current DCB.
|
||||
if (state.SawIndexedDraw &&
|
||||
if (VideoOutExports.TryGetDisplayBufferInfo(
|
||||
handle,
|
||||
displayBufferIndex,
|
||||
out var cachedDisplayBuffer) &&
|
||||
VulkanVideoPresenter.TrySubmitGuestImage(
|
||||
cachedDisplayBuffer.Address,
|
||||
cachedDisplayBuffer.Width,
|
||||
cachedDisplayBuffer.Height,
|
||||
cachedDisplayBuffer.PitchInPixel))
|
||||
{
|
||||
TraceDisplayBuffer(
|
||||
handle,
|
||||
displayBufferIndex,
|
||||
cachedDisplayBuffer,
|
||||
"gpu-cache");
|
||||
}
|
||||
else if (state.SawIndexedDraw &&
|
||||
state.TranslatedDraw is { } translatedDraw &&
|
||||
VideoOutExports.TryGetDisplayBufferInfo(
|
||||
handle,
|
||||
@@ -2796,22 +2902,6 @@ public static class AgcExports
|
||||
displayBuffer.Width,
|
||||
displayBuffer.Height);
|
||||
}
|
||||
else if (VideoOutExports.TryGetDisplayBufferInfo(
|
||||
handle,
|
||||
displayBufferIndex,
|
||||
out var cachedDisplayBuffer) &&
|
||||
VulkanVideoPresenter.TrySubmitGuestImage(
|
||||
cachedDisplayBuffer.Address,
|
||||
cachedDisplayBuffer.Width,
|
||||
cachedDisplayBuffer.Height,
|
||||
cachedDisplayBuffer.PitchInPixel))
|
||||
{
|
||||
TraceDisplayBuffer(
|
||||
handle,
|
||||
displayBufferIndex,
|
||||
cachedDisplayBuffer,
|
||||
"gpu-cache");
|
||||
}
|
||||
|
||||
_ = VideoOutExports.SubmitFlipFromAgc(ctx, handle, displayBufferIndex, unchecked((int)flipMode), flipArg);
|
||||
state.SawIndexedDraw = false;
|
||||
@@ -4133,29 +4223,26 @@ public static class AgcExports
|
||||
|
||||
TraceTextureHash(descriptor, source);
|
||||
|
||||
if (_traceAgcShader)
|
||||
var nonZero = 0;
|
||||
for (var i = 0; i < source.Length; i++)
|
||||
{
|
||||
var nonZero = 0;
|
||||
for (var i = 0; i < source.Length; i++)
|
||||
if (source[i] != 0)
|
||||
{
|
||||
if (source[i] != 0)
|
||||
nonZero++;
|
||||
if (nonZero >= 64)
|
||||
{
|
||||
nonZero++;
|
||||
if (nonZero >= 64)
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TraceAgcShader(
|
||||
$"agc.texture_source addr=0x{descriptor.Address:X16} " +
|
||||
$"fmt={descriptor.Format} num={descriptor.NumberType} tile={descriptor.TileMode} " +
|
||||
$"size={descriptor.Width}x{descriptor.Height} pitch={descriptor.Pitch} " +
|
||||
$"dst=0x{descriptor.DstSelect:X3} " +
|
||||
$"bytes={source.Length} nonzero64={nonZero}");
|
||||
}
|
||||
|
||||
TraceAgcShader(
|
||||
$"agc.texture_source addr=0x{descriptor.Address:X16} " +
|
||||
$"fmt={descriptor.Format} num={descriptor.NumberType} tile={descriptor.TileMode} " +
|
||||
$"size={descriptor.Width}x{descriptor.Height} pitch={descriptor.Pitch} " +
|
||||
$"dst=0x{descriptor.DstSelect:X3} " +
|
||||
$"bytes={source.Length} nonzero64={nonZero}");
|
||||
|
||||
var rgba = source;
|
||||
texture = new VulkanGuestDrawTexture(
|
||||
descriptor.Address,
|
||||
@@ -4414,7 +4501,7 @@ public static class AgcExports
|
||||
var localSizeZ = GetComputeLocalSize(state.ShRegisters, ComputeNumThreadZ);
|
||||
var gpuDispatch = false;
|
||||
var computeError = string.Empty;
|
||||
if (hasStorageBinding &&
|
||||
if ((hasStorageBinding || evaluation.GlobalMemoryBindings.Count != 0) &&
|
||||
(ulong)localSizeX * localSizeY * localSizeZ <= 1024)
|
||||
{
|
||||
var shaderKey = (
|
||||
@@ -4484,7 +4571,8 @@ public static class AgcExports
|
||||
$"groups={dispatch.GroupCountX}x{dispatch.GroupCountY}x{dispatch.GroupCountZ} " +
|
||||
$"local={localSizeX}x{localSizeY}x{localSizeZ} " +
|
||||
$"sys={DescribeComputeSystemRegisters(computeSystemRegisters)} " +
|
||||
$"gpu={gpuDispatch} blits={blitCount}" +
|
||||
$"gpu={gpuDispatch} blits={blitCount} " +
|
||||
$"globals={evaluation.GlobalMemoryBindings.Count}" +
|
||||
(computeError.Length == 0 ? string.Empty : $" error={computeError}") +
|
||||
$" bindings=[{string.Join(',', descriptions)}]");
|
||||
}
|
||||
@@ -5865,16 +5953,6 @@ public static class AgcExports
|
||||
Console.Error.WriteLine($"[LOADER][TRACE] {message}");
|
||||
}
|
||||
|
||||
private static void TraceAgc(ref AgcTraceHandler message)
|
||||
{
|
||||
if (!_traceAgc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Console.Error.WriteLine($"[LOADER][TRACE] {message.ToStringAndClear()}");
|
||||
}
|
||||
|
||||
private static void TraceAgcShader(string message)
|
||||
{
|
||||
if (!_traceAgcShader)
|
||||
@@ -5885,62 +5963,6 @@ public static class AgcExports
|
||||
Console.Error.WriteLine($"[LOADER][TRACE] {message}");
|
||||
}
|
||||
|
||||
private static void TraceAgcShader(ref AgcShaderTraceHandler message)
|
||||
{
|
||||
if (!_traceAgcShader)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Console.Error.WriteLine($"[LOADER][TRACE] {message.ToStringAndClear()}");
|
||||
}
|
||||
|
||||
[InterpolatedStringHandler]
|
||||
internal ref struct AgcTraceHandler
|
||||
{
|
||||
private DefaultInterpolatedStringHandler _inner;
|
||||
|
||||
public AgcTraceHandler(int literalLength, int formattedCount, out bool isEnabled)
|
||||
{
|
||||
isEnabled = _traceAgc;
|
||||
_inner = isEnabled
|
||||
? new DefaultInterpolatedStringHandler(literalLength, formattedCount)
|
||||
: default;
|
||||
}
|
||||
|
||||
public void AppendLiteral(string value) => _inner.AppendLiteral(value);
|
||||
|
||||
public void AppendFormatted<T>(T value) => _inner.AppendFormatted(value);
|
||||
|
||||
public void AppendFormatted<T>(T value, string? format) =>
|
||||
_inner.AppendFormatted(value, format);
|
||||
|
||||
public string ToStringAndClear() => _inner.ToStringAndClear();
|
||||
}
|
||||
|
||||
[InterpolatedStringHandler]
|
||||
internal ref struct AgcShaderTraceHandler
|
||||
{
|
||||
private DefaultInterpolatedStringHandler _inner;
|
||||
|
||||
public AgcShaderTraceHandler(int literalLength, int formattedCount, out bool isEnabled)
|
||||
{
|
||||
isEnabled = _traceAgcShader;
|
||||
_inner = isEnabled
|
||||
? new DefaultInterpolatedStringHandler(literalLength, formattedCount)
|
||||
: default;
|
||||
}
|
||||
|
||||
public void AppendLiteral(string value) => _inner.AppendLiteral(value);
|
||||
|
||||
public void AppendFormatted<T>(T value) => _inner.AppendFormatted(value);
|
||||
|
||||
public void AppendFormatted<T>(T value, string? format) =>
|
||||
_inner.AppendFormatted(value, format);
|
||||
|
||||
public string ToStringAndClear() => _inner.ToStringAndClear();
|
||||
}
|
||||
|
||||
private static string FormatShaderDwords(IReadOnlyList<uint> values) =>
|
||||
values.Count == 0
|
||||
? "none"
|
||||
|
||||
@@ -802,8 +802,15 @@ internal static class Gen5ShaderTranslator
|
||||
0x14 => "VCmpxGtF32",
|
||||
0x15 => "VCmpxLgF32",
|
||||
0x16 => "VCmpxGeF32",
|
||||
0x17 => "VCmpxOF32",
|
||||
0x18 => "VCmpxUF32",
|
||||
0x19 => "VCmpxNgeF32",
|
||||
0x1A => "VCmpxNlgF32",
|
||||
0x1B => "VCmpxNgtF32",
|
||||
0x1C => "VCmpxNleF32",
|
||||
0x1D => "VCmpxNeqF32",
|
||||
0x1E => "VCmpxNltF32",
|
||||
0x1F => "VCmpxTruF32",
|
||||
0x80 => "VCmpFI32",
|
||||
0x81 => "VCmpLtI32",
|
||||
0x82 => "VCmpEqI32",
|
||||
|
||||
@@ -396,6 +396,14 @@ internal static partial class Gen5SpirvTranslator
|
||||
_module.Constant64(_ulongType, 32)));
|
||||
break;
|
||||
}
|
||||
case "VBcntU32B32":
|
||||
result = IAdd(
|
||||
_module.AddInstruction(
|
||||
SpirvOp.BitCount,
|
||||
_uintType,
|
||||
GetRawSource(instruction, 0)),
|
||||
GetRawSource(instruction, 1));
|
||||
break;
|
||||
case "VMadU32U24":
|
||||
{
|
||||
var left = BitwiseAnd(
|
||||
@@ -593,6 +601,18 @@ internal static partial class Gen5SpirvTranslator
|
||||
Ext(38, _uintType, high, right));
|
||||
break;
|
||||
}
|
||||
case "VSadU32":
|
||||
{
|
||||
var left = GetRawSource(instruction, 0);
|
||||
var right = GetRawSource(instruction, 1);
|
||||
var difference = _module.AddInstruction(
|
||||
SpirvOp.ISub,
|
||||
_uintType,
|
||||
Ext(41, _uintType, left, right),
|
||||
Ext(38, _uintType, left, right));
|
||||
result = IAdd(difference, GetRawSource(instruction, 2));
|
||||
break;
|
||||
}
|
||||
case "VMed3I32":
|
||||
{
|
||||
var left = Bitcast(_intType, GetRawSource(instruction, 0));
|
||||
@@ -702,6 +722,14 @@ internal static partial class Gen5SpirvTranslator
|
||||
result = Ext(58, _uintType, vector);
|
||||
break;
|
||||
}
|
||||
case "VCvtPkU16U32":
|
||||
case "VCvtPkI16I32":
|
||||
result = BitwiseOr(
|
||||
BitwiseAnd(GetRawSource(instruction, 0), UInt(0xFFFF)),
|
||||
ShiftLeftLogical(
|
||||
BitwiseAnd(GetRawSource(instruction, 1), UInt(0xFFFF)),
|
||||
UInt(16)));
|
||||
break;
|
||||
default:
|
||||
error = $"unsupported vector opcode {instruction.Opcode}";
|
||||
return false;
|
||||
@@ -833,6 +861,25 @@ internal static partial class Gen5SpirvTranslator
|
||||
{
|
||||
condition = _module.ConstantBool(true);
|
||||
}
|
||||
else if (opcode is "VCmpOF32" or "VCmpxOF32" or "VCmpUF32" or "VCmpxUF32")
|
||||
{
|
||||
// The ordered/unordered predicates only test whether either
|
||||
// operand is NaN. SPIR-V's OpOrdered/OpUnordered are Kernel-only,
|
||||
// so build the same result from OpIsNan, which needs no extra
|
||||
// capability: unordered = isnan(a) || isnan(b), ordered = !that.
|
||||
var left = GetFloatSource(instruction, 0);
|
||||
var right = GetFloatSource(instruction, 1);
|
||||
var nanLeft = _module.AddInstruction(SpirvOp.IsNan, _boolType, left);
|
||||
var nanRight = _module.AddInstruction(SpirvOp.IsNan, _boolType, right);
|
||||
var unordered = _module.AddInstruction(
|
||||
SpirvOp.LogicalOr,
|
||||
_boolType,
|
||||
nanLeft,
|
||||
nanRight);
|
||||
condition = opcode is "VCmpUF32" or "VCmpxUF32"
|
||||
? unordered
|
||||
: _module.AddInstruction(SpirvOp.LogicalNot, _boolType, unordered);
|
||||
}
|
||||
else if (opcode is not ("VCmpClassF32" or "VCmpxClassF32") &&
|
||||
opcode.EndsWith("F32", StringComparison.Ordinal))
|
||||
{
|
||||
@@ -847,6 +894,7 @@ internal static partial class Gen5SpirvTranslator
|
||||
"VCmpLgF32" or "VCmpxLgF32" => SpirvOp.FOrdNotEqual,
|
||||
"VCmpGeF32" or "VCmpxGeF32" => SpirvOp.FOrdGreaterThanEqual,
|
||||
"VCmpNeqF32" or "VCmpxNeqF32" => SpirvOp.FUnordNotEqual,
|
||||
"VCmpNlgF32" or "VCmpxNlgF32" => SpirvOp.FUnordEqual,
|
||||
"VCmpNltF32" or "VCmpxNltF32" => SpirvOp.FUnordGreaterThanEqual,
|
||||
"VCmpNleF32" or "VCmpxNleF32" => SpirvOp.FUnordGreaterThan,
|
||||
"VCmpNgtF32" or "VCmpxNgtF32" => SpirvOp.FUnordLessThanEqual,
|
||||
@@ -897,7 +945,8 @@ internal static partial class Gen5SpirvTranslator
|
||||
condition = _module.AddInstruction(operation, _boolType, left, right);
|
||||
}
|
||||
|
||||
StoreWaveMask(106, condition);
|
||||
// On gfx10, VCmpx writes EXEC only and preserves VCC; the sdst
|
||||
// operand was removed from the cmpx encodings on this generation.
|
||||
if (opcode.StartsWith("VCmpx", StringComparison.Ordinal))
|
||||
{
|
||||
var active = _module.AddInstruction(
|
||||
@@ -907,6 +956,10 @@ internal static partial class Gen5SpirvTranslator
|
||||
condition);
|
||||
StoreWaveMask(126, active);
|
||||
}
|
||||
else
|
||||
{
|
||||
StoreWaveMask(106, condition);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1303,6 +1356,43 @@ internal static partial class Gen5SpirvTranslator
|
||||
Store(_scc, IsNotZero(result));
|
||||
break;
|
||||
}
|
||||
case "SAbsdiffI32":
|
||||
{
|
||||
var wideLeft = _module.AddInstruction(
|
||||
SpirvOp.SConvert,
|
||||
_longType,
|
||||
Bitcast(_intType, left));
|
||||
var wideRight = _module.AddInstruction(
|
||||
SpirvOp.SConvert,
|
||||
_longType,
|
||||
Bitcast(_intType, right));
|
||||
var difference = _module.AddInstruction(
|
||||
SpirvOp.ISub,
|
||||
_longType,
|
||||
wideLeft,
|
||||
wideRight);
|
||||
result = _module.AddInstruction(
|
||||
SpirvOp.UConvert,
|
||||
_uintType,
|
||||
Ext(5, _longType, difference));
|
||||
Store(_scc, IsNotZero(result));
|
||||
break;
|
||||
}
|
||||
case "SPackLlB32B16":
|
||||
result = BitwiseOr(
|
||||
BitwiseAnd(left, UInt(0xFFFF)),
|
||||
ShiftLeftLogical(right, UInt(16)));
|
||||
break;
|
||||
case "SPackLhB32B16":
|
||||
result = BitwiseOr(
|
||||
BitwiseAnd(left, UInt(0xFFFF)),
|
||||
BitwiseAnd(right, UInt(0xFFFF0000)));
|
||||
break;
|
||||
case "SPackHhB32B16":
|
||||
result = BitwiseOr(
|
||||
ShiftRightLogical(left, UInt(16)),
|
||||
BitwiseAnd(right, UInt(0xFFFF0000)));
|
||||
break;
|
||||
case "SCselectB32":
|
||||
result = _module.AddInstruction(
|
||||
SpirvOp.Select,
|
||||
|
||||
@@ -80,7 +80,7 @@ public static class JsonExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "WSOuge5IsCg",
|
||||
ExportName = "_ZN3sce4Json15InitParameter2C2Ev",
|
||||
ExportName = "_ZN3sce4Json14InitParameter2C1Ev",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libSceJson2")]
|
||||
public static int InitParameter2Constructor(CpuContext ctx)
|
||||
@@ -93,7 +93,7 @@ public static class JsonExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "I2QC8PYhJWY",
|
||||
ExportName = "_ZN3sce4Json15InitParameter212setAllocatorERNS0_12MemAllocatorE",
|
||||
ExportName = "_ZN3sce4Json14InitParameter212setAllocatorEPNS0_12MemAllocatorEPv",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libSceJson2")]
|
||||
public static int InitParameter2SetAllocator(CpuContext ctx)
|
||||
@@ -106,7 +106,7 @@ public static class JsonExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "Eu95jmqn5Rw",
|
||||
ExportName = "_ZN3sce4Json15InitParameter217setFileBufferSizeEm",
|
||||
ExportName = "_ZN3sce4Json14InitParameter217setFileBufferSizeEm",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libSceJson2")]
|
||||
public static int InitParameter2SetFileBufferSize(CpuContext ctx)
|
||||
@@ -119,7 +119,7 @@ public static class JsonExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "IXW-z8pggfg",
|
||||
ExportName = "_ZN3sce4Json12Initializer2C1Ev",
|
||||
ExportName = "_ZN3sce4Json11Initializer10initializeEPKNS0_14InitParameter2E",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libSceJson2")]
|
||||
public static int Initializer2Constructor(CpuContext ctx)
|
||||
|
||||
@@ -478,7 +478,7 @@ public static class KernelMemoryCompatExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "LHMrG7e8G78",
|
||||
ExportName = "wcslen",
|
||||
ExportName = "wcsmisc",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Wcslen(CpuContext ctx)
|
||||
@@ -1488,6 +1488,214 @@ public static class KernelMemoryCompatExports
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "ob5xAW4ln-0",
|
||||
ExportName = "strchr",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Strchr(CpuContext ctx)
|
||||
{
|
||||
var address = ctx[CpuRegister.Rdi];
|
||||
var needle = unchecked((byte)ctx[CpuRegister.Rsi]);
|
||||
if (address == 0)
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
// The terminator counts as part of the scanned range, so strchr(s, '\0')
|
||||
// returns a pointer to the string's null byte just like a native libc.
|
||||
Span<byte> current = stackalloc byte[1];
|
||||
for (ulong index = 0; index < 1_048_576; index++)
|
||||
{
|
||||
if (!TryReadCompat(ctx, address + index, current))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
if (current[0] == needle)
|
||||
{
|
||||
ctx[CpuRegister.Rax] = address + index;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
if (current[0] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = 0;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "9yDWMxEFdJU",
|
||||
ExportName = "strrchr",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Strrchr(CpuContext ctx)
|
||||
{
|
||||
var address = ctx[CpuRegister.Rdi];
|
||||
var needle = unchecked((byte)ctx[CpuRegister.Rsi]);
|
||||
if (address == 0)
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
ulong match = 0;
|
||||
var found = false;
|
||||
Span<byte> current = stackalloc byte[1];
|
||||
for (ulong index = 0; index < 1_048_576; index++)
|
||||
{
|
||||
if (!TryReadCompat(ctx, address + index, current))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
if (current[0] == needle)
|
||||
{
|
||||
match = address + index;
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (current[0] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = found ? match : 0;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "8u8lPzUEq+U",
|
||||
ExportName = "memchr",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Memchr(CpuContext ctx)
|
||||
{
|
||||
var address = ctx[CpuRegister.Rdi];
|
||||
var needle = unchecked((byte)ctx[CpuRegister.Rsi]);
|
||||
var count = ctx[CpuRegister.Rdx];
|
||||
|
||||
Span<byte> current = stackalloc byte[1];
|
||||
for (ulong index = 0; index < count; index++)
|
||||
{
|
||||
if (!TryReadCompat(ctx, address + index, current))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
if (current[0] == needle)
|
||||
{
|
||||
ctx[CpuRegister.Rax] = address + index;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = 0;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "Ls4tzzhimqQ",
|
||||
ExportName = "strcat",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Strcat(CpuContext ctx)
|
||||
{
|
||||
var destination = ctx[CpuRegister.Rdi];
|
||||
var source = ctx[CpuRegister.Rsi];
|
||||
if (!TryReadCString(ctx, source, 1_048_576, out var sourceBytes))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
if (!TryReadCString(ctx, destination, 1_048_576, out var destinationBytes))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
// Overwrite the destination terminator and re-terminate after the copied bytes.
|
||||
var appendAddress = destination + (ulong)destinationBytes.Length;
|
||||
var payload = new byte[sourceBytes.Length + 1];
|
||||
sourceBytes.CopyTo(payload.AsSpan());
|
||||
if (!TryWriteCompat(ctx, appendAddress, payload))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = destination;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "kHg45qPC6f0",
|
||||
ExportName = "strncat",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Strncat(CpuContext ctx)
|
||||
{
|
||||
var destination = ctx[CpuRegister.Rdi];
|
||||
var source = ctx[CpuRegister.Rsi];
|
||||
var limit = ctx[CpuRegister.Rdx];
|
||||
|
||||
// Bounding the source read by the count yields strncat's "at most n bytes"
|
||||
// semantics while still stopping early at the source terminator.
|
||||
if (!TryReadCString(ctx, source, limit, out var sourceBytes))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
if (!TryReadCString(ctx, destination, 1_048_576, out var destinationBytes))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
var appendAddress = destination + (ulong)destinationBytes.Length;
|
||||
var payload = new byte[sourceBytes.Length + 1];
|
||||
sourceBytes.CopyTo(payload.AsSpan());
|
||||
if (!TryWriteCompat(ctx, appendAddress, payload))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
ctx[CpuRegister.Rax] = destination;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "viiwFMaNamA",
|
||||
ExportName = "strstr",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libc")]
|
||||
public static int Strstr(CpuContext ctx)
|
||||
{
|
||||
var haystack = ctx[CpuRegister.Rdi];
|
||||
var needle = ctx[CpuRegister.Rsi];
|
||||
if (!TryReadCString(ctx, haystack, 1_048_576, out var haystackBytes))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
if (!TryReadCString(ctx, needle, 1_048_576, out var needleBytes))
|
||||
{
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
// An empty needle matches at the start of the haystack.
|
||||
if (needleBytes.Length == 0)
|
||||
{
|
||||
ctx[CpuRegister.Rax] = haystack;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
var matchIndex = haystackBytes.AsSpan().IndexOf(needleBytes.AsSpan());
|
||||
ctx[CpuRegister.Rax] = matchIndex >= 0 ? haystack + (ulong)matchIndex : 0;
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "QrZZdJ8XsX0",
|
||||
ExportName = "fputs",
|
||||
@@ -1683,6 +1891,30 @@ public static class KernelMemoryCompatExports
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "E6ao34wPw+U",
|
||||
ExportName = "stat",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libKernel")]
|
||||
public static int PosixStat(CpuContext ctx)
|
||||
{
|
||||
var result = KernelStat(ctx);
|
||||
if (result == (int)OrbisGen2Result.ORBIS_GEN2_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var errno = result switch
|
||||
{
|
||||
(int)OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT => Einval,
|
||||
(int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT => Efault,
|
||||
_ => 2,
|
||||
};
|
||||
KernelRuntimeCompatExports.TrySetErrno(ctx, errno);
|
||||
ctx[CpuRegister.Rax] = ulong.MaxValue;
|
||||
return -1;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "gEpBkcwxUjw",
|
||||
ExportName = "sceKernelAprResolveFilepathsToIdsAndFileSizes",
|
||||
@@ -3013,7 +3245,7 @@ public static class KernelMemoryCompatExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "4h6F1LLbTiw",
|
||||
ExportName = "sceKernelMapFlexibleMemoryInternal",
|
||||
ExportName = "sceKernelMapNamedFlexibleMemoryInternal",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libKernel")]
|
||||
public static int KernelMapFlexibleMemoryInternal(CpuContext ctx)
|
||||
@@ -3965,7 +4197,7 @@ public static class KernelMemoryCompatExports
|
||||
_ => unchecked((int)argumentSource.NextGpArg())
|
||||
};
|
||||
|
||||
var formatted = value.ToString();
|
||||
var formatted = value.ToString(CultureInfo.InvariantCulture);
|
||||
if (showSign && value >= 0)
|
||||
formatted = "+" + formatted;
|
||||
else if (spaceForSign && value >= 0)
|
||||
@@ -3989,7 +4221,7 @@ public static class KernelMemoryCompatExports
|
||||
_ => (uint)argumentSource.NextGpArg()
|
||||
};
|
||||
|
||||
var formatted = value.ToString();
|
||||
var formatted = value.ToString(CultureInfo.InvariantCulture);
|
||||
sb.Append(PadString(formatted, width, leftAlign, padWithZero && !leftAlign));
|
||||
}
|
||||
break;
|
||||
@@ -4010,8 +4242,8 @@ public static class KernelMemoryCompatExports
|
||||
};
|
||||
|
||||
var formatted = specifier == 'x'
|
||||
? value.ToString("x")
|
||||
: value.ToString("X");
|
||||
? value.ToString("x", CultureInfo.InvariantCulture)
|
||||
: value.ToString("X", CultureInfo.InvariantCulture);
|
||||
|
||||
if (alternateForm && value != 0)
|
||||
formatted = specifier == 'x' ? "0x" + formatted : "0X" + formatted;
|
||||
@@ -4119,7 +4351,10 @@ public static class KernelMemoryCompatExports
|
||||
var formatStr = precision >= 0
|
||||
? $"{{0:{specifier}{precision}}}"
|
||||
: $"{{0:{specifier}}}";
|
||||
var formatted = string.Format(formatStr, value);
|
||||
var formatted = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
formatStr,
|
||||
value);
|
||||
|
||||
if (showSign && value >= 0)
|
||||
formatted = "+" + formatted;
|
||||
|
||||
@@ -431,6 +431,18 @@ public static class KernelRuntimeCompatExports
|
||||
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "HoLVWNanBBc",
|
||||
ExportName = "getpid",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libKernel")]
|
||||
public static int GetProcessId(CpuContext ctx)
|
||||
{
|
||||
var processId = Environment.ProcessId;
|
||||
ctx[CpuRegister.Rax] = unchecked((uint)processId);
|
||||
return processId;
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "fgxnMeTNUtY",
|
||||
ExportName = "sceKernelGetProcessTimeCounter",
|
||||
|
||||
@@ -19,7 +19,7 @@ public static class LibcInternalExports
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "NWtTN10cJzE",
|
||||
ExportName = "LibcHeapGetTraceInfo",
|
||||
ExportName = "sceLibcHeapGetTraceInfo",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "LibcInternalExt")]
|
||||
public static int LibcHeapGetTraceInfo(CpuContext ctx)
|
||||
|
||||
@@ -192,9 +192,43 @@ public static class PadExports
|
||||
LibraryName = "libScePad")]
|
||||
public static int PadSetTriggerEffect(CpuContext ctx)
|
||||
{
|
||||
var handle = unchecked((int)ctx[CpuRegister.Rdi]);
|
||||
var parameterAddress = ctx[CpuRegister.Rsi];
|
||||
if (handle != PrimaryPadHandle)
|
||||
{
|
||||
return ctx.SetReturn(OrbisPadErrorInvalidHandle);
|
||||
}
|
||||
|
||||
if (parameterAddress == 0)
|
||||
{
|
||||
return ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
Span<byte> parameter = stackalloc byte[120];
|
||||
if (!ctx.Memory.TryRead(parameterAddress, parameter))
|
||||
{
|
||||
return ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
|
||||
var triggerMask = parameter[0];
|
||||
XInputReader.SetTriggerRumble(
|
||||
(triggerMask & 0x01) != 0 ? DecodeTriggerVibration(parameter[8..64]) : null,
|
||||
(triggerMask & 0x02) != 0 ? DecodeTriggerVibration(parameter[64..120]) : null);
|
||||
return ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
}
|
||||
|
||||
private static byte DecodeTriggerVibration(ReadOnlySpan<byte> command)
|
||||
{
|
||||
var mode = BinaryPrimitives.ReadUInt32LittleEndian(command);
|
||||
var amplitude = mode switch
|
||||
{
|
||||
3 when command[10] != 0 => command[9],
|
||||
6 when command[8] != 0 => command[9..19].ToArray().Max(),
|
||||
_ => (byte)0,
|
||||
};
|
||||
return (byte)(Math.Min(amplitude, (byte)8) * 255 / 8);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "yFVnOdGxvZY",
|
||||
ExportName = "scePadSetVibration",
|
||||
|
||||
@@ -39,6 +39,8 @@ internal static class XInputReader
|
||||
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>
|
||||
internal static void EnsureStarted()
|
||||
@@ -99,6 +101,31 @@ internal static class XInputReader
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
@@ -108,8 +135,8 @@ internal static class XInputReader
|
||||
|
||||
var vibration = new XInputVibration
|
||||
{
|
||||
LeftMotorSpeed = (ushort)(_motorLeft * 257), // 0..255 -> 0..65535
|
||||
RightMotorSpeed = (ushort)(_motorRight * 257),
|
||||
LeftMotorSpeed = (ushort)(Math.Max(_motorLeft, _triggerLeft) * 257),
|
||||
RightMotorSpeed = (ushort)(Math.Max(_motorRight, _triggerRight) * 257),
|
||||
};
|
||||
_ = XInputSetState((uint)_slot, ref vibration);
|
||||
}
|
||||
@@ -147,6 +174,8 @@ internal static class XInputReader
|
||||
_slot = -1;
|
||||
_motorLeft = 0;
|
||||
_motorRight = 0;
|
||||
_triggerLeft = 0;
|
||||
_triggerRight = 0;
|
||||
_state = default;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,17 @@ public static class SaveDataExports
|
||||
private const uint MountModeCreate2 = 1u << 5;
|
||||
private const int MountResultSize = 0x40;
|
||||
private static readonly object _stateGate = new();
|
||||
private static readonly HashSet<int> _transactionResources = [];
|
||||
private static string? _titleId;
|
||||
private static int _nextTransactionResource;
|
||||
|
||||
public static void ConfigureApplicationInfo(string? titleId)
|
||||
{
|
||||
lock (_stateGate)
|
||||
{
|
||||
_titleId = string.IsNullOrWhiteSpace(titleId) ? null : SanitizePathSegment(titleId.Trim());
|
||||
_transactionResources.Clear();
|
||||
_nextTransactionResource = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,26 +255,32 @@ public static class SaveDataExports
|
||||
LibraryName = "libSceSaveData")]
|
||||
public static int SaveDataCreateTransactionResource(CpuContext ctx)
|
||||
{
|
||||
// Gen5 ABI: memory size, resource output, reserved.
|
||||
var memorySize = ctx[CpuRegister.Rdi];
|
||||
var resourceAddress = ctx[CpuRegister.Rsi];
|
||||
var reserved = ctx[CpuRegister.Rdx];
|
||||
|
||||
if (resourceAddress == 0)
|
||||
int resource;
|
||||
lock (_stateGate)
|
||||
{
|
||||
return ctx.SetReturn(OrbisSaveDataErrorParameter);
|
||||
resource = ++_nextTransactionResource;
|
||||
_transactionResources.Add(resource);
|
||||
}
|
||||
|
||||
// Offline HLE operations carry no transaction state.
|
||||
if (!ctx.TryWriteUInt64(resourceAddress, 0))
|
||||
TraceSaveData($"create_transaction_resource memory_size=0x{memorySize:X} resource={resource}");
|
||||
return ctx.SetReturn(resource);
|
||||
}
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "lJUQuaKqoKY",
|
||||
ExportName = "sceSaveDataDeleteTransactionResource",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libSceSaveData")]
|
||||
public static int SaveDataDeleteTransactionResource(CpuContext ctx)
|
||||
{
|
||||
var resource = unchecked((int)ctx[CpuRegister.Rdi]);
|
||||
lock (_stateGate)
|
||||
{
|
||||
return ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
_transactionResources.Remove(resource);
|
||||
}
|
||||
|
||||
TraceSaveData(
|
||||
$"create_transaction_resource memory_size=0x{memorySize:X} reserved=0x{reserved:X} " +
|
||||
$"resource_addr=0x{resourceAddress:X} resource=0x0");
|
||||
|
||||
TraceSaveData($"delete_transaction_resource resource={resource}");
|
||||
return ctx.SetReturn(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
// Copyright (C) 2026 SharpEmu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
// Synthetic-shader conformance dumper.
|
||||
//
|
||||
// Feeds hand-assembled Gen5 (gfx10) instruction words through the real
|
||||
// decode -> SPIR-V pipeline (Gen5ShaderTranslator / Gen5SpirvTranslator, via
|
||||
// reflection so no emulator source changes are required) and writes the
|
||||
// resulting vertex and compute SPIR-V blobs to disk. The blobs can then be
|
||||
// checked with spirv-val / spirv-dis.
|
||||
//
|
||||
// Programs that contain buffer_store_dword automatically get a single
|
||||
// global-memory binding covering every store, which the emitter exposes as
|
||||
// guestBuffers[0] (descriptor set 0, binding 0).
|
||||
//
|
||||
// Each program carries an expectation: ExpectTranslate=true programs must
|
||||
// decode and emit both stages; ExpectTranslate=false programs pin a decode
|
||||
// failure that must stay loud. Any unexpected outcome makes the tool exit
|
||||
// non-zero, so it can gate scripts/CI.
|
||||
//
|
||||
// Usage: SharpEmu.Tools.ShaderDump [output-directory]
|
||||
|
||||
using System.Buffers.Binary;
|
||||
using System.Reflection;
|
||||
using SharpEmu.HLE;
|
||||
using SharpEmu.Libs.CxxAbi;
|
||||
|
||||
const ulong ProgramAddress = 0x100000;
|
||||
|
||||
(string Name, bool ExpectTranslate, uint[] Words)[] testPrograms =
|
||||
[
|
||||
("fmac", true, [
|
||||
0x560A0501, // v_fmac_f32 v5, v1, v2
|
||||
0x580A0501, 0x42280000, // v_fmamk_f32 v5, v1, 42.0, v2
|
||||
0x5A0A0501, 0x42280000, // v_fmaak_f32 v5, v1, v2, 42.0
|
||||
0xD52B0005, 0x00020501, // v_fmac_f32_e64 v5, v1, v2
|
||||
0xBF810000, // s_endpgm
|
||||
]),
|
||||
("muls", true, [
|
||||
0xD5690005, 0x00020501, // v_mul_lo_u32 v5, v1, v2
|
||||
0xD56A0005, 0x00020501, // v_mul_hi_u32 v5, v1, v2
|
||||
0xD56B0005, 0x00020501, // v_mul_lo_i32 v5, v1, v2
|
||||
0xD56C0005, 0x00020501, // v_mul_hi_i32 v5, v1, v2
|
||||
0xBF810000, // s_endpgm
|
||||
]),
|
||||
("sopp-hints", true, [
|
||||
0xBFA10001, // s_clause 0x1
|
||||
0xBFA30000, // s_waitcnt_depctr 0x0
|
||||
0xBF810000, // s_endpgm
|
||||
]),
|
||||
// s_round_mode / s_denorm_mode write the FP MODE state and must keep
|
||||
// failing decode loudly until their semantics are modeled (see #108);
|
||||
// this program pins that behavior.
|
||||
("sopp-mode", false, [
|
||||
0xBFA40000, // s_round_mode 0x0
|
||||
0xBFA50000, // s_denorm_mode 0x0
|
||||
0xBF810000, // s_endpgm
|
||||
]),
|
||||
// Executable end-to-end test: compute with real ALU instructions, then
|
||||
// buffer_store_dword results to guestBuffers[0] at offsets 0/4/8, prove
|
||||
// that a store with EXEC=0 does not land (offset 12 stays sentinel), and
|
||||
// that stores work again after EXEC is restored (offset 16).
|
||||
("exec", true, [
|
||||
0xBFA10001, // s_clause 0x1 (hint no-op in an executed program, needs #108)
|
||||
0x7E0002FF, 0x3FC00000, // v_mov_b32 v0, 1.5f
|
||||
0x7E0202FF, 0x40100000, // v_mov_b32 v1, 2.25f
|
||||
0x7E0402FF, 0x41200000, // v_mov_b32 v2, 10.0f
|
||||
0x56040300, // v_fmac_f32 v2, v0, v1 -> v2 = fma(1.5, 2.25, 10.0)
|
||||
0x7E0602FF, 0x7FFFFFFF, // v_mov_b32 v3, 0x7FFFFFFF
|
||||
0x7E0802FF, 0x00010003, // v_mov_b32 v4, 0x00010003
|
||||
0xD56C0005, 0x00020903, // v_mul_hi_i32 v5, v3, v4
|
||||
0xD56B0006, 0x00020903, // v_mul_lo_i32 v6, v3, v4
|
||||
0xE0700000, 0x80020200, // buffer_store_dword v2, off, s[8:11], 0
|
||||
0xE0700004, 0x80020500, // buffer_store_dword v5, off, s[8:11], 0 offset:4
|
||||
0xE0700008, 0x80020600, // buffer_store_dword v6, off, s[8:11], 0 offset:8
|
||||
0xBEFE0380, // s_mov_b32 exec_lo, 0 -> lane inactive
|
||||
0xE070000C, 0x80020200, // buffer_store_dword v2, off, s[8:11], 0 offset:12 (masked, must not land)
|
||||
0xBEFE03C1, // s_mov_b32 exec_lo, -1 -> lane active again
|
||||
0xE0700010, 0x80020000, // buffer_store_dword v0, off, s[8:11], 0 offset:16
|
||||
0xBF810000, // s_endpgm
|
||||
]),
|
||||
];
|
||||
|
||||
var assembly = typeof(CxaGuardExports).Assembly;
|
||||
var shaderTranslator = assembly.GetType("SharpEmu.Libs.Agc.Gen5ShaderTranslator")
|
||||
?? throw new InvalidOperationException("Gen5ShaderTranslator not found");
|
||||
var spirvTranslator = assembly.GetType("SharpEmu.Libs.Agc.Gen5SpirvTranslator")
|
||||
?? throw new InvalidOperationException("Gen5SpirvTranslator not found");
|
||||
var describe = shaderTranslator.GetMethod(
|
||||
"Describe",
|
||||
BindingFlags.Public | BindingFlags.Static)
|
||||
?? throw new InvalidOperationException("Gen5ShaderTranslator.Describe not found");
|
||||
var tryDecode = shaderTranslator.GetMethod(
|
||||
"TryDecodeProgram",
|
||||
BindingFlags.NonPublic | BindingFlags.Static)
|
||||
?? throw new InvalidOperationException("Gen5ShaderTranslator.TryDecodeProgram not found");
|
||||
var stateType = assembly.GetType("SharpEmu.Libs.Agc.Gen5ShaderState")
|
||||
?? throw new InvalidOperationException("Gen5ShaderState not found");
|
||||
var evaluationType = assembly.GetType("SharpEmu.Libs.Agc.Gen5ShaderEvaluation")
|
||||
?? throw new InvalidOperationException("Gen5ShaderEvaluation not found");
|
||||
var imageBindingType = assembly.GetType("SharpEmu.Libs.Agc.Gen5ImageBinding")
|
||||
?? throw new InvalidOperationException("Gen5ImageBinding not found");
|
||||
var globalBindingType = assembly.GetType("SharpEmu.Libs.Agc.Gen5GlobalMemoryBinding")
|
||||
?? throw new InvalidOperationException("Gen5GlobalMemoryBinding not found");
|
||||
var tryCompile = spirvTranslator.GetMethod(
|
||||
"TryCompileVertexShader",
|
||||
BindingFlags.Public | BindingFlags.Static)
|
||||
?? throw new InvalidOperationException("Gen5SpirvTranslator.TryCompileVertexShader not found");
|
||||
var tryCompileCompute = spirvTranslator.GetMethod(
|
||||
"TryCompileComputeShader",
|
||||
BindingFlags.Public | BindingFlags.Static)
|
||||
?? throw new InvalidOperationException("Gen5SpirvTranslator.TryCompileComputeShader not found");
|
||||
|
||||
var outputDirectory = args.Length > 0
|
||||
? args[0]
|
||||
: Path.Combine(AppContext.BaseDirectory, "spv");
|
||||
Directory.CreateDirectory(outputDirectory);
|
||||
|
||||
var failures = 0;
|
||||
foreach (var (name, expectTranslate, words) in testPrograms)
|
||||
{
|
||||
var memory = new FakeMemory();
|
||||
memory.AddRegion(ProgramAddress, words);
|
||||
var ctx = new CpuContext(memory, Generation.Gen5);
|
||||
|
||||
Console.WriteLine(
|
||||
$"[{name}] decode: " +
|
||||
(string)describe.Invoke(null, [ctx, ProgramAddress, ProgramAddress])!);
|
||||
|
||||
object?[] decodeArgs = [ctx, ProgramAddress, null, null];
|
||||
if (!(bool)tryDecode.Invoke(null, decodeArgs)!)
|
||||
{
|
||||
if (expectTranslate)
|
||||
{
|
||||
failures++;
|
||||
Console.WriteLine($"[{name}] FAILED: decode error ({decodeArgs[3]})");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"[{name}] decode failed as expected ({decodeArgs[3]})");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!expectTranslate)
|
||||
{
|
||||
failures++;
|
||||
Console.WriteLine(
|
||||
$"[{name}] FAILED: decoded successfully but is pinned as a decode failure — " +
|
||||
"if the new decode support is intentional, its semantics need verifying here first");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Buffer stores need a global-memory binding; the emitter resolves them by
|
||||
// instruction PC, so collect store PCs from the decoded program itself.
|
||||
var programObj = decodeArgs[2]!;
|
||||
var instructions = (System.Collections.IEnumerable)programObj
|
||||
.GetType().GetProperty("Instructions")!.GetValue(programObj)!;
|
||||
var storePcs = new List<uint>();
|
||||
foreach (var instruction in instructions)
|
||||
{
|
||||
var op = (string)instruction.GetType().GetProperty("Opcode")!.GetValue(instruction)!;
|
||||
if (op.StartsWith("BufferStore", StringComparison.Ordinal))
|
||||
{
|
||||
storePcs.Add((uint)instruction.GetType().GetProperty("Pc")!.GetValue(instruction)!);
|
||||
}
|
||||
}
|
||||
|
||||
// The binding's scalar base (8 -> s[8:11]) must match the srsrc field of
|
||||
// the hand-assembled buffer_store words, and the 64-byte backing store
|
||||
// must cover every hand-assembled store offset.
|
||||
var globalBindings = Array.CreateInstance(globalBindingType, storePcs.Count > 0 ? 1 : 0);
|
||||
if (storePcs.Count > 0)
|
||||
{
|
||||
globalBindings.SetValue(
|
||||
Activator.CreateInstance(
|
||||
globalBindingType,
|
||||
8u,
|
||||
0UL,
|
||||
(IReadOnlyList<uint>)storePcs,
|
||||
new byte[64]),
|
||||
0);
|
||||
}
|
||||
|
||||
var state = Activator.CreateInstance(
|
||||
stateType,
|
||||
programObj,
|
||||
new uint[16],
|
||||
null,
|
||||
null,
|
||||
0u)!;
|
||||
var evaluation = Activator.CreateInstance(
|
||||
evaluationType,
|
||||
new uint[256],
|
||||
new uint[256],
|
||||
new Dictionary<uint, IReadOnlyList<uint>>(),
|
||||
Array.CreateInstance(imageBindingType, 0),
|
||||
globalBindings,
|
||||
null,
|
||||
null,
|
||||
null)!;
|
||||
|
||||
object?[] compileArgs = [state, evaluation, null, null, 0, -1, 0];
|
||||
if ((bool)tryCompile.Invoke(null, compileArgs)!)
|
||||
{
|
||||
var shader = compileArgs[2]!;
|
||||
var spirv = (byte[])shader.GetType().GetProperty("Spirv")!.GetValue(shader)!;
|
||||
var path = Path.Combine(outputDirectory, $"{name}.spv");
|
||||
File.WriteAllBytes(path, spirv);
|
||||
Console.WriteLine($"[{name}] emit: success, {spirv.Length} bytes -> {path}");
|
||||
}
|
||||
else
|
||||
{
|
||||
failures++;
|
||||
Console.WriteLine($"[{name}] emit: FAILED ({compileArgs[3]})");
|
||||
}
|
||||
|
||||
object?[] computeArgs = [state, evaluation, 1u, 1u, 1u, null, null];
|
||||
if ((bool)tryCompileCompute.Invoke(null, computeArgs)!)
|
||||
{
|
||||
var shader = computeArgs[5]!;
|
||||
var spirv = (byte[])shader.GetType().GetProperty("Spirv")!.GetValue(shader)!;
|
||||
var path = Path.Combine(outputDirectory, $"{name}-cs.spv");
|
||||
File.WriteAllBytes(path, spirv);
|
||||
Console.WriteLine($"[{name}] compute emit: success, {spirv.Length} bytes -> {path}");
|
||||
}
|
||||
else
|
||||
{
|
||||
failures++;
|
||||
Console.WriteLine($"[{name}] compute emit: FAILED ({computeArgs[6]})");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine(failures == 0
|
||||
? "RESULT: all programs behaved as expected"
|
||||
: $"RESULT: {failures} unexpected outcome(s)");
|
||||
Environment.ExitCode = failures == 0 ? 0 : 1;
|
||||
|
||||
internal sealed class FakeMemory : ICpuMemory
|
||||
{
|
||||
private readonly List<(ulong Base, byte[] Data)> _regions = [];
|
||||
|
||||
public void AddRegion(ulong baseAddress, uint[] words)
|
||||
{
|
||||
var bytes = new byte[words.Length * sizeof(uint)];
|
||||
for (var index = 0; index < words.Length; index++)
|
||||
{
|
||||
BinaryPrimitives.WriteUInt32LittleEndian(
|
||||
bytes.AsSpan(index * sizeof(uint)),
|
||||
words[index]);
|
||||
}
|
||||
|
||||
_regions.Add((baseAddress, bytes));
|
||||
}
|
||||
|
||||
public bool TryRead(ulong virtualAddress, Span<byte> destination)
|
||||
{
|
||||
foreach (var (baseAddress, data) in _regions)
|
||||
{
|
||||
if (virtualAddress >= baseAddress &&
|
||||
virtualAddress + (ulong)destination.Length <= baseAddress + (ulong)data.Length)
|
||||
{
|
||||
data.AsSpan(
|
||||
(int)(virtualAddress - baseAddress),
|
||||
destination.Length).CopyTo(destination);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryWrite(ulong virtualAddress, ReadOnlySpan<byte> source) => false;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<!--
|
||||
Copyright (C) 2026 SharpEmu Emulator Project
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
-->
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- Standalone dev tool: opt out of the repo-wide lock-file requirement
|
||||
so no packages.lock.json is generated or committed for it. -->
|
||||
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\SharpEmu.Libs\SharpEmu.Libs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user