ash icon indicating copy to clipboard operation
ash copied to clipboard

Consider a unified function pointer table

Open Friz64 opened this issue 11 months ago • 2 comments

Throwing this out there: Why not have a table for Entry, Instance, and Device each, that holds all function pointers? erupt did this. The loading API becomes really pretty, as we can figure out which extensions to load by reading the ppEnabledExtensionNames array behind the scenes. I encourage poking around erupt to see what I mean by this:

Users would also e.g. be able pass around one single object for all their device functions needs. And regarding the stack size of this, I think that we should just store it in an Arc by default (related discussion @ #731).

I understand that this would be a major breaking change, but I don't want to leave it unmentioned.


I originally mentioned this in this comment: https://github.com/ash-rs/ash/pull/734#issuecomment-2001024938, where Ralith replied:

This (...) has also been discussed at length in the past. We concluded that using extension tables to represent extension availability is a valuable pattern to nudge downstream code towards, as it's far less error prone than representing optional extension presence with a side channel and trying to remember to check if any time you use a function from it, if you can even remember which functions come from which extension.

Our current separate wrappers approach is imperfect (some functions may be dynamically absent even if an extension is loaded successfully, ash::Device is verison-independent, etc) and I've gone back and forth myself.

Friz64 avatar Mar 16 '24 04:03 Friz64