Compare commits

..

2 Commits

Author SHA1 Message Date
gdkchan
2492e7e808 Fix R4G4B4A4 format on Vulkan (#3696) 2022-09-13 07:59:38 +02:00
riperiperi
36172ab43b Scale SamplesPassed counter by RT scale on report (#3680)
* Scale SamplesPassed counter by RT scale on report

Adds a scale factor for samples passed counter report based on the render target scale at the time. This ensures that when a game reads this counter, it appears similar to the result at 1x.

This doesn't cover cases where the the render target scale changes during the queried draws, though that might be better to handle along with other scope related issues in a future rework of counters. Games generally don't count for occlusion queries over render target changes anyways.

Fixes an issue in the Splatoon games where the special charge would scale too quickly at high res, points at the end of the game would be broken (but still provide a correct winner), and playing at a low res would make it impossible to swim in ink.

May also affect LOD scaling in The Witcher 3.

* Update Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2022-09-11 15:58:15 +00:00
4 changed files with 22 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
using Ryujinx.Graphics.GAL;
using System;
namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
@@ -151,10 +152,21 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
ulong ticks = _context.GetTimestamp();
float divisor = type switch
{
ReportCounterType.SamplesPassed => _channel.TextureManager.RenderTargetScale * _channel.TextureManager.RenderTargetScale,
_ => 1f
};
ICounterEvent counter = null;
void resultHandler(object evt, ulong result)
{
if (divisor != 1f)
{
result = (ulong)MathF.Ceiling(result / divisor);
}
CounterData counterData = new CounterData
{
Counter = result,

View File

@@ -108,6 +108,10 @@ namespace Ryujinx.Graphics.Vulkan
{
format = VkFormat.D32SfloatS8Uint;
}
else if (srcFormat == GAL.Format.R4G4B4A4Unorm)
{
format = VkFormat.R4G4B4A4UnormPack16;
}
else
{
Logger.Error?.Print(LogClass.Gpu, $"Format {srcFormat} is not supported by the host.");

View File

@@ -6,11 +6,11 @@ namespace Ryujinx.Graphics.Vulkan
{
static class FormatTable
{
private static readonly VkFormat[] Table;
private static readonly VkFormat[] _table;
static FormatTable()
{
Table = new VkFormat[Enum.GetNames(typeof(Format)).Length];
_table = new VkFormat[Enum.GetNames(typeof(Format)).Length];
Add(Format.R8Unorm, VkFormat.R8Unorm);
Add(Format.R8Snorm, VkFormat.R8SNorm);
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Vulkan
Add(Format.D32FloatS8Uint, VkFormat.D32SfloatS8Uint);
Add(Format.R8G8B8A8Srgb, VkFormat.R8G8B8A8Srgb);
Add(Format.R4G4Unorm, VkFormat.R4G4UnormPack8);
Add(Format.R4G4B4A4Unorm, VkFormat.R4G4B4A4UnormPack16);
Add(Format.R4G4B4A4Unorm, VkFormat.A4B4G4R4UnormPack16Ext);
Add(Format.R5G5B5X1Unorm, VkFormat.A1R5G5B5UnormPack16);
Add(Format.R5G5B5A1Unorm, VkFormat.A1R5G5B5UnormPack16);
Add(Format.R5G6B5Unorm, VkFormat.R5G6B5UnormPack16);
@@ -161,12 +161,12 @@ namespace Ryujinx.Graphics.Vulkan
private static void Add(Format format, VkFormat vkFormat)
{
Table[(int)format] = vkFormat;
_table[(int)format] = vkFormat;
}
public static VkFormat GetFormat(Format format)
{
return Table[(int)format];
return _table[(int)format];
}
}
}

View File

@@ -74,17 +74,7 @@ namespace Ryujinx.Graphics.Vulkan
swizzleR = swizzleB;
swizzleB = temp;
}
else if (info.Format == GAL.Format.R4G4B4A4Unorm)
{
var tempG = swizzleG;
var tempB = swizzleB;
swizzleB = swizzleA;
swizzleG = swizzleR;
swizzleR = tempG;
swizzleA = tempB;
}
else if (info.Format == GAL.Format.A1B5G5R5Unorm)
else if (VkFormat == VkFormat.R4G4B4A4UnormPack16 || info.Format == GAL.Format.A1B5G5R5Unorm)
{
var tempB = swizzleB;
var tempA = swizzleA;