diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-06-24 19:54:50 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-25 00:54:50 +0200 |
| commit | ed2f5ede0f8d8f58390745f5e237bbfea36397fe (patch) | |
| tree | a197861cf93d1e279a288fe0be32aa43cae5cb9a /Ryujinx.Graphics.Shader/CodeGen | |
| parent | eac659e37bf2ad8398a959c91f7b30017e4ad7f3 (diff) | |
Fix texture sampling with depth compare and LOD level or bias (#2404)
* Fix texture sampling with depth compare and LOD level or bias
* Shader cache version bump
* nit: Sorting
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen')
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs | 26 |
2 files changed, 20 insertions, 8 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index 2e993ef0..4471fa32 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -20,6 +20,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl context.AppendLine("#extension GL_ARB_shader_ballot : enable"); context.AppendLine("#extension GL_ARB_shader_group_vote : enable"); context.AppendLine("#extension GL_EXT_shader_image_load_formatted : enable"); + context.AppendLine("#extension GL_EXT_texture_shadow_lod : enable"); if (context.Config.Stage == ShaderStage.Compute) { @@ -32,7 +33,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl } context.AppendLine("#pragma optionNV(fastmath off)"); - context.AppendLine(); context.AppendLine($"const int {DefaultNames.UndefinedName} = 0;"); diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs index 911c7b05..cb99bdcc 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs @@ -309,20 +309,32 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions bool isMultisample = (texOp.Type & SamplerType.Multisample) != 0; bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; - // TODO: Bindless texture support. For now we just return 0. - if (isBindless) + SamplerType type = texOp.Type & SamplerType.Mask; + + bool is2D = type == SamplerType.Texture2D; + bool isCube = type == SamplerType.TextureCube; + + // 2D Array and Cube shadow samplers with LOD level or bias requires an extension. + // If the extension is not supported, just remove the LOD parameter. + if (isArray && isShadow && (is2D || isCube) && !context.Config.GpuAccessor.QuerySupportsTextureShadowLod()) { - return NumberFormatter.FormatFloat(0); + hasLodBias = false; + hasLodLevel = false; } - // This combination is valid, but not available on GLSL. - // For now, ignore the LOD level and do a normal sample. - // TODO: How to implement it properly? - if (hasLodLevel && isArray && isShadow) + // Cube shadow samplers with LOD level requires an extension. + // If the extension is not supported, just remove the LOD level parameter. + if (isShadow && isCube && !context.Config.GpuAccessor.QuerySupportsTextureShadowLod()) { hasLodLevel = false; } + // TODO: Bindless texture support. For now we just return 0. + if (isBindless) + { + return NumberFormatter.FormatFloat(0); + } + string texCall = intCoords ? "texelFetch" : "texture"; if (isGather) |
