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

Make ResourceDevice actually generic over the backend #150

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

lukaslihotzki
Copy link
Contributor

The ResourceDevice trait is intended not to depend on the specific backend. This is shown by the type parameters that are used in the function signatures (such as Self::Texture) instead of super::Texture. However, super::TextureViewDesc contains super::Texture, so the trait indirectly depends on the concrete super::Texture, but not on all the other type parameters. Therefore, this seems like an oversight.

To fix this inconsistency, this PR makes crate::TextureViewDesc generic over the contained Texture, so the trait can use this struct with the correct Self::Texture type parameter. Advantage of this solution is that users don't need to change the code if they just pass the TextureViewDesc to create_texture_view, even if there were different implementations of ResourceDevice. Alternative solution would be to exclude the actual Texture from TextureViewDesc and just specify it as first parameter in create_texture_view. Another solution would be to add a Self::TextureViewDesc type parameter to ResourceDevice, but then, it would be difficult for users to create the TextureViewDesc in a generic way.

I would be happy if this inconsistency is fixed with any solution (the mentioned ones or another).

@lukaslihotzki
Copy link
Contributor Author

This change is related to #148, but it makes sense on its own.

blade-graphics/src/lib.rs Outdated Show resolved Hide resolved
@lukaslihotzki lukaslihotzki requested a review from kvark July 25, 2024 09:02
Copy link
Owner

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Thank you!

@kvark kvark merged commit d4b395e into kvark:main Jul 26, 2024
5 checks passed
@lukaslihotzki lukaslihotzki mentioned this pull request Aug 4, 2024
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 this pull request may close these issues.

2 participants