aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-08-23 02:07:23 -0300
committergdkchan <gab.dark.100@gmail.com>2018-08-23 02:07:23 -0300
commit624e813cd3e5d782847c577c2da0cfb8a121fd18 (patch)
treefa12638a42a406f1736662f1a2fdee1d9f9bd014 /Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs
parent9977acad0fe08ee98a8174ce1c5609be22ba67ee (diff)
Implement multiple rendertarget attachments and depth writting (#375)
* Add depth writting * Implement multiple attachments * Address feedback
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs')
-rw-r--r--Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs75
1 files changed, 74 insertions, 1 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs b/Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs
index 8e5057ed..eca90fc3 100644
--- a/Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs
+++ b/Ryujinx.Graphics/Gal/Shader/ShaderHeader.cs
@@ -1,5 +1,30 @@
-namespace Ryujinx.Graphics.Gal.Shader
+using System;
+
+namespace Ryujinx.Graphics.Gal.Shader
{
+ struct OmapTarget
+ {
+ public bool Red;
+ public bool Green;
+ public bool Blue;
+ public bool Alpha;
+
+ public bool Enabled => Red || Green || Blue || Alpha;
+
+ public bool ComponentEnabled(int Component)
+ {
+ switch (Component)
+ {
+ case 0: return Red;
+ case 1: return Green;
+ case 2: return Blue;
+ case 3: return Alpha;
+ }
+
+ throw new ArgumentException(nameof(Component));
+ }
+ }
+
class ShaderHeader
{
public const int PointList = 1;
@@ -30,6 +55,10 @@
public int StoreReqStart { get; private set; }
public int StoreReqEnd { get; private set; }
+ public OmapTarget[] OmapTargets { get; private set; }
+ public bool OmapSampleMask { get; private set; }
+ public bool OmapDepth { get; private set; }
+
public ShaderHeader(IGalMemory Memory, long Position)
{
uint CommonWord0 = (uint)Memory.ReadInt32(Position + 0);
@@ -61,6 +90,50 @@
MaxOutputVertexCount = ReadBits(CommonWord4, 0, 12);
StoreReqStart = ReadBits(CommonWord4, 12, 8);
StoreReqEnd = ReadBits(CommonWord4, 24, 8);
+
+ //Type 2 (fragment?) reading
+ uint Type2OmapTarget = (uint)Memory.ReadInt32(Position + 72);
+ uint Type2Omap = (uint)Memory.ReadInt32(Position + 76);
+
+ OmapTargets = new OmapTarget[8];
+
+ for (int i = 0; i < OmapTargets.Length; i++)
+ {
+ int Offset = i * 4;
+
+ OmapTargets[i] = new OmapTarget
+ {
+ Red = ReadBits(Type2OmapTarget, Offset + 0, 1) != 0,
+ Green = ReadBits(Type2OmapTarget, Offset + 1, 1) != 0,
+ Blue = ReadBits(Type2OmapTarget, Offset + 2, 1) != 0,
+ Alpha = ReadBits(Type2OmapTarget, Offset + 3, 1) != 0
+ };
+ }
+
+ OmapSampleMask = ReadBits(Type2Omap, 0, 1) != 0;
+ OmapDepth = ReadBits(Type2Omap, 1, 1) != 0;
+ }
+
+ public int DepthRegister
+ {
+ get
+ {
+ int Count = 0;
+
+ for (int Index = 0; Index < OmapTargets.Length; Index++)
+ {
+ for (int Component = 0; Component < 4; Component++)
+ {
+ if (OmapTargets[Index].ComponentEnabled(Component))
+ {
+ Count++;
+ }
+ }
+ }
+
+ // Depth register is always two registers after the last color output
+ return Count + 1;
+ }
}
private static int ReadBits(uint Word, int Offset, int BitWidth)