2019-12-16 05:59:46 +01:00
|
|
|
using System;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
2019-12-29 18:41:50 +01:00
|
|
|
namespace Ryujinx.Graphics.Shader.Translation
|
2019-10-13 08:02:07 +02:00
|
|
|
{
|
|
|
|
struct ShaderConfig
|
|
|
|
{
|
|
|
|
public ShaderStage Stage { get; }
|
|
|
|
|
2019-12-16 05:59:46 +01:00
|
|
|
public OutputTopology OutputTopology { get; }
|
|
|
|
|
|
|
|
public int MaxOutputVertices { get; }
|
|
|
|
|
2020-02-02 04:25:52 +01:00
|
|
|
public int LocalMemorySize { get; }
|
|
|
|
|
2020-04-03 02:20:47 +02:00
|
|
|
public ImapPixelType[] ImapTypes { get; }
|
|
|
|
|
|
|
|
public OmapTarget[] OmapTargets { get; }
|
|
|
|
public bool OmapSampleMask { get; }
|
|
|
|
public bool OmapDepth { get; }
|
2019-12-01 03:53:09 +01:00
|
|
|
|
2020-05-06 03:02:28 +02:00
|
|
|
public IGpuAccessor GpuAccessor { get; }
|
2019-10-13 08:02:07 +02:00
|
|
|
|
2020-05-06 03:02:28 +02:00
|
|
|
public TranslationFlags Flags { get; }
|
2019-10-13 08:02:07 +02:00
|
|
|
|
2020-05-06 03:02:28 +02:00
|
|
|
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationFlags flags)
|
2019-12-16 05:59:46 +01:00
|
|
|
{
|
2020-01-01 16:39:09 +01:00
|
|
|
Stage = ShaderStage.Compute;
|
|
|
|
OutputTopology = OutputTopology.PointList;
|
|
|
|
MaxOutputVertices = 0;
|
2020-02-02 04:25:52 +01:00
|
|
|
LocalMemorySize = 0;
|
2020-04-03 02:20:47 +02:00
|
|
|
ImapTypes = null;
|
2020-01-01 16:39:09 +01:00
|
|
|
OmapTargets = null;
|
|
|
|
OmapSampleMask = false;
|
|
|
|
OmapDepth = false;
|
2020-05-06 03:02:28 +02:00
|
|
|
GpuAccessor = gpuAccessor;
|
2020-01-01 16:39:09 +01:00
|
|
|
Flags = flags;
|
2019-12-16 05:59:46 +01:00
|
|
|
}
|
|
|
|
|
2020-05-06 03:02:28 +02:00
|
|
|
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
2019-12-16 05:59:46 +01:00
|
|
|
{
|
2020-01-01 16:39:09 +01:00
|
|
|
Stage = header.Stage;
|
|
|
|
OutputTopology = header.OutputTopology;
|
|
|
|
MaxOutputVertices = header.MaxOutputVertexCount;
|
2020-02-02 04:25:52 +01:00
|
|
|
LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize;
|
2020-04-03 02:20:47 +02:00
|
|
|
ImapTypes = header.ImapTypes;
|
2020-01-01 16:39:09 +01:00
|
|
|
OmapTargets = header.OmapTargets;
|
|
|
|
OmapSampleMask = header.OmapSampleMask;
|
|
|
|
OmapDepth = header.OmapDepth;
|
2020-05-06 03:02:28 +02:00
|
|
|
GpuAccessor = gpuAccessor;
|
2020-01-01 16:39:09 +01:00
|
|
|
Flags = flags;
|
2019-12-16 05:59:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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 08:02:07 +02:00
|
|
|
}
|
|
|
|
}
|