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