Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use value equality to determine uniform buffer equivalence #6414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion osu.Framework/Graphics/Rendering/IUniformBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace osu.Framework.Graphics.Rendering
/// <summary>
/// A buffer which stores data for a uniform block.
/// </summary>
public interface IUniformBuffer : IDisposable
public interface IUniformBuffer : IDisposable, IEquatable<IUniformBuffer>
{
bool IEquatable<IUniformBuffer>.Equals(IUniformBuffer? other) => false;
}

/// <inheritdoc cref="IUniformBuffer"/>
Expand All @@ -21,5 +22,13 @@ public interface IUniformBuffer<TData> : IUniformBuffer
/// The data contained by this <see cref="IUniformBuffer{TData}"/>.
/// </summary>
TData Data { get; set; }

bool IEquatable<IUniformBuffer>.Equals(IUniformBuffer? otherBuffer)
{
if (otherBuffer is not IUniformBuffer<TData> tdataBuffer)
return false;

return tdataBuffer.Data.Equals(Data);
}
}
}
2 changes: 1 addition & 1 deletion osu.Framework/Graphics/Rendering/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ internal void SetUniform<T>(IUniformWithValue<T> uniform)

public void BindUniformBuffer(string blockName, IUniformBuffer buffer)
{
if (boundUniformBuffers.TryGetValue(blockName, out IUniformBuffer? current) && current == buffer)
if (boundUniformBuffers.TryGetValue(blockName, out IUniformBuffer? current) && current.Equals(buffer))
return;

FlushCurrentBatch(FlushBatchSource.BindBuffer);
Expand Down
Loading