diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-10-28 17:20:43 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-28 21:20:43 +0100 |
| commit | 0031edae27ba6a7bdb08db51efd84c887a6bdabd (patch) | |
| tree | 3377a2105380789a3c52a3d3e2c864bcde5a74ad /Ryujinx.Graphics.Shader/SamplerType.cs | |
| parent | 9f13f957af9cf3691c22ff67b5dc28a588024b4d (diff) | |
Avoid sampler conflicts on bindless samplers with the same name (#1642)
Diffstat (limited to 'Ryujinx.Graphics.Shader/SamplerType.cs')
| -rw-r--r-- | Ryujinx.Graphics.Shader/SamplerType.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/SamplerType.cs b/Ryujinx.Graphics.Shader/SamplerType.cs index 9546efe4..286ae9d5 100644 --- a/Ryujinx.Graphics.Shader/SamplerType.cs +++ b/Ryujinx.Graphics.Shader/SamplerType.cs @@ -1,3 +1,4 @@ +using Ryujinx.Graphics.Shader.StructuredIr; using System; namespace Ryujinx.Graphics.Shader @@ -35,5 +36,72 @@ namespace Ryujinx.Graphics.Shader throw new ArgumentException($"Invalid sampler type \"{type}\"."); } + + public static string ToGlslSamplerType(this SamplerType type) + { + string typeName; + + switch (type & SamplerType.Mask) + { + case SamplerType.Texture1D: typeName = "sampler1D"; break; + case SamplerType.TextureBuffer: typeName = "samplerBuffer"; break; + case SamplerType.Texture2D: typeName = "sampler2D"; break; + case SamplerType.Texture3D: typeName = "sampler3D"; break; + case SamplerType.TextureCube: typeName = "samplerCube"; break; + + default: throw new ArgumentException($"Invalid sampler type \"{type}\"."); + } + + if ((type & SamplerType.Multisample) != 0) + { + typeName += "MS"; + } + + if ((type & SamplerType.Array) != 0) + { + typeName += "Array"; + } + + if ((type & SamplerType.Shadow) != 0) + { + typeName += "Shadow"; + } + + return typeName; + } + + public static string ToGlslImageType(this SamplerType type, VariableType componentType) + { + string typeName; + + switch (type & SamplerType.Mask) + { + case SamplerType.Texture1D: typeName = "image1D"; break; + case SamplerType.TextureBuffer: typeName = "imageBuffer"; break; + case SamplerType.Texture2D: typeName = "image2D"; break; + case SamplerType.Texture3D: typeName = "image3D"; break; + case SamplerType.TextureCube: typeName = "imageCube"; break; + + default: throw new ArgumentException($"Invalid sampler type \"{type}\"."); + } + + if ((type & SamplerType.Multisample) != 0) + { + typeName += "MS"; + } + + if ((type & SamplerType.Array) != 0) + { + typeName += "Array"; + } + + switch (componentType) + { + case VariableType.U32: typeName = 'u' + typeName; break; + case VariableType.S32: typeName = 'i' + typeName; break; + } + + return typeName; + } } }
\ No newline at end of file |
