Merge pull request #1 from TheRooferDev/publish-astc-vrr
Publish astc vrr
This commit is contained in:
@@ -4,7 +4,8 @@ namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
Switch,
|
||||
Unbounded,
|
||||
Custom
|
||||
Custom,
|
||||
Vrr
|
||||
}
|
||||
|
||||
public static class VSyncModeExtensions
|
||||
@@ -13,8 +14,9 @@ namespace Ryujinx.Common.Configuration
|
||||
vsync switch
|
||||
{
|
||||
VSyncMode.Switch => customEnabled ? VSyncMode.Custom : VSyncMode.Unbounded,
|
||||
VSyncMode.Unbounded => VSyncMode.Switch,
|
||||
VSyncMode.Custom => VSyncMode.Unbounded,
|
||||
VSyncMode.Unbounded => VSyncMode.Vrr,
|
||||
VSyncMode.Vrr => VSyncMode.Switch,
|
||||
_ => VSyncMode.Switch
|
||||
};
|
||||
}
|
||||
|
||||
@@ -661,6 +661,32 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
}
|
||||
}
|
||||
|
||||
// Large 4K texture-pack array textures (e.g. a 2048x2048 ASTC 2D array with 121 layers) decode to
|
||||
// more than 2 GiB of RGBA8, which overflows Int32 and cannot fit in a single array. Decode and
|
||||
// upload them one slice at a time instead (each slice is only a few MiB), reusing the same
|
||||
// single-slice path that partial synchronization already uses.
|
||||
if (Info.FormatInfo.Format.IsAstc &&
|
||||
!_context.Capabilities.SupportsAstcCompression &&
|
||||
_depth == 1 &&
|
||||
AstcDecoder.QueryDecompressedSizeLong(Info.Width, Info.Height, 1, Info.Levels, _layers) > int.MaxValue)
|
||||
{
|
||||
for (int layer = 0; layer < _layers; layer++)
|
||||
{
|
||||
for (int level = 0; level < Info.Levels; level++)
|
||||
{
|
||||
int sliceOffset = _sizeInfo.AllOffsets[layer * Info.Levels + level];
|
||||
|
||||
MemoryOwner<byte> sliceResult = ConvertToHostCompatibleFormat(data[sliceOffset..], level, single: true);
|
||||
|
||||
HostTexture.SetData(sliceResult, layer, level);
|
||||
}
|
||||
}
|
||||
|
||||
_hasData = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MemoryOwner<byte> result = ConvertToHostCompatibleFormat(data);
|
||||
|
||||
if (ScaleFactor != 1f && AllowScaledSetData())
|
||||
|
||||
@@ -115,6 +115,27 @@ namespace Ryujinx.Graphics.Texture.Astc
|
||||
return size * 4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the fully-decoded (RGBA8) size in bytes using 64-bit arithmetic, so callers can detect
|
||||
/// when the result would overflow <see cref="int"/> (e.g. large 4K texture-pack array textures) and
|
||||
/// decode slice-by-slice instead of allocating a single oversized buffer.
|
||||
/// </summary>
|
||||
public static long QueryDecompressedSizeLong(int sizeX, int sizeY, int sizeZ, int levelCount, int layerCount)
|
||||
{
|
||||
long size = 0;
|
||||
|
||||
for (int i = 0; i < levelCount; i++)
|
||||
{
|
||||
long levelSizeX = Math.Max(1, sizeX >> i);
|
||||
long levelSizeY = Math.Max(1, sizeY >> i);
|
||||
long levelSizeZ = Math.Max(1, sizeZ >> i);
|
||||
|
||||
size += levelSizeX * levelSizeY * levelSizeZ * layerCount;
|
||||
}
|
||||
|
||||
return size * 4;
|
||||
}
|
||||
|
||||
public void ProcessBlock(int index)
|
||||
{
|
||||
Buffer16 inputBlock = MemoryMarshal.Cast<byte, Buffer16>(InputBuffer.Span)[index];
|
||||
|
||||
@@ -282,7 +282,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
private static PresentModeKHR ChooseSwapPresentMode(PresentModeKHR[] availablePresentModes, VSyncMode vSyncMode)
|
||||
{
|
||||
if (vSyncMode == VSyncMode.Unbounded && availablePresentModes.Contains(PresentModeKHR.ImmediateKhr))
|
||||
// VRR: FifoRelaxed lets the display's variable refresh rate (G-Sync/FreeSync) drive the refresh
|
||||
// in fullscreen, smoothing a fluctuating frame rate without tearing. Immediate (full VSync off)
|
||||
// was tried first but could hang the GPU under load, so FifoRelaxed is used instead.
|
||||
if (vSyncMode == VSyncMode.Vrr && availablePresentModes.Contains(PresentModeKHR.FifoRelaxedKhr))
|
||||
{
|
||||
return PresentModeKHR.FifoRelaxedKhr;
|
||||
}
|
||||
else if (vSyncMode == VSyncMode.Unbounded && availablePresentModes.Contains(PresentModeKHR.ImmediateKhr))
|
||||
{
|
||||
return PresentModeKHR.ImmediateKhr;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<Color x:Key="Switch">#FF2EEAC9</Color>
|
||||
<Color x:Key="Unbounded">#FFFF4554</Color>
|
||||
<Color x:Key="Custom">#6483F5</Color>
|
||||
<Color x:Key="Vrr">#FF4CD964</Color>
|
||||
<Color x:Key="Warning">#800080</Color>
|
||||
<Color x:Key="CustomConfig">#00B5B8</Color>
|
||||
</ResourceDictionary>
|
||||
@@ -38,6 +39,7 @@
|
||||
<Color x:Key="Switch">#13c3a4</Color>
|
||||
<Color x:Key="Unbounded">#FFFF4554</Color>
|
||||
<Color x:Key="Custom">#6483F5</Color>
|
||||
<Color x:Key="Vrr">#FF4CD964</Color>
|
||||
<Color x:Key="Warning">#800080</Color>
|
||||
<Color x:Key="CustomConfig">#00B5B8</Color>
|
||||
</ResourceDictionary>
|
||||
@@ -58,6 +60,7 @@
|
||||
<Color x:Key="Switch">#FF2EEAC9</Color>
|
||||
<Color x:Key="Unbounded">#FFFF4554</Color>
|
||||
<Color x:Key="Custom">#6483F5</Color>
|
||||
<Color x:Key="Vrr">#FF4CD964</Color>
|
||||
<Color x:Key="Warning">#FFA500</Color>
|
||||
<Color x:Key="CustomConfig">#00B5B8</Color>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1369,7 +1369,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
VSyncModeColor = new SolidColorBrush(clr);
|
||||
}
|
||||
|
||||
VSyncModeText = args.VSyncMode == "Custom" ? "Custom" : "VSync";
|
||||
VSyncModeText = args.VSyncMode switch
|
||||
{
|
||||
"Custom" => "Custom",
|
||||
"Vrr" => "VRR",
|
||||
_ => "VSync"
|
||||
};
|
||||
DockedStatusText = args.DockedMode;
|
||||
AspectRatioStatusText = args.AspectRatio;
|
||||
GameStatusText = args.GameStatus;
|
||||
|
||||
Reference in New Issue
Block a user