[VideoOut] Keep guests on SDR output under Auto HDR on macOS (#1020)
Upstream e7a4f0a0 started reporting HDR to the guest whenever the display
has HDR enabled. On an HDR Mac, Silent Hill switches its output to HDR,
a guest pipeline then fails to compile in MoltenVK (ushort4 output to a
BGRA8 attachment) and the process crashes inside MoltenVK on every run.
Auto now stays SDR on macOS; --hdr=on still opts in.
This commit is contained in:
parent
ec0198f2d0
commit
cb42e849d7
|
|
@ -67,8 +67,16 @@ public sealed record HostVideoOptions
|
|||
public PerformanceOverlayCorner OverlayCorner { get; init; } = PerformanceOverlayCorner.TopRight;
|
||||
public PerformanceOverlayMode OverlayMode { get; init; } = PerformanceOverlayMode.TitleBar;
|
||||
|
||||
// On macOS, Auto keeps guests on SDR output: reporting HDR moves titles onto render paths
|
||||
// MoltenVK cannot build yet (Silent Hill's HDR switch fails a pipeline compile and then
|
||||
// crashes inside MoltenVK on every run). --hdr=on still opts in.
|
||||
internal static bool AutoHdrAllowed => !OperatingSystem.IsMacOS();
|
||||
|
||||
internal bool CanUseHdr(bool displayHdrEnabled, bool surfaceSupportsHdr) =>
|
||||
surfaceSupportsHdr && (HdrMode == HostHdrMode.On || HdrMode == HostHdrMode.Auto && displayHdrEnabled);
|
||||
CanUseHdr(displayHdrEnabled, surfaceSupportsHdr, AutoHdrAllowed);
|
||||
|
||||
internal bool CanUseHdr(bool displayHdrEnabled, bool surfaceSupportsHdr, bool autoAllowed) =>
|
||||
surfaceSupportsHdr && (HdrMode == HostHdrMode.On || HdrMode == HostHdrMode.Auto && autoAllowed && displayHdrEnabled);
|
||||
|
||||
public HostVideoOptions Normalize() => this with
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,15 @@ public sealed class VideoOutOutputSupportTests
|
|||
private static readonly ulong MemoryFault =
|
||||
unchecked((ulong)(int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void AutoHdrFollowsThePlatformPolicyButOnAlwaysOptsIn(bool autoAllowed)
|
||||
{
|
||||
Assert.Equal(autoAllowed, new HostVideoOptions { HdrMode = HostHdrMode.Auto }.CanUseHdr(true, true, autoAllowed));
|
||||
Assert.True(new HostVideoOptions { HdrMode = HostHdrMode.On }.CanUseHdr(true, true, autoAllowed));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(HostHdrMode.Auto, false, true, false)]
|
||||
[InlineData(HostHdrMode.Auto, true, false, false)]
|
||||
|
|
@ -35,7 +44,7 @@ public sealed class VideoOutOutputSupportTests
|
|||
public void OutputStatusReportsHdrOnlyWhenAllowedAndSupported(
|
||||
HostHdrMode mode, bool displayHdrEnabled, bool surfaceSupportsHdr, bool expectedHdr)
|
||||
{
|
||||
var supported = new HostVideoOptions { HdrMode = mode }.CanUseHdr(displayHdrEnabled, surfaceSupportsHdr);
|
||||
var supported = new HostVideoOptions { HdrMode = mode }.CanUseHdr(displayHdrEnabled, surfaceSupportsHdr, autoAllowed: true);
|
||||
Assert.Equal(expectedHdr, supported);
|
||||
|
||||
var bytes = Enumerable.Repeat((byte)0xA5, 0x32).ToArray();
|
||||
|
|
|
|||
Loading…
Reference in New Issue