GPU: Swap bindings array instead of copying (#4003)

* GPU: Swap bindings array instead of copying

Reduces work on UpdateShaderState. Now the cost is a few reference moves for arrays, rather than copying data.

Downside: bindings arrays are no longer readonly.

* Micro optimisation

* Add missing docs

* Address Feedback
This commit is contained in:
riperiperi 2022-12-04 17:18:40 +00:00 committed by GitHub
parent 3868a00206
commit 4965681e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 162 additions and 252 deletions

View file

@ -57,45 +57,21 @@ namespace Ryujinx.Graphics.Gpu.Image
}
/// <summary>
/// Rents the texture bindings array of the compute pipeline.
/// Sets the texture and image bindings for the compute pipeline.
/// </summary>
/// <param name="count">The number of bindings needed</param>
/// <returns>The texture bindings array</returns>
public TextureBindingInfo[] RentComputeTextureBindings(int count)
/// <param name="bindings">Bindings for the active shader</param>
public void SetComputeBindings(CachedShaderBindings bindings)
{
return _cpBindingsManager.RentTextureBindings(0, count);
_cpBindingsManager.SetBindings(bindings);
}
/// <summary>
/// Rents the texture bindings array for a given stage on the graphics pipeline.
/// Sets the texture and image bindings for the graphics pipeline.
/// </summary>
/// <param name="stage">The index of the shader stage to bind the textures</param>
/// <param name="count">The number of bindings needed</param>
/// <returns>The texture bindings array</returns>
public TextureBindingInfo[] RentGraphicsTextureBindings(int stage, int count)
/// <param name="bindings">Bindings for the active shader</param>
public void SetGraphicsBindings(CachedShaderBindings bindings)
{
return _gpBindingsManager.RentTextureBindings(stage, count);
}
/// <summary>
/// Rents the image bindings array of the compute pipeline.
/// </summary>
/// <param name="count">The number of bindings needed</param>
/// <returns>The image bindings array</returns>
public TextureBindingInfo[] RentComputeImageBindings(int count)
{
return _cpBindingsManager.RentImageBindings(0, count);
}
/// <summary>
/// Rents the image bindings array for a given stage on the graphics pipeline.
/// </summary>
/// <param name="stage">The index of the shader stage to bind the images</param>
/// <param name="count">The number of bindings needed</param>
/// <returns>The image bindings array</returns>
public TextureBindingInfo[] RentGraphicsImageBindings(int stage, int count)
{
return _gpBindingsManager.RentImageBindings(stage, count);
_gpBindingsManager.SetBindings(bindings);
}
/// <summary>
@ -107,16 +83,6 @@ namespace Ryujinx.Graphics.Gpu.Image
_cpBindingsManager.SetTextureBufferIndex(index);
}
/// <summary>
/// Sets the max binding indexes on the compute pipeline.
/// </summary>
/// <param name="maxTextureBinding">The maximum texture binding</param>
/// <param name="maxImageBinding">The maximum image binding</param>
public void SetComputeMaxBindings(int maxTextureBinding, int maxImageBinding)
{
_cpBindingsManager.SetMaxBindings(maxTextureBinding, maxImageBinding);
}
/// <summary>
/// Sets the texture constant buffer index on the graphics pipeline.
/// </summary>
@ -126,16 +92,6 @@ namespace Ryujinx.Graphics.Gpu.Image
_gpBindingsManager.SetTextureBufferIndex(index);
}
/// <summary>
/// Sets the max binding indexes on the graphics pipeline.
/// </summary>
/// <param name="maxTextureBinding">The maximum texture binding</param>
/// <param name="maxImageBinding">The maximum image binding</param>
public void SetGraphicsMaxBindings(int maxTextureBinding, int maxImageBinding)
{
_gpBindingsManager.SetMaxBindings(maxTextureBinding, maxImageBinding);
}
/// <summary>
/// Sets the current sampler pool on the compute pipeline.
/// </summary>