2020-11-12 23:15:34 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Shader.Cache.Definition
|
|
|
|
|
{
|
2021-09-28 23:55:12 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flags indicating if the shader accesses certain built-ins, such as the instance ID.
|
|
|
|
|
/// </summary>
|
|
|
|
|
enum UseFlags : byte
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// None of the built-ins are used.
|
|
|
|
|
/// </summary>
|
|
|
|
|
None = 0,
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates whenever the vertex shader reads the gl_InstanceID built-in.
|
|
|
|
|
/// </summary>
|
|
|
|
|
InstanceId = 1 << 0,
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates whenever any of the VTG stages writes to the gl_Layer built-in.
|
|
|
|
|
/// </summary>
|
|
|
|
|
RtLayer = 1 << 1
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-12 23:15:34 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Host shader entry header used for binding information.
|
|
|
|
|
/// </summary>
|
2022-02-16 22:15:39 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x18)]
|
2020-11-12 23:15:34 +00:00
|
|
|
|
struct HostShaderCacheEntryHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of constant buffer descriptors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int CBuffersCount;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of storage buffer descriptors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int SBuffersCount;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of texture descriptors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int TexturesCount;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of image descriptors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int ImagesCount;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-09-28 23:55:12 +00:00
|
|
|
|
/// Flags indicating if the shader accesses certain built-ins, such as the instance ID.
|
2020-11-12 23:15:34 +00:00
|
|
|
|
/// </summary>
|
2021-09-28 23:55:12 +00:00
|
|
|
|
public UseFlags UseFlags;
|
2020-11-12 23:15:34 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set to true if this entry is in use.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
public bool InUse;
|
|
|
|
|
|
2021-04-20 10:33:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Mask of clip distances that are written to on the shader.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte ClipDistancesWritten;
|
|
|
|
|
|
2020-11-12 23:15:34 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reserved / unused.
|
|
|
|
|
/// </summary>
|
2021-04-20 10:33:54 +00:00
|
|
|
|
public byte Reserved;
|
2020-11-12 23:15:34 +00:00
|
|
|
|
|
2022-02-16 22:15:39 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Mask of components written by the fragment shader stage.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int FragmentOutputMap;
|
|
|
|
|
|
2020-11-12 23:15:34 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new host shader cache entry header.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cBuffersCount">Count of constant buffer descriptors</param>
|
|
|
|
|
/// <param name="sBuffersCount">Count of storage buffer descriptors</param>
|
|
|
|
|
/// <param name="texturesCount">Count of texture descriptors</param>
|
|
|
|
|
/// <param name="imagesCount">Count of image descriptors</param>
|
|
|
|
|
/// <param name="usesInstanceId">Set to true if the shader uses instance id</param>
|
2022-02-16 22:15:39 +00:00
|
|
|
|
/// <param name="clipDistancesWritten">Mask of clip distances that are written to on the shader</param>
|
|
|
|
|
/// <param name="fragmentOutputMap">Mask of components written by the fragment shader stage</param>
|
2021-04-20 10:33:54 +00:00
|
|
|
|
public HostShaderCacheEntryHeader(
|
|
|
|
|
int cBuffersCount,
|
|
|
|
|
int sBuffersCount,
|
|
|
|
|
int texturesCount,
|
|
|
|
|
int imagesCount,
|
|
|
|
|
bool usesInstanceId,
|
2021-09-28 23:55:12 +00:00
|
|
|
|
bool usesRtLayer,
|
2022-02-16 22:15:39 +00:00
|
|
|
|
byte clipDistancesWritten,
|
|
|
|
|
int fragmentOutputMap) : this()
|
2020-11-12 23:15:34 +00:00
|
|
|
|
{
|
2021-04-20 10:33:54 +00:00
|
|
|
|
CBuffersCount = cBuffersCount;
|
|
|
|
|
SBuffersCount = sBuffersCount;
|
|
|
|
|
TexturesCount = texturesCount;
|
|
|
|
|
ImagesCount = imagesCount;
|
|
|
|
|
ClipDistancesWritten = clipDistancesWritten;
|
2022-02-16 22:15:39 +00:00
|
|
|
|
FragmentOutputMap = fragmentOutputMap;
|
2021-04-20 10:33:54 +00:00
|
|
|
|
InUse = true;
|
2021-09-28 23:55:12 +00:00
|
|
|
|
|
|
|
|
|
UseFlags = usesInstanceId ? UseFlags.InstanceId : UseFlags.None;
|
|
|
|
|
|
|
|
|
|
if (usesRtLayer)
|
|
|
|
|
{
|
|
|
|
|
UseFlags |= UseFlags.RtLayer;
|
|
|
|
|
}
|
2020-11-12 23:15:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|