From 04dfb86fdeb10f45c0a286309eb18affd47191af Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 24 Oct 2021 19:40:20 -0300 Subject: [PATCH] Preserve image types for shader bindless surface instructions (.D variants) (#2779) * Preserve image types for SULD/SUST .D variants * Make format unknown for surface atomic if bindless and not sized --- .../Instructions/InstEmitSurface.cs | 8 ++++---- .../Optimizations/BindlessElimination.cs | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs index a47d66500..f78f9db89 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs @@ -264,8 +264,8 @@ namespace Ryujinx.Graphics.Shader.Instructions } // TODO: FP and 64-bit formats. - TextureFormat format = !isBindless && (size == SuatomSize.Sd32 || size == SuatomSize.Sd64) - ? context.Config.GetTextureFormatAtomic(imm) + TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64 + ? (isBindless ? TextureFormat.Unknown : context.Config.GetTextureFormatAtomic(imm)) : GetTextureFormat(size); if (compareAndSwap) @@ -516,8 +516,8 @@ namespace Ryujinx.Graphics.Shader.Instructions } // TODO: FP and 64-bit formats. - TextureFormat format = !isBindless && (size == SuatomSize.Sd32 || size == SuatomSize.Sd64) - ? context.Config.GetTextureFormatAtomic(imm) + TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64 + ? (isBindless ? TextureFormat.Unknown : context.Config.GetTextureFormatAtomic(imm)) : GetTextureFormat(size); sourcesList.Add(Rb()); diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs index a76df6a17..1b303caf1 100644 --- a/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs +++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs @@ -128,13 +128,16 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations int cbufOffset = src0.GetCbufOffset(); int cbufSlot = src0.GetCbufSlot(); - if (texOp.Inst == Instruction.ImageAtomic) + if (texOp.Format == TextureFormat.Unknown) { - texOp.Format = config.GetTextureFormatAtomic(cbufOffset, cbufSlot); - } - else - { - texOp.Format = config.GetTextureFormat(cbufOffset, cbufSlot); + if (texOp.Inst == Instruction.ImageAtomic) + { + texOp.Format = config.GetTextureFormatAtomic(cbufOffset, cbufSlot); + } + else + { + texOp.Format = config.GetTextureFormat(cbufOffset, cbufSlot); + } } SetHandle(config, texOp, cbufOffset, cbufSlot, false);