aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
diff options
context:
space:
mode:
authorMary <me@thog.eu>2020-11-13 00:15:34 +0100
committerGitHub <noreply@github.com>2020-11-13 00:15:34 +0100
commit48f6570557fc76496936514d94e3ccddf55ec633 (patch)
treece455833899cb33a312e5853a7a3d191bb5d18d9 /Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
parent7166e82c3cf1fd8cf2fce3281017ee88122684d8 (diff)
Salieri: shader cache (#1701)
Here come Salieri, my implementation of a disk shader cache! "I'm sure you know why I named it that." "It doesn't really mean anything." This implementation collects shaders at runtime and cache them to be later compiled when starting a game.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs100
1 files changed, 4 insertions, 96 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
index 0eaa534b..b3f1b3a8 100644
--- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -1,6 +1,5 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL;
-using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.State;
using Ryujinx.Graphics.Shader;
@@ -9,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Represents a GPU state and memory accessor.
/// </summary>
- class GpuAccessor : IGpuAccessor
+ class GpuAccessor : TextureDescriptorCapableGpuAccessor, IGpuAccessor
{
private readonly GpuContext _context;
private readonly GpuState _state;
@@ -78,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <typeparam name="T">Type of the data to be read</typeparam>
/// <param name="address">GPU virtual address of the data</param>
/// <returns>Data at the memory location</returns>
- public T MemoryRead<T>(ulong address) where T : unmanaged
+ public override T MemoryRead<T>(ulong address)
{
return _context.MemoryManager.Read<T>(address);
}
@@ -135,33 +134,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
- /// Queries texture target information.
- /// </summary>
- /// <param name="handle">Texture handle</param>
- /// <returns>True if the texture is a buffer texture, false otherwise</returns>
- public bool QueryIsTextureBuffer(int handle)
- {
- return GetTextureDescriptor(handle).UnpackTextureTarget() == TextureTarget.TextureBuffer;
- }
-
- /// <summary>
- /// Queries texture target information.
- /// </summary>
- /// <param name="handle">Texture handle</param>
- /// <returns>True if the texture is a rectangle texture, false otherwise</returns>
- public bool QueryIsTextureRectangle(int handle)
- {
- var descriptor = GetTextureDescriptor(handle);
-
- TextureTarget target = descriptor.UnpackTextureTarget();
-
- bool is2DTexture = target == TextureTarget.Texture2D ||
- target == TextureTarget.Texture2DRect;
-
- return !descriptor.UnpackTextureCoordNormalized() && is2DTexture;
- }
-
- /// <summary>
/// Queries current primitive topology for geometry shaders.
/// </summary>
/// <returns>Current primitive topology</returns>
@@ -209,75 +181,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
public bool QuerySupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
/// <summary>
- /// Queries texture format information, for shaders using image load or store.
- /// </summary>
- /// <remarks>
- /// This only returns non-compressed color formats.
- /// If the format of the texture is a compressed, depth or unsupported format, then a default value is returned.
- /// </remarks>
- /// <param name="handle">Texture handle</param>
- /// <returns>Color format of the non-compressed texture</returns>
- public TextureFormat QueryTextureFormat(int handle)
- {
- var descriptor = GetTextureDescriptor(handle);
-
- if (!FormatTable.TryGetTextureFormat(descriptor.UnpackFormat(), descriptor.UnpackSrgb(), out FormatInfo formatInfo))
- {
- return TextureFormat.Unknown;
- }
-
- return formatInfo.Format switch
- {
- Format.R8Unorm => TextureFormat.R8Unorm,
- Format.R8Snorm => TextureFormat.R8Snorm,
- Format.R8Uint => TextureFormat.R8Uint,
- Format.R8Sint => TextureFormat.R8Sint,
- Format.R16Float => TextureFormat.R16Float,
- Format.R16Unorm => TextureFormat.R16Unorm,
- Format.R16Snorm => TextureFormat.R16Snorm,
- Format.R16Uint => TextureFormat.R16Uint,
- Format.R16Sint => TextureFormat.R16Sint,
- Format.R32Float => TextureFormat.R32Float,
- Format.R32Uint => TextureFormat.R32Uint,
- Format.R32Sint => TextureFormat.R32Sint,
- Format.R8G8Unorm => TextureFormat.R8G8Unorm,
- Format.R8G8Snorm => TextureFormat.R8G8Snorm,
- Format.R8G8Uint => TextureFormat.R8G8Uint,
- Format.R8G8Sint => TextureFormat.R8G8Sint,
- Format.R16G16Float => TextureFormat.R16G16Float,
- Format.R16G16Unorm => TextureFormat.R16G16Unorm,
- Format.R16G16Snorm => TextureFormat.R16G16Snorm,
- Format.R16G16Uint => TextureFormat.R16G16Uint,
- Format.R16G16Sint => TextureFormat.R16G16Sint,
- Format.R32G32Float => TextureFormat.R32G32Float,
- Format.R32G32Uint => TextureFormat.R32G32Uint,
- Format.R32G32Sint => TextureFormat.R32G32Sint,
- Format.R8G8B8A8Unorm => TextureFormat.R8G8B8A8Unorm,
- Format.R8G8B8A8Snorm => TextureFormat.R8G8B8A8Snorm,
- Format.R8G8B8A8Uint => TextureFormat.R8G8B8A8Uint,
- Format.R8G8B8A8Sint => TextureFormat.R8G8B8A8Sint,
- Format.R8G8B8A8Srgb => TextureFormat.R8G8B8A8Unorm,
- Format.R16G16B16A16Float => TextureFormat.R16G16B16A16Float,
- Format.R16G16B16A16Unorm => TextureFormat.R16G16B16A16Unorm,
- Format.R16G16B16A16Snorm => TextureFormat.R16G16B16A16Snorm,
- Format.R16G16B16A16Uint => TextureFormat.R16G16B16A16Uint,
- Format.R16G16B16A16Sint => TextureFormat.R16G16B16A16Sint,
- Format.R32G32B32A32Float => TextureFormat.R32G32B32A32Float,
- Format.R32G32B32A32Uint => TextureFormat.R32G32B32A32Uint,
- Format.R32G32B32A32Sint => TextureFormat.R32G32B32A32Sint,
- Format.R10G10B10A2Unorm => TextureFormat.R10G10B10A2Unorm,
- Format.R10G10B10A2Uint => TextureFormat.R10G10B10A2Uint,
- Format.R11G11B10Float => TextureFormat.R11G11B10Float,
- _ => TextureFormat.Unknown
- };
- }
-
- /// <summary>
/// Gets the texture descriptor for a given texture on the pool.
/// </summary>
- /// <param name="handle">Index of the texture (this is the shader "fake" handle)</param>
+ /// <param name="handle">Index of the texture (this is the word offset of the handle in the constant buffer)</param>
/// <returns>Texture descriptor</returns>
- private Image.TextureDescriptor GetTextureDescriptor(int handle)
+ public override Image.TextureDescriptor GetTextureDescriptor(int handle)
{
if (_compute)
{