diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2021-09-02 04:17:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-02 00:17:43 -0300 |
| commit | f0b00c1ae92a2e8fdff9c532e7f2f79ad708b184 (patch) | |
| tree | 76ac9ca16b6bf8dce852249993eb3486798000b7 /Ryujinx.Graphics.Shader/Translation | |
| parent | 142cededd4db2ff4f83a4833580d343a4f0a8cde (diff) | |
Fix TXQ for 3D textures. (#2613)
* Fix TXQ for 3D textures.
Assumes the texture is 3D if the component mask contains Z.
This fixes a bug in UE4 games where parts of the map had garbage pointers to lighting voxels, as the lookup 3D texture was not being initialized. Most notable game is THPS1+2.
May need another PR to keep image store data alive and properly flush it in order using the AutoDeleteCache.
* Get sampler type for TextureSize from bound textures.
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs | 16 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs b/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs index 709668f4..e2f2b752 100644 --- a/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs +++ b/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs @@ -30,10 +30,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations texOp.Inst == Instruction.TextureSize) { Operand bindlessHandle = Utils.FindLastOperation(texOp.GetSource(0), block); + bool rewriteSamplerType = texOp.Inst == Instruction.TextureSize; if (bindlessHandle.Type == OperandType.ConstantBuffer) { - SetHandle(config, texOp, bindlessHandle.GetCbufOffset(), bindlessHandle.GetCbufSlot()); + SetHandle(config, texOp, bindlessHandle.GetCbufOffset(), bindlessHandle.GetCbufSlot(), rewriteSamplerType); continue; } @@ -59,7 +60,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations config, texOp, src0.GetCbufOffset() | ((src1.GetCbufOffset() + 1) << 16), - src0.GetCbufSlot() | ((src1.GetCbufSlot() + 1) << 16)); + src0.GetCbufSlot() | ((src1.GetCbufSlot() + 1) << 16), + rewriteSamplerType); } else if (texOp.Inst == Instruction.ImageLoad || texOp.Inst == Instruction.ImageStore || @@ -81,15 +83,21 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations texOp.Format = config.GetTextureFormat(cbufOffset, cbufSlot); } - SetHandle(config, texOp, cbufOffset, cbufSlot); + SetHandle(config, texOp, cbufOffset, cbufSlot, false); } } } } - private static void SetHandle(ShaderConfig config, TextureOperation texOp, int cbufOffset, int cbufSlot) + private static void SetHandle(ShaderConfig config, TextureOperation texOp, int cbufOffset, int cbufSlot, bool rewriteSamplerType) { texOp.SetHandle(cbufOffset, cbufSlot); + + if (rewriteSamplerType) + { + texOp.Type = config.GpuAccessor.QuerySamplerType(cbufOffset, cbufSlot); + } + config.SetUsedTexture(texOp.Inst, texOp.Type, texOp.Format, texOp.Flags, cbufSlot, cbufOffset); } } diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs index 7d3246db..72fa7733 100644 --- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs +++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs @@ -294,7 +294,7 @@ namespace Ryujinx.Graphics.Shader.Translation inst &= Instruction.Mask; bool isImage = inst == Instruction.ImageLoad || inst == Instruction.ImageStore || inst == Instruction.ImageAtomic; bool isWrite = inst == Instruction.ImageStore || inst == Instruction.ImageAtomic; - bool accurateType = inst != Instruction.TextureSize && inst != Instruction.Lod; + bool accurateType = inst != Instruction.Lod; if (isImage) { |
