aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/ShaderConfig.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-12-16 01:59:46 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit9d7a142a48a5f804127fcae2265bb6ec5495d178 (patch)
tree4ba4de906d74404760fcbebe9aeb51460252f500 /Ryujinx.Graphics.Shader/ShaderConfig.cs
parent2eccc7023ae0d1247378516b14507d422e4915c5 (diff)
Support texture rectangle targets (non-normalized coords)
Diffstat (limited to 'Ryujinx.Graphics.Shader/ShaderConfig.cs')
-rw-r--r--Ryujinx.Graphics.Shader/ShaderConfig.cs103
1 files changed, 89 insertions, 14 deletions
diff --git a/Ryujinx.Graphics.Shader/ShaderConfig.cs b/Ryujinx.Graphics.Shader/ShaderConfig.cs
index 3088cfbb..6b3640df 100644
--- a/Ryujinx.Graphics.Shader/ShaderConfig.cs
+++ b/Ryujinx.Graphics.Shader/ShaderConfig.cs
@@ -1,4 +1,5 @@
using Ryujinx.Graphics.Shader.Translation;
+using System;
namespace Ryujinx.Graphics.Shader
{
@@ -6,26 +7,100 @@ namespace Ryujinx.Graphics.Shader
{
public ShaderStage Stage { get; }
- public ShaderCapabilities Capabilities { get; }
+ public OutputTopology OutputTopology { get; }
+
+ public int MaxOutputVertices { get; }
+
+ public OutputMapTarget[] OmapTargets { get; }
+ public bool OmapSampleMask { get; }
+ public bool OmapDepth { get; }
public TranslationFlags Flags { get; }
- public int MaxOutputVertices { get; }
+ private QueryInfoCallback _queryInfoCallback;
- public OutputTopology OutputTopology { get; }
+ public ShaderConfig(TranslationFlags flags, QueryInfoCallback queryInfoCallback)
+ {
+ Stage = ShaderStage.Compute;
+ OutputTopology = OutputTopology.PointList;
+ MaxOutputVertices = 0;
+ OmapTargets = null;
+ OmapSampleMask = false;
+ OmapDepth = false;
+ Flags = flags;
+ _queryInfoCallback = queryInfoCallback;
+ }
+
+ public ShaderConfig(ShaderHeader header, TranslationFlags flags, QueryInfoCallback queryInfoCallback)
+ {
+ Stage = header.Stage;
+ OutputTopology = header.OutputTopology;
+ MaxOutputVertices = header.MaxOutputVertexCount;
+ OmapTargets = header.OmapTargets;
+ OmapSampleMask = header.OmapSampleMask;
+ OmapDepth = header.OmapDepth;
+ Flags = flags;
+ _queryInfoCallback = queryInfoCallback;
+ }
+
+ 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;
+ }
- public ShaderConfig(
- ShaderStage stage,
- ShaderCapabilities capabilities,
- TranslationFlags flags,
- int maxOutputVertices,
- OutputTopology outputTopology)
+ public bool QueryInfoBool(QueryInfoName info, int index = 0)
{
- Stage = stage;
- Capabilities = capabilities;
- Flags = flags;
- MaxOutputVertices = maxOutputVertices;
- OutputTopology = outputTopology;
+ return Convert.ToBoolean(QueryInfo(info, index));
+ }
+
+ public int QueryInfo(QueryInfoName info, int index = 0)
+ {
+ if (_queryInfoCallback != null)
+ {
+ return _queryInfoCallback(info, index);
+ }
+ else
+ {
+ switch (info)
+ {
+ case QueryInfoName.ComputeLocalSizeX:
+ case QueryInfoName.ComputeLocalSizeY:
+ case QueryInfoName.ComputeLocalSizeZ:
+ return 1;
+ case QueryInfoName.ComputeSharedMemorySize:
+ return 0xc000;
+ case QueryInfoName.IsTextureBuffer:
+ return Convert.ToInt32(false);
+ case QueryInfoName.IsTextureRectangle:
+ return Convert.ToInt32(false);
+ case QueryInfoName.MaximumViewportDimensions:
+ return 0x8000;
+ case QueryInfoName.PrimitiveTopology:
+ return (int)InputTopology.Points;
+ case QueryInfoName.StorageBufferOffsetAlignment:
+ return 16;
+ case QueryInfoName.SupportsNonConstantTextureOffset:
+ return Convert.ToInt32(true);
+ case QueryInfoName.ViewportTransformEnable:
+ return Convert.ToInt32(true);
+ }
+ }
+
+ return 0;
}
}
} \ No newline at end of file