ash icon indicating copy to clipboard operation
ash copied to clipboard

Don't generate function structs for extensions that have no functions

Open Rua opened this issue 4 years ago • 3 comments

I noticed that Ash generates quite a few structs for extensions without any functions, for example KhrSurfaceProtectedCapabilitiesFn. These structs end up empty and are rather useless. Would it be better if the generator filtered out such cases?

Rua avatar May 25 '21 12:05 Rua

@Rua Are you referring to unit-like structs? The type you linked may have an empty struct, but it's the only way to get to ::name() to enable an extension in the first place, and const SPEC_VERSION is used in our application too.

I agree though, we could probably get rid of everything that's unused or makes no sense:

  • unsafe impl Send + Sync;
  • Manual Clone trait (already taken care of by using derive(Clone) in https://github.com/MaikKlein/ash/pull/437#discussion_r634814420);
  • fn load, there's nothing to load;
  • Make these unit-like structs.

Feel free to tackle this one, or wait for @MaikKlein / @Ralith to provide their opinion. The generator is already pretty loaded, but any wins we can get in ash compile time are worth taking IMO (see also #438, I hope shedding ~2k lines helps the parser at least).

MarijnS95 avatar May 25 '21 14:05 MarijnS95

Ah, I didn't realise that these structures had purposes beside loading functions.

Rua avatar May 25 '21 14:05 Rua

Ah, I didn't realise that these structures had purposes beside loading functions.

The impl block containing these is (strangely) placed above the struct though, when the rest (impl block containing fn load()) is below so I'm not surprised it was missed ^^

MarijnS95 avatar May 25 '21 14:05 MarijnS95