Implement BGRA texture support (#1418)

* Implement BGRA texture support

* Missing AppendLine

* Remove empty lines

* Address PR feedback
This commit is contained in:
gdkchan 2020-07-26 00:03:40 -03:00 committed by GitHub
parent 2678bf0010
commit 8dbcae1ff8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 232 additions and 61 deletions

View file

@ -115,22 +115,46 @@ namespace Ryujinx.Graphics.Shader.Translation
int regIndex = 0;
for (int attachment = 0; attachment < 8; attachment++)
for (int rtIndex = 0; rtIndex < 8; rtIndex++)
{
OmapTarget target = Config.OmapTargets[attachment];
OmapTarget target = Config.OmapTargets[rtIndex];
for (int component = 0; component < 4; component++)
{
if (target.ComponentEnabled(component))
if (!target.ComponentEnabled(component))
{
Operand dest = Attribute(AttributeConsts.FragmentOutputColorBase + attachment * 16 + component * 4);
Operand src = Register(regIndex, RegisterType.Gpr);
this.Copy(dest, src);
regIndex++;
continue;
}
int fragmentOutputColorAttr = AttributeConsts.FragmentOutputColorBase + rtIndex * 16;
Operand src = Register(regIndex, RegisterType.Gpr);
// Perform B <-> R swap if needed, for BGRA formats (not supported on OpenGL).
if (component == 0 || component == 2)
{
Operand isBgra = Attribute(AttributeConsts.FragmentOutputIsBgraBase + rtIndex * 4);
Operand lblIsBgra = Label();
Operand lblEnd = Label();
this.BranchIfTrue(lblIsBgra, isBgra);
this.Copy(Attribute(fragmentOutputColorAttr + component * 4), src);
this.Branch(lblEnd);
MarkLabel(lblIsBgra);
this.Copy(Attribute(fragmentOutputColorAttr + (2 - component) * 4), src);
MarkLabel(lblEnd);
}
else
{
this.Copy(Attribute(fragmentOutputColorAttr + component * 4), src);
}
regIndex++;
}
}
}