2022-01-08 18:48:48 +01:00
|
|
|
using Ryujinx.Common.Memory;
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
2021-08-11 21:33:43 +02:00
|
|
|
namespace Ryujinx.Graphics.Shader
|
|
|
|
{
|
2022-01-08 18:48:48 +01:00
|
|
|
public struct Vector4<T>
|
2021-08-11 21:33:43 +02:00
|
|
|
{
|
2022-01-08 18:48:48 +01:00
|
|
|
public T X;
|
|
|
|
public T Y;
|
|
|
|
public T Z;
|
|
|
|
public T W;
|
|
|
|
}
|
2021-08-11 21:33:43 +02:00
|
|
|
|
2022-01-08 18:48:48 +01:00
|
|
|
public struct SupportBuffer
|
|
|
|
{
|
|
|
|
public static int FieldSize;
|
|
|
|
public static int RequiredSize;
|
|
|
|
|
|
|
|
public static int FragmentAlphaTestOffset;
|
|
|
|
public static int FragmentIsBgraOffset;
|
2022-05-12 15:47:13 +02:00
|
|
|
public static int ViewportInverseOffset;
|
2022-01-08 18:48:48 +01:00
|
|
|
public static int FragmentRenderScaleCountOffset;
|
|
|
|
public static int GraphicsRenderScaleOffset;
|
|
|
|
public static int ComputeRenderScaleOffset;
|
2021-08-11 21:33:43 +02:00
|
|
|
|
2022-01-08 18:48:48 +01:00
|
|
|
public const int FragmentIsBgraCount = 8;
|
2021-08-11 21:33:43 +02:00
|
|
|
// One for the render target, 32 for the textures, and 8 for the images.
|
2021-08-12 00:44:41 +02:00
|
|
|
public const int RenderScaleMaxCount = 1 + 32 + 8;
|
2021-08-11 21:33:43 +02:00
|
|
|
|
2022-01-08 18:48:48 +01:00
|
|
|
private static int OffsetOf<T>(ref SupportBuffer storage, ref T target)
|
|
|
|
{
|
|
|
|
return (int)Unsafe.ByteOffset(ref Unsafe.As<SupportBuffer, T>(ref storage), ref target);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SupportBuffer()
|
|
|
|
{
|
|
|
|
FieldSize = Unsafe.SizeOf<Vector4<float>>();
|
|
|
|
RequiredSize = Unsafe.SizeOf<SupportBuffer>();
|
|
|
|
|
|
|
|
SupportBuffer instance = new SupportBuffer();
|
|
|
|
|
|
|
|
FragmentAlphaTestOffset = OffsetOf(ref instance, ref instance.FragmentAlphaTest);
|
|
|
|
FragmentIsBgraOffset = OffsetOf(ref instance, ref instance.FragmentIsBgra);
|
2022-05-12 15:47:13 +02:00
|
|
|
ViewportInverseOffset = OffsetOf(ref instance, ref instance.ViewportInverse);
|
2022-01-08 18:48:48 +01:00
|
|
|
FragmentRenderScaleCountOffset = OffsetOf(ref instance, ref instance.FragmentRenderScaleCount);
|
|
|
|
GraphicsRenderScaleOffset = OffsetOf(ref instance, ref instance.RenderScale);
|
|
|
|
ComputeRenderScaleOffset = GraphicsRenderScaleOffset + FieldSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Vector4<int> FragmentAlphaTest;
|
|
|
|
public Array8<Vector4<int>> FragmentIsBgra;
|
2022-05-12 15:47:13 +02:00
|
|
|
public Vector4<float> ViewportInverse;
|
2022-01-08 18:48:48 +01:00
|
|
|
public Vector4<int> FragmentRenderScaleCount;
|
|
|
|
|
|
|
|
// Render scale max count: 1 + 32 + 8. First scale is fragment output scale, others are textures/image inputs.
|
|
|
|
public Array41<Vector4<float>> RenderScale;
|
2021-08-11 21:33:43 +02:00
|
|
|
}
|
|
|
|
}
|