Implement Viewport Transform Disable (#3328)
* Initial implementation (no specialization) * Use specialization * Fix render scale, increase code gen version * Revert accidental change * Address Feedback
This commit is contained in:
parent
92ca1cb0cb
commit
43b4b34376
24 changed files with 200 additions and 26 deletions
|
@ -67,6 +67,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
public const int FragmentOutputIsBgraBase = 0x1000100;
|
||||
public const int FragmentOutputIsBgraEnd = FragmentOutputIsBgraBase + 8 * 4;
|
||||
|
||||
public const int SupportBlockViewInverseX = 0x1000200;
|
||||
public const int SupportBlockViewInverseY = 0x1000204;
|
||||
|
||||
public const int ThreadIdX = 0x2000000;
|
||||
public const int ThreadIdY = 0x2000004;
|
||||
public const int ThreadIdZ = 0x2000008;
|
||||
|
|
|
@ -154,9 +154,56 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return label;
|
||||
}
|
||||
|
||||
public void PrepareForVertexReturn()
|
||||
{
|
||||
if (Config.GpuAccessor.QueryViewportTransformDisable())
|
||||
{
|
||||
Operand x = Attribute(AttributeConsts.PositionX | AttributeConsts.LoadOutputMask);
|
||||
Operand y = Attribute(AttributeConsts.PositionY | AttributeConsts.LoadOutputMask);
|
||||
Operand xScale = Attribute(AttributeConsts.SupportBlockViewInverseX);
|
||||
Operand yScale = Attribute(AttributeConsts.SupportBlockViewInverseY);
|
||||
Operand negativeOne = ConstF(-1.0f);
|
||||
|
||||
this.Copy(Attribute(AttributeConsts.PositionX), this.FPFusedMultiplyAdd(x, xScale, negativeOne));
|
||||
this.Copy(Attribute(AttributeConsts.PositionY), this.FPFusedMultiplyAdd(y, yScale, negativeOne));
|
||||
}
|
||||
}
|
||||
|
||||
public void PrepareForVertexReturn(out Operand oldXLocal, out Operand oldYLocal, out Operand oldZLocal)
|
||||
{
|
||||
if (Config.GpuAccessor.QueryViewportTransformDisable())
|
||||
{
|
||||
oldXLocal = Local();
|
||||
this.Copy(oldXLocal, Attribute(AttributeConsts.PositionX | AttributeConsts.LoadOutputMask));
|
||||
oldYLocal = Local();
|
||||
this.Copy(oldYLocal, Attribute(AttributeConsts.PositionY | AttributeConsts.LoadOutputMask));
|
||||
}
|
||||
else
|
||||
{
|
||||
oldXLocal = null;
|
||||
oldYLocal = null;
|
||||
}
|
||||
|
||||
// Will be used by Vulkan backend for depth mode emulation.
|
||||
oldZLocal = null;
|
||||
|
||||
PrepareForVertexReturn();
|
||||
}
|
||||
|
||||
public void PrepareForReturn()
|
||||
{
|
||||
if (!IsNonMain && Config.Stage == ShaderStage.Fragment)
|
||||
if (IsNonMain)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.LastInVertexPipeline &&
|
||||
(Config.Stage == ShaderStage.Vertex || Config.Stage == ShaderStage.TessellationEvaluation) &&
|
||||
(Config.Options.Flags & TranslationFlags.VertexA) == 0)
|
||||
{
|
||||
PrepareForVertexReturn();
|
||||
}
|
||||
else if (Config.Stage == ShaderStage.Fragment)
|
||||
{
|
||||
if (Config.OmapDepth)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
public ShaderStage Stage { get; }
|
||||
|
||||
public bool GpPassthrough { get; }
|
||||
public bool LastInVertexPipeline { get; private set; }
|
||||
|
||||
public int ThreadsPerInputPrimitive { get; }
|
||||
|
||||
|
@ -135,6 +136,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
OmapSampleMask = header.OmapSampleMask;
|
||||
OmapDepth = header.OmapDepth;
|
||||
TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled();
|
||||
LastInVertexPipeline = header.Stage < ShaderStage.Fragment;
|
||||
}
|
||||
|
||||
public int GetDepthRegister()
|
||||
|
@ -274,6 +276,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
NextInputAttributesPerPatchComponents = config.ThisInputAttributesPerPatchComponents;
|
||||
NextUsesFixedFuncAttributes = config.UsedFeatures.HasFlag(FeatureFlags.FixedFuncAttr);
|
||||
MergeOutputUserAttributes(config.UsedInputAttributes, config.UsedInputAttributesPerPatch);
|
||||
|
||||
if (config.Stage != ShaderStage.Fragment)
|
||||
{
|
||||
LastInVertexPipeline = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void MergeOutputUserAttributes(int mask, int maskPerPatch)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue