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

Applied the suggested changes for MonoGame#6728, and docs #8370

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

itsBuggingMe
Copy link
Contributor

@itsBuggingMe itsBuggingMe commented Jun 9, 2024

Follow-up to #8281

@SimonDarksideJ
Copy link
Contributor

Looks good to me, a second review @mrhelmut ?

@dellis1972
Copy link
Contributor

Can we get a more descriptive commit message/PR description if possible please?
I had to go through 3 different PR's to get to the reason as to why these API's are being added. I just makes it harder for people to see why something changed when going through the history.

/// <param name="vertexBuffer">The vertex buffer to set</param>
public void SetVertexBuffers(VertexBufferBinding vertexBuffer)
{
_vertexBufferBindings[0] = vertexBuffer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear the other elements? (i.e. 1, 2, 3) here and below? Also a prior call to SetVB(a1, a2, a3) should clean up after calling _vertexBuffers.Set otherwise it's not gonna be GC'ed?

/// <returns>
/// <see langword="true"/> if the input layout was changed; otherwise,
/// <see langword="false"/>.
/// </returns>
public bool Set(params VertexBufferBinding[] vertexBufferBindings)
public bool Set(VertexBufferBinding[] vertexBufferBindings, int bindingCount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add doc on the negative effects of passing a binding (and its effect on per-frame heap alloc).
IMO, I feel like the API user can do all this without introducing _vertexBufferBindings[] array at the GraphicsDevice level - you can maintain it yourself, can't you? But I realize you already made some params changes so will let others chime in here.

It's a good idea though, but could mostly live inside a doc comment as opposed to prescribing/adding complexity..

@SimonDarksideJ
Copy link
Contributor

After some internal conversation, could you add some Unit Tests to ensure these enhancements are covered in testing please @Mindfulplays

@Mindfulplays
Copy link
Contributor

After some internal conversation, could you add some Unit Tests to ensure these enhancements are covered in testing please @Mindfulplays

I agree too, The original change + this one seems to add complexity that could really be avoided/pushed outside, but tests should help contain it imo. @itsBuggingMe

@itsBuggingMe
Copy link
Contributor Author

itsBuggingMe commented Jun 29, 2024

Is it possible to temporarily do what @Mindfulplays has suggested, and switch to span params once #8194 has completed and C# 13 is done?

@mrhelmut
Copy link
Contributor

mrhelmut commented Jul 4, 2024

Giving a second thought to this...

... what is the advantage of this? You can pass an array to the params for it to generate no garbage. I feel like we're solving a non-issue here.

@itsBuggingMe
Copy link
Contributor Author

It is not strictly necessary but would make the api more streamlined and convenient. Takes away another pitfall and one less thing for the user to think about. C# itself does this too to avoid allocations such as in string.Concat().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants