From 21cd4c0c00e4a06e399c93419c8f9eff0e663bfb Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 22 Nov 2023 20:51:51 -0300 Subject: Extend bindless elimination to see through shuffle (#5958) * Extend bindless elimination to see through shuffle * Shader cache version bump --- .../Translation/Optimizations/BindlessElimination.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Ryujinx.Graphics.Shader') diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs index c955f5b5..6706053e 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs @@ -29,7 +29,16 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations if (texOp.Inst == Instruction.TextureSample || texOp.Inst.IsTextureQuery()) { - Operand bindlessHandle = Utils.FindLastOperation(texOp.GetSource(0), block); + Operand bindlessHandle = texOp.GetSource(0); + + // In some cases the compiler uses a shuffle operation to get the handle, + // for some textureGrad implementations. In those cases, we can skip the shuffle. + if (bindlessHandle.AsgOp is Operation shuffleOp && shuffleOp.Inst == Instruction.Shuffle) + { + bindlessHandle = shuffleOp.GetSource(0); + } + + bindlessHandle = Utils.FindLastOperation(bindlessHandle, block); // Some instructions do not encode an accurate sampler type: // - Most instructions uses the same type for 1D and Buffer. -- cgit v1.2.3