You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here I use C for "carrier" and E for "element". A carrier is the struct that gets consumed by Vulkan API functions, and is the head of the pointer chain. An element is the opposite, just a part of the pointer chain.
The elements a carrier may be extended by is defined by the Vulkan registry. We leverage this information to provide a compile-time safe API, by generating a push_next builder function for every carrier which only takes elements that implement ExtendsC (a trait only implemented for valid elements).
In erupt, I switched this around: The trait is now implemented for the carriers, and the elements are in the generic parameter position. This means that the push_next function can now become a trait function with a default implementation, which works everywhere.
Here I use
C
for "carrier" andE
for "element". A carrier is the struct that gets consumed by Vulkan API functions, and is the head of the pointer chain. An element is the opposite, just a part of the pointer chain.The elements a carrier may be extended by is defined by the Vulkan registry. We leverage this information to provide a compile-time safe API, by generating a
push_next
builder function for every carrier which only takes elements that implementExtendsC
(a trait only implemented for valid elements).In erupt, I switched this around: The trait is now implemented for the carriers, and the elements are in the generic parameter position. This means that the
push_next
function can now become a trait function with a default implementation, which works everywhere.See the
ExtendableFrom
trait from erupt.Side note: ash generates a separate trait for every carrier struct, where it could use generics (
Extends<C>
) instead.The text was updated successfully, but these errors were encountered: