aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs23
1 files changed, 22 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
index 5108d861..df42a13c 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Numerics;
using static Spv.Specification;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
@@ -622,7 +623,27 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
else if (attr >= AttributeConsts.FragmentOutputColorBase && attr < AttributeConsts.FragmentOutputColorEnd)
{
int location = (attr - AttributeConsts.FragmentOutputColorBase) / 16;
- context.Decorate(spvVar, Decoration.Location, (LiteralInteger)location);
+
+ if (context.Config.Stage == ShaderStage.Fragment && context.Config.GpuAccessor.QueryDualSourceBlendEnable())
+ {
+ int firstLocation = BitOperations.TrailingZeroCount(context.Config.UsedOutputAttributes);
+ int index = location - firstLocation;
+ int mask = 3 << firstLocation;
+
+ if ((uint)index < 2 && (context.Config.UsedOutputAttributes & mask) == mask)
+ {
+ context.Decorate(spvVar, Decoration.Location, (LiteralInteger)firstLocation);
+ context.Decorate(spvVar, Decoration.Index, (LiteralInteger)index);
+ }
+ else
+ {
+ context.Decorate(spvVar, Decoration.Location, (LiteralInteger)location);
+ }
+ }
+ else
+ {
+ context.Decorate(spvVar, Decoration.Location, (LiteralInteger)location);
+ }
}
if (!isOutAttr)