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

README: Remove deprecated builder() snippets and guidelines #743

Merged
merged 2 commits into from
Apr 16, 2023

Conversation

MarijnS95
Copy link
Collaborator

Fixes #742

#602 introduced builder functions directly on the raw Vulkan struct types by using lifetime borrows which are FFI compatible (ABI is identical) wuth raw pointers, simplifying the whole system and protecting the user against losing lifetimes upon calling .build(). However, this change wasn't propagated through to the README so the code snippets were still showcasing removed ::builder() and .build() functions and documenting "the .build() footgun" which doesn't even exist anymore 🎉

README.md Outdated Show resolved Hide resolved
README.md Outdated
Pointer chains in builders differ from raw Vulkan. Instead of chaining every struct manually, you instead use `.push_next` on the struct that you are going to pass into the function. Those structs then get *prepended* into the chain.

`push_next` is also type checked, you can only add valid structs to the chain. Both the structs and the builders can be passed into `push_next`. Only builders for structs that can be passed into functions will implement a `push_next`.
Pointer chains in Ash differ from raw Vulkan. Instead of chaining every struct manually, you instead use `.push_next()` on the struct that you are going to pass into the function. Those structs then get _prepended_ into the chain.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nit: I don't think "Pointer chains in Ash differ from raw Vulkan" is the right wording, but it was already there. They are still the same pointer chains, it's just that our .push_next() helper function has a specific way to ".insert(1)" rather than .append() to be simple and efficient (no need to walk to the end of the chain, though we do need to do that for the struct that is being appended, but the common case is that it's just one item).

At the same time the spec says that specific pNext ordering is allowed (but strongly discouraged) if drivers/extensions absolutely need it for deterministic behaviour.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree this wording could be improved, both for clarity and concision. Perhaps:

Ash provides helpers for assembling pointer chains. Use .push_next() on the struct ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated and reordered. Left out the "refer to the push_next() documentation for more detailed insertion order" or something along those lines.

Note that our fn push_next() docs don't cover the case where a hypothetical D->E chain is appended to an A->B->C chain, which will end up looking like A->D->E->B->C.

@MarijnS95 MarijnS95 requested a review from Ralith April 15, 2023 08:53
Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Some nits, otherwise LGTM.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
 #602 introduced builder functions directly on the raw Vulkan struct
types by using lifetime borrows which are FFI compatible (ABI is
identical) wuth raw pointers, simplifying the whole system and
protecting the user against losing lifetimes upon calling `.build()`.
However, this change wasn't propagated through to the `README` so the
code snippets were still showcasing removed `::builder()` and `.build()`
functions and documenting "the `.build()` footgun" which doesn't even
exist anymore 🎉
@MarijnS95 MarijnS95 merged commit 23da5db into master Apr 16, 2023
@MarijnS95 MarijnS95 deleted the readme-no-builder branch April 16, 2023 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

*Info::builder() still mentioned in the README.md despite being removed.
2 participants