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.
This commit is contained in:
parent
142cededd4
commit
f0b00c1ae9
8 changed files with 60 additions and 18 deletions
|
@ -697,7 +697,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
flags = ConvertTextureFlags(tldsOp.Target) | TextureFlags.IntCoords;
|
||||
|
||||
if (tldsOp.Target == TexelLoadTarget.Texture1DLodZero && context.Config.GpuAccessor.QueryIsTextureBuffer(tldsOp.HandleOffset))
|
||||
if (tldsOp.Target == TexelLoadTarget.Texture1DLodZero && context.Config.GpuAccessor.QuerySamplerType(tldsOp.HandleOffset) == SamplerType.TextureBuffer)
|
||||
{
|
||||
type = SamplerType.TextureBuffer;
|
||||
flags &= ~TextureFlags.LodLevel;
|
||||
|
@ -1306,8 +1306,6 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
// TODO: Validate and use property.
|
||||
Instruction inst = Instruction.TextureSize;
|
||||
|
||||
SamplerType type = SamplerType.Texture2D;
|
||||
|
||||
TextureFlags flags = bindless ? TextureFlags.Bindless : TextureFlags.None;
|
||||
|
||||
int raIndex = op.Ra.Index;
|
||||
|
@ -1347,6 +1345,17 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
int handle = !bindless ? op.HandleOffset : 0;
|
||||
|
||||
SamplerType type;
|
||||
|
||||
if (bindless)
|
||||
{
|
||||
type = (op.ComponentMask & 4) != 0 ? SamplerType.Texture3D : SamplerType.Texture2D;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = context.Config.GpuAccessor.QuerySamplerType(handle);
|
||||
}
|
||||
|
||||
for (int compMask = op.ComponentMask, compIndex = 0; compMask != 0; compMask >>= 1, compIndex++)
|
||||
{
|
||||
if ((compMask & 1) != 0)
|
||||
|
@ -1422,7 +1431,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
{
|
||||
// For bindless, we don't have any way to know the texture type,
|
||||
// so we assume it's texture buffer when the sampler type is 1D, since that's more common.
|
||||
bool isTypeBuffer = isBindless || context.Config.GpuAccessor.QueryIsTextureBuffer(op.HandleOffset);
|
||||
bool isTypeBuffer = isBindless || context.Config.GpuAccessor.QuerySamplerType(op.HandleOffset) == SamplerType.TextureBuffer;
|
||||
|
||||
if (isTypeBuffer)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue