mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-09-29 09:31:08 +00:00
Move redundant bindings update checking to the backend
This commit is contained in:
parent
70a6b7ea65
commit
596a1b1d88
|
@ -175,7 +175,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
private int[] _cachedTextureBuffer;
|
private int[] _cachedTextureBuffer;
|
||||||
private int[] _cachedSamplerBuffer;
|
private int[] _cachedSamplerBuffer;
|
||||||
|
|
||||||
private int _lastBinding;
|
|
||||||
private int _lastSequenceNumber;
|
private int _lastSequenceNumber;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -194,7 +193,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
_texturePool = texturePool;
|
_texturePool = texturePool;
|
||||||
_samplerPool = samplerPool;
|
_samplerPool = samplerPool;
|
||||||
|
|
||||||
_lastBinding = -1;
|
|
||||||
_lastSequenceNumber = -1;
|
_lastSequenceNumber = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,18 +247,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
SamplerIds.Clear();
|
SamplerIds.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invalidates the cached binding number if it equals to <paramref name="binding"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="binding">Binding number to match</param>
|
|
||||||
public void ClearBindingIfEqual(int binding)
|
|
||||||
{
|
|
||||||
if (_lastBinding == binding)
|
|
||||||
{
|
|
||||||
_lastBinding = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the cached constant buffer data.
|
/// Updates the cached constant buffer data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -290,35 +276,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the cached binding number.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parent">Cache instance</param>
|
|
||||||
/// <param name="newBinding">New binding number</param>
|
|
||||||
public void SetNewBinding(TextureBindingsArrayCache parent, int newBinding)
|
|
||||||
{
|
|
||||||
parent.ClearBindingsIfEqual(newBinding);
|
|
||||||
_lastBinding = newBinding;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if the binding number changed since the last call to this method.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parent">Cache instance</param>
|
|
||||||
/// <param name="newBinding">New binding number</param>
|
|
||||||
/// <returns>True if the binding changed, false otherwise</returns>
|
|
||||||
public bool BindingChanged(TextureBindingsArrayCache parent, int newBinding)
|
|
||||||
{
|
|
||||||
if (_lastBinding != newBinding)
|
|
||||||
{
|
|
||||||
SetNewBinding(parent, newBinding);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the cached texture or sampler pool has been modified since the last call to this method.
|
/// Checks if the cached texture or sampler pool has been modified since the last call to this method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -520,7 +477,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
entry.SynchronizeMemory(isStore);
|
entry.SynchronizeMemory(isStore);
|
||||||
|
|
||||||
if (entry.BindingChanged(this, bindingInfo.Binding))
|
if (isImage)
|
||||||
|
{
|
||||||
|
_context.Renderer.Pipeline.SetImageArray(stage, bindingInfo.Binding, entry.ImageArray);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_context.Renderer.Pipeline.SetTextureArray(stage, bindingInfo.Binding, entry.TextureArray);
|
_context.Renderer.Pipeline.SetTextureArray(stage, bindingInfo.Binding, entry.TextureArray);
|
||||||
}
|
}
|
||||||
|
@ -545,7 +506,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
entry.SynchronizeMemory(isStore);
|
entry.SynchronizeMemory(isStore);
|
||||||
|
|
||||||
if (entry.BindingChanged(this, bindingInfo.Binding))
|
if (isImage)
|
||||||
|
{
|
||||||
|
_context.Renderer.Pipeline.SetImageArray(stage, bindingInfo.Binding, entry.ImageArray);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_context.Renderer.Pipeline.SetTextureArray(stage, bindingInfo.Binding, entry.TextureArray);
|
_context.Renderer.Pipeline.SetTextureArray(stage, bindingInfo.Binding, entry.TextureArray);
|
||||||
}
|
}
|
||||||
|
@ -652,8 +617,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.SetNewBinding(this, bindingInfo.Binding);
|
|
||||||
|
|
||||||
if (isImage)
|
if (isImage)
|
||||||
{
|
{
|
||||||
entry.ImageArray.SetFormats(0, formats);
|
entry.ImageArray.SetFormats(0, formats);
|
||||||
|
@ -743,17 +706,5 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
_lruCache.Remove(toRemove);
|
_lruCache.Remove(toRemove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clears all cached bindings that are equal to <paramref name="binding"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="binding">Binding number to clear</param>
|
|
||||||
private void ClearBindingsIfEqual(int binding)
|
|
||||||
{
|
|
||||||
foreach (CacheEntry entry in _cache.Values)
|
|
||||||
{
|
|
||||||
entry.ClearBindingIfEqual(binding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,10 +499,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
Array.Resize(ref _textureArrayRefs, binding + ArrayGrowthSize);
|
Array.Resize(ref _textureArrayRefs, binding + ArrayGrowthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
_textureArrayRefs[binding] = new ArrayRef<TextureArray>(stage, array as TextureArray);
|
if (_textureArrayRefs[binding].Stage != stage || _textureArrayRefs[binding].Array != array)
|
||||||
_textureArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags());
|
{
|
||||||
|
_textureArrayRefs[binding] = new ArrayRef<TextureArray>(stage, array as TextureArray);
|
||||||
|
_textureArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags());
|
||||||
|
|
||||||
SignalDirty(DirtyFlags.Texture);
|
SignalDirty(DirtyFlags.Texture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetImageArray(CommandBufferScoped cbs, ShaderStage stage, int binding, IImageArray array)
|
public void SetImageArray(CommandBufferScoped cbs, ShaderStage stage, int binding, IImageArray array)
|
||||||
|
@ -512,10 +515,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
Array.Resize(ref _imageArrayRefs, binding + ArrayGrowthSize);
|
Array.Resize(ref _imageArrayRefs, binding + ArrayGrowthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
_imageArrayRefs[binding] = new ArrayRef<ImageArray>(stage, array as ImageArray);
|
if (_imageArrayRefs[binding].Stage != stage || _imageArrayRefs[binding].Array != array)
|
||||||
_imageArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags());
|
{
|
||||||
|
_imageArrayRefs[binding] = new ArrayRef<ImageArray>(stage, array as ImageArray);
|
||||||
|
_imageArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags());
|
||||||
|
|
||||||
SignalDirty(DirtyFlags.Image);
|
SignalDirty(DirtyFlags.Image);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetUniformBuffers(CommandBuffer commandBuffer, ReadOnlySpan<BufferAssignment> buffers)
|
public void SetUniformBuffers(CommandBuffer commandBuffer, ReadOnlySpan<BufferAssignment> buffers)
|
||||||
|
|
Loading…
Reference in a new issue