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

Return error if library functions aren't found, instead of panicking #387

Closed
Rua opened this issue Mar 7, 2021 · 3 comments · Fixed by #390
Closed

Return error if library functions aren't found, instead of panicking #387

Rua opened this issue Mar 7, 2021 · 3 comments · Fixed by #390

Comments

@Rua
Copy link
Contributor

Rua commented Mar 7, 2021

EntryCustom::new_custom doesn't return any error, it assumes the given library contains the functions it needs. If they aren't present, then the function panics. That's less than ideal if smoother error handling is needed, I would prefer it if the function returned Result if the library isn't a valid Vulkan library in some way. This would also propagate to Entry::new. Could this be implemented?

@MarijnS95
Copy link
Collaborator

That's rather trivial to add - I guess you're just 4 minutes late to get the 0.32 release. Feel free to submit a PR :)

@Rua
Copy link
Contributor Author

Rua commented Mar 7, 2021

Ah, well I can't complain about a new version when I asked for it before! :D

I was initially thinking only about StaticFn, but it looks like a lot of functions use the same pattern: try to get the function address, and if not found then use a stub that panics when called. I doubt it's a good idea to make all of these return an error, I can imagine legitimate cases where not all of the functions are present. But I feel StaticFn is different, since it exists outside the Vulkan library entirely and is trying to find a first point of entry. If that fails, you're not getting anywhere. So would it be ok to make StaticFn::load return Result, but leave every other load function as it is? I realise that might make auto code generation a bit awkward.

@MarijnS95
Copy link
Collaborator

Agreed, the entry loaders are loading "optional" functionality (ie. can't load 1.2 functions from a 1.1 library). StaticFn is not optional however, and pretty much immediately panics when loading entries after retrieving it. Should be good to return a Result from there while leaving the rest as it is.

Not sure if all the Entry functions are "core" functions and should all be available if a certain Vulkan version is declared. Perhaps it is nice to see up-front that certain functions failed to load (while not preventing the rest from loading) but that is definitely not required, feature availability can be checked in other ways.

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 a pull request may close this issue.

2 participants