[bink] keep guest decode path

This commit is contained in:
ParantezTech
2026-07-18 23:01:57 +03:00
parent 7548911413
commit 9aedb88f3c
2 changed files with 17 additions and 12 deletions
+3 -3
View File
@@ -14,9 +14,9 @@ available, presents its decoded BGRA frames at the normal guest-flip boundary.
This preserves the game's own timing and lets the host Vulkan presenter display This preserves the game's own timing and lets the host Vulkan presenter display
the movie without trying to execute the PS5-specific Bink GPU decode path. the movie without trying to execute the PS5-specific Bink GPU decode path.
Without an adapter, Bink movies are skipped by default: their open call returns Without an adapter, Bink files remain visible to the guest and the game's
not-found so games that mark cinematics as optional progress to their next statically linked decoder runs normally. Set SHARPEMU_BINK_MODE=skip only when
state instead of waiting on an empty Bink GPU texture. explicitly testing a title whose cinematics are optional.
Set SHARPEMU_BINK_MODE=dummy to retain the open and show a built-in, Set SHARPEMU_BINK_MODE=dummy to retain the open and show a built-in,
non-decoded placeholder frame. This requires no SDK, but is a visual diagnostic non-decoded placeholder frame. This requires no SDK, but is a visual diagnostic
+14 -9
View File
@@ -29,10 +29,9 @@ internal static class Bink2MovieBridge
private static bool _availabilityReported; private static bool _availabilityReported;
/// <summary> /// <summary>
/// Returns true when the guest should receive a normal "file not found" /// Returns true only when movie skipping was explicitly requested. Without
/// result for a Bink movie. This is the safe default without a decoder: /// a host adapter the guest must be allowed to run the Bink implementation
/// games that treat movies as optional fall through to their next state /// statically linked into its executable.
/// rather than submitting an empty Bink GPU texture forever.
/// </summary> /// </summary>
internal static bool ShouldSkipGuestMovie(string hostPath) => internal static bool ShouldSkipGuestMovie(string hostPath) =>
hostPath.EndsWith(".bk2", StringComparison.OrdinalIgnoreCase) && hostPath.EndsWith(".bk2", StringComparison.OrdinalIgnoreCase) &&
@@ -53,12 +52,18 @@ internal static class Bink2MovieBridge
return; return;
} }
if (ResolveMode() == MovieMode.Dummy) var mode = ResolveMode();
if (mode == MovieMode.Dummy)
{ {
AttachDummyMovieLocked(hostPath); AttachDummyMovieLocked(hostPath);
return; return;
} }
if (mode != MovieMode.Native)
{
return;
}
var adapter = GetAdapterLocked(); var adapter = GetAdapterLocked();
if (adapter is null) if (adapter is null)
{ {
@@ -165,16 +170,15 @@ internal static class Bink2MovieBridge
return MovieMode.Skip; return MovieMode.Skip;
} }
// With no SDK adapter present, returning "not found" makes optional // Prefer the optional host adapter when one is supplied. Otherwise let
// cinematics advance. Supplying either an explicit path or the normal // the game's statically linked Bink implementation consume the file.
// side-by-side adapter enables native playback automatically.
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SHARPEMU_BINK2_BRIDGE")) || if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SHARPEMU_BINK2_BRIDGE")) ||
EnumerateAdapterCandidates().Any(File.Exists)) EnumerateAdapterCandidates().Any(File.Exists))
{ {
return MovieMode.Native; return MovieMode.Native;
} }
return MovieMode.Skip; return MovieMode.Guest;
} }
private static void AttachDummyMovieLocked(string hostPath) private static void AttachDummyMovieLocked(string hostPath)
@@ -335,6 +339,7 @@ internal static class Bink2MovieBridge
private enum MovieMode private enum MovieMode
{ {
Guest,
Skip, Skip,
Dummy, Dummy,
Native, Native,