diff options
author | gdkchan <gab.dark.100@gmail.com> | 2023-02-25 07:39:51 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-25 10:39:51 +0000 |
commit | cedd2007451c046a1276556bacb4e19333b11557 (patch) | |
tree | ea755d325fc23e0dca26e6138609a24429b37ce9 /Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | |
parent | 58207685c0dcda07d18f5f538629c775e2a714b8 (diff) |
Move gl_Layer to vertex shader if geometry is not supported (#4368)1.1.639
* Set gl_Layer on vertex shader if it's set on the geometry shader and it does nothing else
* Shader cache version bump
* PR feedback
* Fix typo
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 5c045d9b..11f7085d 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -353,6 +353,11 @@ namespace Ryujinx.Graphics.Gpu.Shader } } + if (!_context.Capabilities.SupportsGeometryShader) + { + TryRemoveGeometryStage(translatorContexts); + } + CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1]; List<ShaderSource> shaderSources = new List<ShaderSource>(); @@ -422,6 +427,39 @@ namespace Ryujinx.Graphics.Gpu.Shader } /// <summary> + /// Tries to eliminate the geometry stage from the array of translator contexts. + /// </summary> + /// <param name="translatorContexts">Array of translator contexts</param> + public static void TryRemoveGeometryStage(TranslatorContext[] translatorContexts) + { + if (translatorContexts[4] != null) + { + // We have a geometry shader, but geometry shaders are not supported. + // Try to eliminate the geometry shader. + + ShaderProgramInfo info = translatorContexts[4].Translate().Info; + + if (info.Identification == ShaderIdentification.GeometryLayerPassthrough) + { + // We managed to identify that this geometry shader is only used to set the output Layer value, + // we can set the Layer on the previous stage instead (usually the vertex stage) and eliminate it. + + for (int i = 3; i >= 1; i--) + { + if (translatorContexts[i] != null) + { + translatorContexts[i].SetGeometryShaderLayerInputAttribute(info.GpLayerInputAttribute); + translatorContexts[i].SetLastInVertexPipeline(translatorContexts[5] != null); + break; + } + } + + translatorContexts[4] = null; + } + } + } + + /// <summary> /// Creates a shader source for use with the backend from a translated shader program. /// </summary> /// <param name="program">Translated shader program</param> |