aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-09-02 04:17:43 +0100
committerGitHub <noreply@github.com>2021-09-02 00:17:43 -0300
commitf0b00c1ae92a2e8fdff9c532e7f2f79ad708b184 (patch)
tree76ac9ca16b6bf8dce852249993eb3486798000b7 /Ryujinx.Graphics.Gpu
parent142cededd4db2ff4f83a4833580d343a4f0a8cde (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.Gpu')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureTarget.cs23
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs2
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs8
3 files changed, 28 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs b/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
index 1db758fc..5e0a0721 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
@@ -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
+ };
+ }
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 0d479559..cda3ecb3 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Version of the codegen (to be changed when codegen or guest format change).
/// </summary>
- private const ulong ShaderCodeGenVersion = 2092;
+ private const ulong ShaderCodeGenVersion = 2613;
// Progress reporting helpers
private volatile int _shaderCount;
diff --git a/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs
index 54b4133a..7c4eea02 100644
--- a/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs
@@ -119,14 +119,14 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
- /// Queries texture target information.
+ /// Queries sampler type information.
/// </summary>
/// <param name="handle">Texture handle</param>
/// <param name="cbufSlot">Constant buffer slot for the texture handle</param>
- /// <returns>True if the texture is a buffer texture, false otherwise</returns>
- public bool QueryIsTextureBuffer(int handle, int cbufSlot = -1)
+ /// <returns>The sampler type value for the given handle</returns>
+ public SamplerType QuerySamplerType(int handle, int cbufSlot = -1)
{
- return GetTextureDescriptor(handle, cbufSlot).UnpackTextureTarget() == TextureTarget.TextureBuffer;
+ return GetTextureDescriptor(handle, cbufSlot).UnpackTextureTarget().ConvertSamplerType();
}
/// <summary>