From 2ca07804f7fc7619f6e6ce9085413ea79aa17d2c Mon Sep 17 00:00:00 2001 From: riperiperi Date: Tue, 14 Jun 2022 21:15:17 +0100 Subject: [PATCH] Fix some things. --- Ryujinx.Graphics.Gpu/Image/SamplerPool.cs | 2 ++ .../Image/TextureBindingsManager.cs | 16 ++++++++-------- Ryujinx.Graphics.Gpu/Image/TexturePool.cs | 2 +- Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 2 +- .../Shader/ShaderSpecializationState.cs | 6 +++++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs b/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs index 5576908e7..e95800ada 100644 --- a/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs +++ b/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs @@ -48,6 +48,8 @@ namespace Ryujinx.Graphics.Gpu.Image Items[i] = null; } } + + UpdateModifiedSequence(); } SequenceNumber = Context.SequenceNumber; diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index d02985bfa..6e200a137 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -53,6 +53,9 @@ namespace Ryujinx.Graphics.Gpu.Image private int[] _textureBindingsCount; private int[] _imageBindingsCount; + private int _texturePoolSequence; + private int _samplerPoolSequence; + private int _textureBufferIndex; private readonly float[] _scales; @@ -324,9 +327,6 @@ namespace Ryujinx.Graphics.Gpu.Image } } - private int _texturePoolSequence; - private int _samplerPoolSequence; - /// /// Ensures that the bindings are visible to the host GPU. /// Note: this actually performs the binding using the host graphics API. @@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Image } } - if (cachedSamplerBufferIndex != samplerBufferIndex) + if (samplerBufferIndex != cachedSamplerBufferIndex) { ref BufferBounds bounds = ref _channel.BufferManager.GetUniformBufferBounds(_isCompute, stageIndex, samplerBufferIndex); @@ -719,8 +719,8 @@ namespace Ryujinx.Graphics.Gpu.Image (int textureWordOffset, int samplerWordOffset, TextureHandleType handleType) = TextureHandle.UnpackOffsets(wordOffset); ulong textureBufferAddress = _isCompute - ? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex) - : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex); + ? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex) + : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex); int handle = _channel.MemoryManager.Physical.Read(textureBufferAddress + (uint)textureWordOffset * 4); @@ -733,8 +733,8 @@ namespace Ryujinx.Graphics.Gpu.Image if (handleType != TextureHandleType.CombinedSampler) { ulong samplerBufferAddress = _isCompute - ? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex) - : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex); + ? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex) + : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex); int samplerHandle = _channel.MemoryManager.Physical.Read(samplerBufferAddress + (uint)samplerWordOffset * 4); diff --git a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index 3c646b458..b8002be4d 100644 --- a/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Image } /// - /// Gets the texture descripor and texture with the given ID. + /// Gets the texture descriptor and texture with the given ID. /// /// /// This method assumes that the pool has been manually synchronized before doing binding. diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index 8472305ef..9f5f39a92 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -379,7 +379,7 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// - /// Gets the bounds of the compute uniform buffer currently bound at the given index. + /// Gets the bounds of the uniform buffer currently bound at the given index. /// /// Indicates whenever the uniform is requested by the 3D or compute engine /// Index of the shader stage, if the uniform is for the 3D engine diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs index 5ee01ef86..33130ca1f 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs @@ -202,6 +202,10 @@ namespace Ryujinx.Graphics.Gpu.Shader } } + /// + /// Prepare the shader specialization state for quick binding lookups. + /// + /// The shader stages public void Prepare(CachedShaderStage[] stages) { _allTextures = _textureSpecialization.ToArray(); @@ -508,7 +512,7 @@ namespace Ryujinx.Graphics.Gpu.Shader } } - if (stageChange || cachedSamplerBufferIndex != samplerBufferIndex) + if (stageChange || samplerBufferIndex != cachedSamplerBufferIndex) { ref BufferBounds bounds = ref channel.BufferManager.GetUniformBufferBounds(isCompute, stageIndex, samplerBufferIndex);