forked from Mirror/Ryujinx
Separate zeta from color formats (#1647)
This commit is contained in:
parent
64088f04e3
commit
a89b81a812
9 changed files with 197 additions and 201 deletions
|
@ -19,7 +19,9 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
var dstCopyTexture = state.Get<CopyTexture>(MethodOffset.CopyDstTexture);
|
var dstCopyTexture = state.Get<CopyTexture>(MethodOffset.CopyDstTexture);
|
||||||
var srcCopyTexture = state.Get<CopyTexture>(MethodOffset.CopySrcTexture);
|
var srcCopyTexture = state.Get<CopyTexture>(MethodOffset.CopySrcTexture);
|
||||||
|
|
||||||
Texture srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture);
|
var srcCopyTextureFormat = srcCopyTexture.Format.Convert();
|
||||||
|
|
||||||
|
Texture srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, srcCopyTextureFormat);
|
||||||
|
|
||||||
if (srcTexture == null)
|
if (srcTexture == null)
|
||||||
{
|
{
|
||||||
|
@ -29,9 +31,18 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
// When the source texture that was found has a depth format,
|
// When the source texture that was found has a depth format,
|
||||||
// we must enforce the target texture also has a depth format,
|
// we must enforce the target texture also has a depth format,
|
||||||
// as copies between depth and color formats are not allowed.
|
// as copies between depth and color formats are not allowed.
|
||||||
dstCopyTexture.Format = TextureCompatibility.DeriveDepthFormat(dstCopyTexture.Format, srcTexture.Format);
|
FormatInfo dstCopyTextureFormat;
|
||||||
|
|
||||||
Texture dstTexture = TextureManager.FindOrCreateTexture(dstCopyTexture, srcTexture.ScaleMode == Image.TextureScaleMode.Scaled);
|
if (srcTexture.Format.IsDepthOrStencil())
|
||||||
|
{
|
||||||
|
dstCopyTextureFormat = srcCopyTextureFormat;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dstCopyTextureFormat = dstCopyTexture.Format.Convert();
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture dstTexture = TextureManager.FindOrCreateTexture(dstCopyTexture, dstCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled);
|
||||||
|
|
||||||
if (dstTexture == null)
|
if (dstTexture == null)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +100,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
{
|
{
|
||||||
srcCopyTexture.Height++;
|
srcCopyTexture.Height++;
|
||||||
|
|
||||||
srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, srcTexture.ScaleMode == Image.TextureScaleMode.Scaled);
|
srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, srcCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled);
|
||||||
if (srcTexture.ScaleFactor != dstTexture.ScaleFactor)
|
if (srcTexture.ScaleFactor != dstTexture.ScaleFactor)
|
||||||
{
|
{
|
||||||
srcTexture.PropagateScale(dstTexture);
|
srcTexture.PropagateScale(dstTexture);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Gpu.State;
|
|
||||||
using Ryujinx.Graphics.Texture;
|
using Ryujinx.Graphics.Texture;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -88,26 +87,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
return info.FormatInfo;
|
return info.FormatInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Finds the appropriate depth format for a copy texture if the source texture has a depth format.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dstTextureFormat">Destination CopyTexture Format</param>
|
|
||||||
/// <param name="srcTextureFormat">Source Texture Format</param>
|
|
||||||
/// <returns>Derived RtFormat if srcTextureFormat is a depth format, otherwise return dstTextureFormat.</returns>
|
|
||||||
public static RtFormat DeriveDepthFormat(RtFormat dstTextureFormat, Format srcTextureFormat)
|
|
||||||
{
|
|
||||||
return srcTextureFormat switch
|
|
||||||
{
|
|
||||||
Format.S8Uint => RtFormat.S8Uint,
|
|
||||||
Format.D16Unorm => RtFormat.D16Unorm,
|
|
||||||
Format.D24X8Unorm => RtFormat.D24Unorm,
|
|
||||||
Format.D32Float => RtFormat.D32Float,
|
|
||||||
Format.D24UnormS8Uint => RtFormat.D24UnormS8Uint,
|
|
||||||
Format.D32FloatS8Uint => RtFormat.D32FloatS8Uint,
|
|
||||||
_ => dstTextureFormat
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if two formats are compatible, according to the host API copy format compatibility rules.
|
/// Checks if two formats are compatible, according to the host API copy format compatibility rules.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -116,7 +95,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// <returns>True if the formats are compatible, false otherwise</returns>
|
/// <returns>True if the formats are compatible, false otherwise</returns>
|
||||||
public static bool FormatCompatible(FormatInfo lhs, FormatInfo rhs)
|
public static bool FormatCompatible(FormatInfo lhs, FormatInfo rhs)
|
||||||
{
|
{
|
||||||
if (IsDsFormat(lhs.Format) || IsDsFormat(rhs.Format))
|
if (lhs.Format.IsDepthOrStencil() || rhs.Format.IsDepthOrStencil())
|
||||||
{
|
{
|
||||||
return lhs.Format == rhs.Format;
|
return lhs.Format == rhs.Format;
|
||||||
}
|
}
|
||||||
|
@ -567,26 +546,5 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
return FormatClass.Unclassified;
|
return FormatClass.Unclassified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if the format is a depth-stencil texture format.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="format">Format to check</param>
|
|
||||||
/// <returns>True if the format is a depth-stencil format (including depth only), false otherwise</returns>
|
|
||||||
private static bool IsDsFormat(Format format)
|
|
||||||
{
|
|
||||||
switch (format)
|
|
||||||
{
|
|
||||||
case Format.D16Unorm:
|
|
||||||
case Format.D24X8Unorm:
|
|
||||||
case Format.D24UnormS8Uint:
|
|
||||||
case Format.D32Float:
|
|
||||||
case Format.D32FloatS8Uint:
|
|
||||||
case Format.S8Uint:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -451,9 +451,10 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// Tries to find an existing texture, or create a new one if not found.
|
/// Tries to find an existing texture, or create a new one if not found.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="copyTexture">Copy texture to find or create</param>
|
/// <param name="copyTexture">Copy texture to find or create</param>
|
||||||
|
/// <param name="formatInfo">Format information of the copy texture</param>
|
||||||
/// <param name="preferScaling">Indicates if the texture should be scaled from the start</param>
|
/// <param name="preferScaling">Indicates if the texture should be scaled from the start</param>
|
||||||
/// <returns>The texture</returns>
|
/// <returns>The texture</returns>
|
||||||
public Texture FindOrCreateTexture(CopyTexture copyTexture, bool preferScaling = true)
|
public Texture FindOrCreateTexture(CopyTexture copyTexture, FormatInfo formatInfo, bool preferScaling = true)
|
||||||
{
|
{
|
||||||
ulong address = _context.MemoryManager.Translate(copyTexture.Address.Pack());
|
ulong address = _context.MemoryManager.Translate(copyTexture.Address.Pack());
|
||||||
|
|
||||||
|
@ -465,8 +466,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
int gobBlocksInY = copyTexture.MemoryLayout.UnpackGobBlocksInY();
|
int gobBlocksInY = copyTexture.MemoryLayout.UnpackGobBlocksInY();
|
||||||
int gobBlocksInZ = copyTexture.MemoryLayout.UnpackGobBlocksInZ();
|
int gobBlocksInZ = copyTexture.MemoryLayout.UnpackGobBlocksInZ();
|
||||||
|
|
||||||
FormatInfo formatInfo = copyTexture.Format.Convert();
|
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
if (copyTexture.LinearLayout)
|
if (copyTexture.LinearLayout)
|
||||||
|
|
134
Ryujinx.Graphics.Gpu/State/ColorFormat.cs
Normal file
134
Ryujinx.Graphics.Gpu/State/ColorFormat.cs
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
using Ryujinx.Graphics.GAL;
|
||||||
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Gpu.State
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Color texture format.
|
||||||
|
/// </summary>
|
||||||
|
enum ColorFormat
|
||||||
|
{
|
||||||
|
R32G32B32A32Float = 0xc0,
|
||||||
|
R32G32B32A32Sint = 0xc1,
|
||||||
|
R32G32B32A32Uint = 0xc2,
|
||||||
|
R32G32B32X32Float = 0xc3,
|
||||||
|
R32G32B32X32Sint = 0xc4,
|
||||||
|
R32G32B32X32Uint = 0xc5,
|
||||||
|
R16G16B16X16Unorm = 0xc6,
|
||||||
|
R16G16B16X16Snorm = 0xc7,
|
||||||
|
R16G16B16X16Sint = 0xc8,
|
||||||
|
R16G16B16X16Uint = 0xc9,
|
||||||
|
R16G16B16A16Float = 0xca,
|
||||||
|
R32G32Float = 0xcb,
|
||||||
|
R32G32Sint = 0xcc,
|
||||||
|
R32G32Uint = 0xcd,
|
||||||
|
R16G16B16X16Float = 0xce,
|
||||||
|
B8G8R8A8Unorm = 0xcf,
|
||||||
|
B8G8R8A8Srgb = 0xd0,
|
||||||
|
R10G10B10A2Unorm = 0xd1,
|
||||||
|
R10G10B10A2Uint = 0xd2,
|
||||||
|
R8G8B8A8Unorm = 0xd5,
|
||||||
|
R8G8B8A8Srgb = 0xd6,
|
||||||
|
R8G8B8X8Snorm = 0xd7,
|
||||||
|
R8G8B8X8Sint = 0xd8,
|
||||||
|
R8G8B8X8Uint = 0xd9,
|
||||||
|
R16G16Unorm = 0xda,
|
||||||
|
R16G16Snorm = 0xdb,
|
||||||
|
R16G16Sint = 0xdc,
|
||||||
|
R16G16Uint = 0xdd,
|
||||||
|
R16G16Float = 0xde,
|
||||||
|
R11G11B10Float = 0xe0,
|
||||||
|
R32Sint = 0xe3,
|
||||||
|
R32Uint = 0xe4,
|
||||||
|
R32Float = 0xe5,
|
||||||
|
B8G8R8X8Unorm = 0xe6,
|
||||||
|
B8G8R8X8Srgb = 0xe7,
|
||||||
|
B5G6R5Unorm = 0xe8,
|
||||||
|
B5G5R5A1Unorm = 0xe9,
|
||||||
|
R8G8Unorm = 0xea,
|
||||||
|
R8G8Snorm = 0xeb,
|
||||||
|
R8G8Sint = 0xec,
|
||||||
|
R8G8Uint = 0xed,
|
||||||
|
R16Unorm = 0xee,
|
||||||
|
R16Snorm = 0xef,
|
||||||
|
R16Sint = 0xf0,
|
||||||
|
R16Uint = 0xf1,
|
||||||
|
R16Float = 0xf2,
|
||||||
|
R8Unorm = 0xf3,
|
||||||
|
R8Snorm = 0xf4,
|
||||||
|
R8Sint = 0xf5,
|
||||||
|
R8Uint = 0xf6,
|
||||||
|
B5G5R5X1Unorm = 0xf8,
|
||||||
|
R8G8B8X8Unorm = 0xf9,
|
||||||
|
R8G8B8X8Srgb = 0xfa
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ColorFormatConverter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the color texture format to a host compatible format.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">Color format</param>
|
||||||
|
/// <returns>Host compatible format enum value</returns>
|
||||||
|
public static FormatInfo Convert(this ColorFormat format)
|
||||||
|
{
|
||||||
|
return format switch
|
||||||
|
{
|
||||||
|
ColorFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
|
||||||
|
ColorFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
|
||||||
|
ColorFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
|
||||||
|
ColorFormat.R32G32B32X32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
|
||||||
|
ColorFormat.R32G32B32X32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
|
||||||
|
ColorFormat.R32G32B32X32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
|
||||||
|
ColorFormat.R16G16B16X16Unorm => new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8, 4),
|
||||||
|
ColorFormat.R16G16B16X16Snorm => new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8, 4),
|
||||||
|
ColorFormat.R16G16B16X16Sint => new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8, 4),
|
||||||
|
ColorFormat.R16G16B16X16Uint => new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8, 4),
|
||||||
|
ColorFormat.R16G16B16A16Float => new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4),
|
||||||
|
ColorFormat.R32G32Float => new FormatInfo(Format.R32G32Float, 1, 1, 8, 2),
|
||||||
|
ColorFormat.R32G32Sint => new FormatInfo(Format.R32G32Sint, 1, 1, 8, 2),
|
||||||
|
ColorFormat.R32G32Uint => new FormatInfo(Format.R32G32Uint, 1, 1, 8, 2),
|
||||||
|
ColorFormat.R16G16B16X16Float => new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4),
|
||||||
|
ColorFormat.B8G8R8A8Unorm => new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4, 4),
|
||||||
|
ColorFormat.B8G8R8A8Srgb => new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R10G10B10A2Unorm => new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R10G10B10A2Uint => new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R8G8B8A8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R8G8B8A8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R8G8B8X8Snorm => new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R8G8B8X8Sint => new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R8G8B8X8Uint => new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R16G16Unorm => new FormatInfo(Format.R16G16Unorm, 1, 1, 4, 2),
|
||||||
|
ColorFormat.R16G16Snorm => new FormatInfo(Format.R16G16Snorm, 1, 1, 4, 2),
|
||||||
|
ColorFormat.R16G16Sint => new FormatInfo(Format.R16G16Sint, 1, 1, 4, 2),
|
||||||
|
ColorFormat.R16G16Uint => new FormatInfo(Format.R16G16Uint, 1, 1, 4, 2),
|
||||||
|
ColorFormat.R16G16Float => new FormatInfo(Format.R16G16Float, 1, 1, 4, 2),
|
||||||
|
ColorFormat.R11G11B10Float => new FormatInfo(Format.R11G11B10Float, 1, 1, 4, 3),
|
||||||
|
ColorFormat.R32Sint => new FormatInfo(Format.R32Sint, 1, 1, 4, 1),
|
||||||
|
ColorFormat.R32Uint => new FormatInfo(Format.R32Uint, 1, 1, 4, 1),
|
||||||
|
ColorFormat.R32Float => new FormatInfo(Format.R32Float, 1, 1, 4, 1),
|
||||||
|
ColorFormat.B8G8R8X8Unorm => new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4, 4),
|
||||||
|
ColorFormat.B8G8R8X8Srgb => new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4, 4),
|
||||||
|
ColorFormat.B5G6R5Unorm => new FormatInfo(Format.B5G6R5Unorm, 1, 1, 2, 3),
|
||||||
|
ColorFormat.B5G5R5A1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2, 4),
|
||||||
|
ColorFormat.R8G8Unorm => new FormatInfo(Format.R8G8Unorm, 1, 1, 2, 2),
|
||||||
|
ColorFormat.R8G8Snorm => new FormatInfo(Format.R8G8Snorm, 1, 1, 2, 2),
|
||||||
|
ColorFormat.R8G8Sint => new FormatInfo(Format.R8G8Sint, 1, 1, 2, 2),
|
||||||
|
ColorFormat.R8G8Uint => new FormatInfo(Format.R8G8Uint, 1, 1, 2, 2),
|
||||||
|
ColorFormat.R16Unorm => new FormatInfo(Format.R16Unorm, 1, 1, 2, 1),
|
||||||
|
ColorFormat.R16Snorm => new FormatInfo(Format.R16Snorm, 1, 1, 2, 1),
|
||||||
|
ColorFormat.R16Sint => new FormatInfo(Format.R16Sint, 1, 1, 2, 1),
|
||||||
|
ColorFormat.R16Uint => new FormatInfo(Format.R16Uint, 1, 1, 2, 1),
|
||||||
|
ColorFormat.R16Float => new FormatInfo(Format.R16Float, 1, 1, 2, 1),
|
||||||
|
ColorFormat.R8Unorm => new FormatInfo(Format.R8Unorm, 1, 1, 1, 1),
|
||||||
|
ColorFormat.R8Snorm => new FormatInfo(Format.R8Snorm, 1, 1, 1, 1),
|
||||||
|
ColorFormat.R8Sint => new FormatInfo(Format.R8Sint, 1, 1, 1, 1),
|
||||||
|
ColorFormat.R8Uint => new FormatInfo(Format.R8Uint, 1, 1, 1, 1),
|
||||||
|
ColorFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5X1Unorm, 1, 1, 2, 4),
|
||||||
|
ColorFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
|
||||||
|
ColorFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
|
||||||
|
_ => FormatInfo.Default
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Gpu.State
|
||||||
struct CopyTexture
|
struct CopyTexture
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649
|
||||||
public RtFormat Format;
|
public ColorFormat Format;
|
||||||
public Boolean32 LinearLayout;
|
public Boolean32 LinearLayout;
|
||||||
public MemoryLayout MemoryLayout;
|
public MemoryLayout MemoryLayout;
|
||||||
public int Depth;
|
public int Depth;
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.State
|
||||||
public GpuVa Address;
|
public GpuVa Address;
|
||||||
public int WidthOrStride;
|
public int WidthOrStride;
|
||||||
public int Height;
|
public int Height;
|
||||||
public RtFormat Format;
|
public ColorFormat Format;
|
||||||
public MemoryLayout MemoryLayout;
|
public MemoryLayout MemoryLayout;
|
||||||
public int Depth;
|
public int Depth;
|
||||||
public int LayerSize;
|
public int LayerSize;
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.State
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649
|
||||||
public GpuVa Address;
|
public GpuVa Address;
|
||||||
public RtFormat Format;
|
public ZetaFormat Format;
|
||||||
public MemoryLayout MemoryLayout;
|
public MemoryLayout MemoryLayout;
|
||||||
public int LayerSize;
|
public int LayerSize;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
|
|
|
@ -1,148 +0,0 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.State
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Render target buffer texture format.
|
|
||||||
/// </summary>
|
|
||||||
enum RtFormat
|
|
||||||
{
|
|
||||||
D32Float = 0xa,
|
|
||||||
D16Unorm = 0x13,
|
|
||||||
D24UnormS8Uint = 0x14,
|
|
||||||
D24Unorm = 0x15,
|
|
||||||
S8UintD24Unorm = 0x16,
|
|
||||||
S8Uint = 0x17,
|
|
||||||
D32FloatS8Uint = 0x19,
|
|
||||||
R32G32B32A32Float = 0xc0,
|
|
||||||
R32G32B32A32Sint = 0xc1,
|
|
||||||
R32G32B32A32Uint = 0xc2,
|
|
||||||
R32G32B32X32Float = 0xc3,
|
|
||||||
R32G32B32X32Sint = 0xc4,
|
|
||||||
R32G32B32X32Uint = 0xc5,
|
|
||||||
R16G16B16X16Unorm = 0xc6,
|
|
||||||
R16G16B16X16Snorm = 0xc7,
|
|
||||||
R16G16B16X16Sint = 0xc8,
|
|
||||||
R16G16B16X16Uint = 0xc9,
|
|
||||||
R16G16B16A16Float = 0xca,
|
|
||||||
R32G32Float = 0xcb,
|
|
||||||
R32G32Sint = 0xcc,
|
|
||||||
R32G32Uint = 0xcd,
|
|
||||||
R16G16B16X16Float = 0xce,
|
|
||||||
B8G8R8A8Unorm = 0xcf,
|
|
||||||
B8G8R8A8Srgb = 0xd0,
|
|
||||||
R10G10B10A2Unorm = 0xd1,
|
|
||||||
R10G10B10A2Uint = 0xd2,
|
|
||||||
R8G8B8A8Unorm = 0xd5,
|
|
||||||
R8G8B8A8Srgb = 0xd6,
|
|
||||||
R8G8B8X8Snorm = 0xd7,
|
|
||||||
R8G8B8X8Sint = 0xd8,
|
|
||||||
R8G8B8X8Uint = 0xd9,
|
|
||||||
R16G16Unorm = 0xda,
|
|
||||||
R16G16Snorm = 0xdb,
|
|
||||||
R16G16Sint = 0xdc,
|
|
||||||
R16G16Uint = 0xdd,
|
|
||||||
R16G16Float = 0xde,
|
|
||||||
R11G11B10Float = 0xe0,
|
|
||||||
R32Sint = 0xe3,
|
|
||||||
R32Uint = 0xe4,
|
|
||||||
R32Float = 0xe5,
|
|
||||||
B8G8R8X8Unorm = 0xe6,
|
|
||||||
B8G8R8X8Srgb = 0xe7,
|
|
||||||
B5G6R5Unorm = 0xe8,
|
|
||||||
B5G5R5A1Unorm = 0xe9,
|
|
||||||
R8G8Unorm = 0xea,
|
|
||||||
R8G8Snorm = 0xeb,
|
|
||||||
R8G8Sint = 0xec,
|
|
||||||
R8G8Uint = 0xed,
|
|
||||||
R16Unorm = 0xee,
|
|
||||||
R16Snorm = 0xef,
|
|
||||||
R16Sint = 0xf0,
|
|
||||||
R16Uint = 0xf1,
|
|
||||||
R16Float = 0xf2,
|
|
||||||
R8Unorm = 0xf3,
|
|
||||||
R8Snorm = 0xf4,
|
|
||||||
R8Sint = 0xf5,
|
|
||||||
R8Uint = 0xf6,
|
|
||||||
B5G5R5X1Unorm = 0xf8,
|
|
||||||
R8G8B8X8Unorm = 0xf9,
|
|
||||||
R8G8B8X8Srgb = 0xfa
|
|
||||||
}
|
|
||||||
|
|
||||||
static class RtFormatConverter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Converts the render target buffer texture format to a host compatible format.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="format">Render target format</param>
|
|
||||||
/// <returns>Host compatible format enum value</returns>
|
|
||||||
public static FormatInfo Convert(this RtFormat format)
|
|
||||||
{
|
|
||||||
return format switch
|
|
||||||
{
|
|
||||||
RtFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4, 1),
|
|
||||||
RtFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2, 1),
|
|
||||||
RtFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
|
|
||||||
RtFormat.D24Unorm => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 1),
|
|
||||||
RtFormat.S8UintD24Unorm => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
|
|
||||||
RtFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1, 1),
|
|
||||||
RtFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2),
|
|
||||||
RtFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
|
|
||||||
RtFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
|
|
||||||
RtFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
|
|
||||||
RtFormat.R32G32B32X32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
|
|
||||||
RtFormat.R32G32B32X32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
|
|
||||||
RtFormat.R32G32B32X32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
|
|
||||||
RtFormat.R16G16B16X16Unorm => new FormatInfo(Format.R16G16B16A16Unorm, 1, 1, 8, 4),
|
|
||||||
RtFormat.R16G16B16X16Snorm => new FormatInfo(Format.R16G16B16A16Snorm, 1, 1, 8, 4),
|
|
||||||
RtFormat.R16G16B16X16Sint => new FormatInfo(Format.R16G16B16A16Sint, 1, 1, 8, 4),
|
|
||||||
RtFormat.R16G16B16X16Uint => new FormatInfo(Format.R16G16B16A16Uint, 1, 1, 8, 4),
|
|
||||||
RtFormat.R16G16B16A16Float => new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4),
|
|
||||||
RtFormat.R32G32Float => new FormatInfo(Format.R32G32Float, 1, 1, 8, 2),
|
|
||||||
RtFormat.R32G32Sint => new FormatInfo(Format.R32G32Sint, 1, 1, 8, 2),
|
|
||||||
RtFormat.R32G32Uint => new FormatInfo(Format.R32G32Uint, 1, 1, 8, 2),
|
|
||||||
RtFormat.R16G16B16X16Float => new FormatInfo(Format.R16G16B16A16Float, 1, 1, 8, 4),
|
|
||||||
RtFormat.B8G8R8A8Unorm => new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4, 4),
|
|
||||||
RtFormat.B8G8R8A8Srgb => new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4, 4),
|
|
||||||
RtFormat.R10G10B10A2Unorm => new FormatInfo(Format.R10G10B10A2Unorm, 1, 1, 4, 4),
|
|
||||||
RtFormat.R10G10B10A2Uint => new FormatInfo(Format.R10G10B10A2Uint, 1, 1, 4, 4),
|
|
||||||
RtFormat.R8G8B8A8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
|
|
||||||
RtFormat.R8G8B8A8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
|
|
||||||
RtFormat.R8G8B8X8Snorm => new FormatInfo(Format.R8G8B8A8Snorm, 1, 1, 4, 4),
|
|
||||||
RtFormat.R8G8B8X8Sint => new FormatInfo(Format.R8G8B8A8Sint, 1, 1, 4, 4),
|
|
||||||
RtFormat.R8G8B8X8Uint => new FormatInfo(Format.R8G8B8A8Uint, 1, 1, 4, 4),
|
|
||||||
RtFormat.R16G16Unorm => new FormatInfo(Format.R16G16Unorm, 1, 1, 4, 2),
|
|
||||||
RtFormat.R16G16Snorm => new FormatInfo(Format.R16G16Snorm, 1, 1, 4, 2),
|
|
||||||
RtFormat.R16G16Sint => new FormatInfo(Format.R16G16Sint, 1, 1, 4, 2),
|
|
||||||
RtFormat.R16G16Uint => new FormatInfo(Format.R16G16Uint, 1, 1, 4, 2),
|
|
||||||
RtFormat.R16G16Float => new FormatInfo(Format.R16G16Float, 1, 1, 4, 2),
|
|
||||||
RtFormat.R11G11B10Float => new FormatInfo(Format.R11G11B10Float, 1, 1, 4, 3),
|
|
||||||
RtFormat.R32Sint => new FormatInfo(Format.R32Sint, 1, 1, 4, 1),
|
|
||||||
RtFormat.R32Uint => new FormatInfo(Format.R32Uint, 1, 1, 4, 1),
|
|
||||||
RtFormat.R32Float => new FormatInfo(Format.R32Float, 1, 1, 4, 1),
|
|
||||||
RtFormat.B8G8R8X8Unorm => new FormatInfo(Format.B8G8R8A8Unorm, 1, 1, 4, 4),
|
|
||||||
RtFormat.B8G8R8X8Srgb => new FormatInfo(Format.B8G8R8A8Srgb, 1, 1, 4, 4),
|
|
||||||
RtFormat.B5G6R5Unorm => new FormatInfo(Format.B5G6R5Unorm, 1, 1, 2, 3),
|
|
||||||
RtFormat.B5G5R5A1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2, 4),
|
|
||||||
RtFormat.R8G8Unorm => new FormatInfo(Format.R8G8Unorm, 1, 1, 2, 2),
|
|
||||||
RtFormat.R8G8Snorm => new FormatInfo(Format.R8G8Snorm, 1, 1, 2, 2),
|
|
||||||
RtFormat.R8G8Sint => new FormatInfo(Format.R8G8Sint, 1, 1, 2, 2),
|
|
||||||
RtFormat.R8G8Uint => new FormatInfo(Format.R8G8Uint, 1, 1, 2, 2),
|
|
||||||
RtFormat.R16Unorm => new FormatInfo(Format.R16Unorm, 1, 1, 2, 1),
|
|
||||||
RtFormat.R16Snorm => new FormatInfo(Format.R16Snorm, 1, 1, 2, 1),
|
|
||||||
RtFormat.R16Sint => new FormatInfo(Format.R16Sint, 1, 1, 2, 1),
|
|
||||||
RtFormat.R16Uint => new FormatInfo(Format.R16Uint, 1, 1, 2, 1),
|
|
||||||
RtFormat.R16Float => new FormatInfo(Format.R16Float, 1, 1, 2, 1),
|
|
||||||
RtFormat.R8Unorm => new FormatInfo(Format.R8Unorm, 1, 1, 1, 1),
|
|
||||||
RtFormat.R8Snorm => new FormatInfo(Format.R8Snorm, 1, 1, 1, 1),
|
|
||||||
RtFormat.R8Sint => new FormatInfo(Format.R8Sint, 1, 1, 1, 1),
|
|
||||||
RtFormat.R8Uint => new FormatInfo(Format.R8Uint, 1, 1, 1, 1),
|
|
||||||
RtFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5X1Unorm, 1, 1, 2, 4),
|
|
||||||
RtFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
|
|
||||||
RtFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
|
|
||||||
_ => FormatInfo.Default
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
42
Ryujinx.Graphics.Gpu/State/ZetaFormat.cs
Normal file
42
Ryujinx.Graphics.Gpu/State/ZetaFormat.cs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
using Ryujinx.Graphics.GAL;
|
||||||
|
using Ryujinx.Graphics.Gpu.Image;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Gpu.State
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Depth-stencil texture format.
|
||||||
|
/// </summary>
|
||||||
|
enum ZetaFormat
|
||||||
|
{
|
||||||
|
D32Float = 0xa,
|
||||||
|
D16Unorm = 0x13,
|
||||||
|
D24UnormS8Uint = 0x14,
|
||||||
|
D24Unorm = 0x15,
|
||||||
|
S8UintD24Unorm = 0x16,
|
||||||
|
S8Uint = 0x17,
|
||||||
|
D32FloatS8Uint = 0x19
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ZetaFormatConverter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the depth-stencil texture format to a host compatible format.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">Depth-stencil format</param>
|
||||||
|
/// <returns>Host compatible format enum value</returns>
|
||||||
|
public static FormatInfo Convert(this ZetaFormat format)
|
||||||
|
{
|
||||||
|
return format switch
|
||||||
|
{
|
||||||
|
ZetaFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4, 1),
|
||||||
|
ZetaFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2, 1),
|
||||||
|
ZetaFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
|
||||||
|
ZetaFormat.D24Unorm => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 1),
|
||||||
|
ZetaFormat.S8UintD24Unorm => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
|
||||||
|
ZetaFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1, 1),
|
||||||
|
ZetaFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2),
|
||||||
|
_ => FormatInfo.Default
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue