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

@ -24,6 +24,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
public CachedShaderStage[] Shaders { get; }
/// <summary>
/// Cached shader bindings, ready for placing into the bindings manager.
/// </summary>
public CachedShaderBindings Bindings { get; }
/// <summary>
/// Creates a new instance of the shader bundle.
/// </summary>
@ -37,6 +42,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
Shaders = shaders;
SpecializationState.Prepare(shaders);
Bindings = new CachedShaderBindings(shaders.Length == 1, shaders);
}
/// <summary>