Ryujinx/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs

72 lines
2.3 KiB
C#
Raw Normal View History

using System;
2019-10-13 02:02:07 -04:00
2019-12-29 12:41:50 -05:00
namespace Ryujinx.Graphics.Shader.Translation
2019-10-13 02:02:07 -04:00
{
struct ShaderConfig
{
public ShaderStage Stage { get; }
public OutputTopology OutputTopology { get; }
public int MaxOutputVertices { get; }
public int LocalMemorySize { get; }
public ImapPixelType[] ImapTypes { get; }
public OmapTarget[] OmapTargets { get; }
public bool OmapSampleMask { get; }
public bool OmapDepth { get; }
public IGpuAccessor GpuAccessor { get; }
2019-10-13 02:02:07 -04:00
public TranslationFlags Flags { get; }
2019-10-13 02:02:07 -04:00
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationFlags flags)
{
2020-01-01 10:39:09 -05:00
Stage = ShaderStage.Compute;
OutputTopology = OutputTopology.PointList;
MaxOutputVertices = 0;
LocalMemorySize = 0;
ImapTypes = null;
2020-01-01 10:39:09 -05:00
OmapTargets = null;
OmapSampleMask = false;
OmapDepth = false;
GpuAccessor = gpuAccessor;
2020-01-01 10:39:09 -05:00
Flags = flags;
}
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationFlags flags)
{
2020-01-01 10:39:09 -05:00
Stage = header.Stage;
OutputTopology = header.OutputTopology;
MaxOutputVertices = header.MaxOutputVertexCount;
LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize;
ImapTypes = header.ImapTypes;
2020-01-01 10:39:09 -05:00
OmapTargets = header.OmapTargets;
OmapSampleMask = header.OmapSampleMask;
OmapDepth = header.OmapDepth;
GpuAccessor = gpuAccessor;
2020-01-01 10:39:09 -05:00
Flags = flags;
}
public int GetDepthRegister()
{
int count = 0;
for (int index = 0; index < OmapTargets.Length; index++)
{
for (int component = 0; component < 4; component++)
{
if (OmapTargets[index].ComponentEnabled(component))
{
count++;
}
}
}
// The depth register is always two registers after the last color output.
return count + 1;
}
2019-10-13 02:02:07 -04:00
}
}