diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2022-05-12 14:47:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-12 10:47:13 -0300 |
| commit | 43b4b34376cdea486906f8bb4058dda3be7e1bd8 (patch) | |
| tree | 66e11982136335f0d7b180f9234b326ee5b3bf10 /Ryujinx.Graphics.Shader/CodeGen | |
| parent | 92ca1cb0cbab228e5ef22645cd4f9d06b1da4766 (diff) | |
Implement Viewport Transform Disable (#3328)
* Initial implementation (no specialization)
* Use specialization
* Fix render scale, increase code gen version
* Revert accidental change
* Address Feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen')
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs | 9 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs | 1 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs | 5 |
3 files changed, 11 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index c955a616..59a7ccdc 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -249,7 +249,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl context.AppendLine(); } } - else if (isFragment) + else if (isFragment || context.Config.Stage == ShaderStage.Vertex) { DeclareSupportUniformBlock(context, context.Config.Stage, 0); } @@ -615,8 +615,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl private static void DeclareSupportUniformBlock(CodeGenContext context, ShaderStage stage, int scaleElements) { - bool isFragment = stage == ShaderStage.Fragment; - if (!isFragment && scaleElements == 0) + bool needsSupportBlock = stage == ShaderStage.Fragment || + (context.Config.LastInVertexPipeline && context.Config.GpuAccessor.QueryViewportTransformDisable()); + + if (!needsSupportBlock && scaleElements == 0) { return; } @@ -630,6 +632,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl case ShaderStage.Vertex: context.AppendLine($"uint {DefaultNames.SupportBlockAlphaTestName};"); context.AppendLine($"bool {DefaultNames.SupportBlockIsBgraName}[{SupportBuffer.FragmentIsBgraCount}];"); + context.AppendLine($"vec4 {DefaultNames.SupportBlockViewportInverse};"); context.AppendLine($"int {DefaultNames.SupportBlockFragmentScaleCount};"); break; case ShaderStage.Compute: diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs index 76203522..3ab4814c 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs @@ -18,6 +18,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl public const string SupportBlockName = "support_block"; public const string SupportBlockAlphaTestName = "s_alpha_test"; public const string SupportBlockIsBgraName = "s_is_bgra"; + public const string SupportBlockViewportInverse = "s_viewport_inverse"; public const string SupportBlockFragmentScaleCount = "s_frag_scale_count"; public const string SupportBlockRenderScaleName = "s_render_scale"; diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs index 2d6607ad..334c744d 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs @@ -84,7 +84,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { AttributeConsts.FragmentOutputIsBgraBase + 16, new BuiltInAttribute($"{DefaultNames.SupportBlockIsBgraName}[4]", VariableType.Bool) }, { AttributeConsts.FragmentOutputIsBgraBase + 20, new BuiltInAttribute($"{DefaultNames.SupportBlockIsBgraName}[5]", VariableType.Bool) }, { AttributeConsts.FragmentOutputIsBgraBase + 24, new BuiltInAttribute($"{DefaultNames.SupportBlockIsBgraName}[6]", VariableType.Bool) }, - { AttributeConsts.FragmentOutputIsBgraBase + 28, new BuiltInAttribute($"{DefaultNames.SupportBlockIsBgraName}[7]", VariableType.Bool) } + { AttributeConsts.FragmentOutputIsBgraBase + 28, new BuiltInAttribute($"{DefaultNames.SupportBlockIsBgraName}[7]", VariableType.Bool) }, + + { AttributeConsts.SupportBlockViewInverseX, new BuiltInAttribute($"{DefaultNames.SupportBlockViewportInverse}.x", VariableType.F32) }, + { AttributeConsts.SupportBlockViewInverseY, new BuiltInAttribute($"{DefaultNames.SupportBlockViewportInverse}.y", VariableType.F32) } }; private Dictionary<AstOperand, string> _locals; |
