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:
riperiperi 2021-09-02 04:17:43 +01:00 committed by GitHub
parent 142cededd4
commit f0b00c1ae9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 18 deletions

View file

@ -1,4 +1,5 @@
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
namespace Ryujinx.Graphics.Gpu.Image
{
@ -54,5 +55,27 @@ namespace Ryujinx.Graphics.Gpu.Image
return Target.Texture1D;
}
/// <summary>
/// Converts the texture target enum to a shader sampler type.
/// </summary>
/// <param name="target">The target enum to convert</param>
/// <returns>The shader sampler type</returns>
public static SamplerType ConvertSamplerType(this TextureTarget target)
{
return target switch
{
TextureTarget.Texture1D => SamplerType.Texture1D,
TextureTarget.Texture2D => SamplerType.Texture2D,
TextureTarget.Texture3D => SamplerType.Texture3D,
TextureTarget.Cubemap => SamplerType.TextureCube,
TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array,
TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array,
TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
TextureTarget.Texture2DRect => SamplerType.Texture2D,
TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
_ => SamplerType.Texture2D
};
}
}
}