2020-11-12 23:15:34 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Shader.Cache.Definition
|
|
|
|
|
{
|
2021-09-29 00:55:12 +01: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>
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x14)]
|
|
|
|
|
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-29 00:55:12 +01: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-29 00:55:12 +01: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 11:33:54 +01: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 11:33:54 +01:00
|
|
|
|
public byte Reserved;
|
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>
|
2021-04-20 11:33:54 +01:00
|
|
|
|
public HostShaderCacheEntryHeader(
|
|
|
|
|
int cBuffersCount,
|
|
|
|
|
int sBuffersCount,
|
|
|
|
|
int texturesCount,
|
|
|
|
|
int imagesCount,
|
|
|
|
|
bool usesInstanceId,
|
2021-09-29 00:55:12 +01:00
|
|
|
|
bool usesRtLayer,
|
2021-04-20 11:33:54 +01:00
|
|
|
|
byte clipDistancesWritten) : this()
|
2020-11-12 23:15:34 +00:00
|
|
|
|
{
|
2021-04-20 11:33:54 +01:00
|
|
|
|
CBuffersCount = cBuffersCount;
|
|
|
|
|
SBuffersCount = sBuffersCount;
|
|
|
|
|
TexturesCount = texturesCount;
|
|
|
|
|
ImagesCount = imagesCount;
|
|
|
|
|
ClipDistancesWritten = clipDistancesWritten;
|
|
|
|
|
InUse = true;
|
2021-09-29 00:55:12 +01:00
|
|
|
|
|
|
|
|
|
UseFlags = usesInstanceId ? UseFlags.InstanceId : UseFlags.None;
|
|
|
|
|
|
|
|
|
|
if (usesRtLayer)
|
|
|
|
|
{
|
|
|
|
|
UseFlags |= UseFlags.RtLayer;
|
|
|
|
|
}
|
2020-11-12 23:15:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|