Make ResourceDevice actually generic over the backend #150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofsuper::Texture
. However,super::TextureViewDesc
containssuper::Texture
, so the trait indirectly depends on the concretesuper::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 correctSelf::Texture
type parameter. Advantage of this solution is that users don't need to change the code if they just pass the TextureViewDesc tocreate_texture_view
, even if there were different implementations ofResourceDevice
. Alternative solution would be to exclude the actualTexture
fromTextureViewDesc
and just specify it as first parameter increate_texture_view
. Another solution would be to add aSelf::TextureViewDesc
type parameter toResourceDevice
, but then, it would be difficult for users to create theTextureViewDesc
in a generic way.I would be happy if this inconsistency is fixed with any solution (the mentioned ones or another).