From 3148c0c21cb45a92ff77344027757fb4808bb3cb Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 11 Aug 2021 18:56:59 -0300 Subject: [PATCH] Unify GpuAccessorBase and TextureDescriptorCapableGpuAccessor (#2542) * Unify GpuAccessorBase and TextureDescriptorCapableGpuAccessor * Shader cache version bump --- Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs | 2 +- .../Shader/GpuAccessorBase.cs | 55 ------------------- Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 2 +- .../TextureDescriptorCapableGpuAccessor.cs | 43 ++++++++++++++- 4 files changed, 43 insertions(+), 59 deletions(-) delete mode 100644 Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs index 65c8c287e..91746a962 100644 --- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs +++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// Represents a GPU state and memory accessor. /// - class GpuAccessor : TextureDescriptorCapableGpuAccessor + class GpuAccessor : TextureDescriptorCapableGpuAccessor, IGpuAccessor { private readonly GpuChannel _channel; private readonly GpuAccessorState _state; diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs deleted file mode 100644 index fb990cfe9..000000000 --- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Ryujinx.Graphics.Gpu.Shader -{ - /// - /// Represents a GPU state and memory accessor. - /// - class GpuAccessorBase - { - private readonly GpuContext _context; - - /// - /// Creates a new instance of the GPU state accessor. - /// - /// GPU context - public GpuAccessorBase(GpuContext context) - { - _context = context; - } - - /// - /// Queries host about the presence of the FrontFacing built-in variable bug. - /// - /// True if the bug is present on the host device used, false otherwise - public bool QueryHostHasFrontFacingBug() => _context.Capabilities.HasFrontFacingBug; - - /// - /// Queries host about the presence of the vector indexing bug. - /// - /// True if the bug is present on the host device used, false otherwise - public bool QueryHostHasVectorIndexingBug() => _context.Capabilities.HasVectorIndexingBug; - - /// - /// Queries host storage buffer alignment required. - /// - /// Host storage buffer alignment in bytes - public int QueryHostStorageBufferOffsetAlignment() => _context.Capabilities.StorageBufferOffsetAlignment; - - /// - /// Queries host support for readable images without a explicit format declaration on the shader. - /// - /// True if formatted image load is supported, false otherwise - public bool QueryHostSupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted; - - /// - /// Queries host GPU non-constant texture offset support. - /// - /// True if the GPU and driver supports non-constant texture offsets, false otherwise - public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset; - - /// - /// Queries host GPU texture shadow LOD support. - /// - /// True if the GPU and driver supports texture shadow LOD, false otherwise - public bool QueryHostSupportsTextureShadowLod() => _context.Capabilities.SupportsTextureShadowLod; - } -} diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index fada667c8..5b08593e1 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// Version of the codegen (to be changed when codegen or guest format change). /// - private const ulong ShaderCodeGenVersion = 2540; + private const ulong ShaderCodeGenVersion = 2542; // Progress reporting helpers private volatile int _shaderCount; diff --git a/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs index 355074499..54b4133a0 100644 --- a/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs +++ b/Ryujinx.Graphics.Gpu/Shader/TextureDescriptorCapableGpuAccessor.cs @@ -4,16 +4,55 @@ using Ryujinx.Graphics.Shader; namespace Ryujinx.Graphics.Gpu.Shader { - abstract class TextureDescriptorCapableGpuAccessor : GpuAccessorBase, IGpuAccessor + abstract class TextureDescriptorCapableGpuAccessor : IGpuAccessor { - public TextureDescriptorCapableGpuAccessor(GpuContext context) : base(context) + private readonly GpuContext _context; + + public TextureDescriptorCapableGpuAccessor(GpuContext context) { + _context = context; } public abstract T MemoryRead(ulong address) where T : unmanaged; public abstract ITextureDescriptor GetTextureDescriptor(int handle, int cbufSlot); + /// + /// Queries host about the presence of the FrontFacing built-in variable bug. + /// + /// True if the bug is present on the host device used, false otherwise + public bool QueryHostHasFrontFacingBug() => _context.Capabilities.HasFrontFacingBug; + + /// + /// Queries host about the presence of the vector indexing bug. + /// + /// True if the bug is present on the host device used, false otherwise + public bool QueryHostHasVectorIndexingBug() => _context.Capabilities.HasVectorIndexingBug; + + /// + /// Queries host storage buffer alignment required. + /// + /// Host storage buffer alignment in bytes + public int QueryHostStorageBufferOffsetAlignment() => _context.Capabilities.StorageBufferOffsetAlignment; + + /// + /// Queries host support for readable images without a explicit format declaration on the shader. + /// + /// True if formatted image load is supported, false otherwise + public bool QueryHostSupportsImageLoadFormatted() => _context.Capabilities.SupportsImageLoadFormatted; + + /// + /// Queries host GPU non-constant texture offset support. + /// + /// True if the GPU and driver supports non-constant texture offsets, false otherwise + public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset; + + /// + /// Queries host GPU texture shadow LOD support. + /// + /// True if the GPU and driver supports texture shadow LOD, false otherwise + public bool QueryHostSupportsTextureShadowLod() => _context.Capabilities.SupportsTextureShadowLod; + /// /// Queries texture format information, for shaders using image load or store. ///