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

How to supply a custom sampler to a texture? #60

Open
lwiklendt opened this issue Jul 10, 2021 · 2 comments
Open

How to supply a custom sampler to a texture? #60

lwiklendt opened this issue Jul 10, 2021 · 2 comments

Comments

@lwiklendt
Copy link

At the moment the only way of creating a Texture with your own sampler (e.g. for nearest mag filtering) is to call Texture::from_raw_parts. However, to create a binding group we need to supply a shared reference to the texture layout which is currently a private field in the Renderer struct. The way I'm getting around it at the moment is to copy-paste the texture layout code from Renderer::new, but a better approach would be either for Renderer to have a function that returns the texture layout as a shared reference, or for Texture to have a new method that takes a SamplerDescriptor.

@benmkw
Copy link
Contributor

benmkw commented Jul 15, 2021

or for Texture to have a new method that takes a SamplerDescriptor

At first glance it seems that you could move the SamplerDescriptor creation which is currently in Texture::new into the default impl for TextureConfig and expose it that way.
(If you don't just need the SamplerDescriptor, but also the Sampler then this won't work because of the dependency on the device...)

Using ..Default() for TextureConfig means that this does not impact other users.

see https://github.com/Yatekii/imgui-wgpu-rs/pull/35/files for reference

@lwiklendt
Copy link
Author

At first glance it seems that you could move the SamplerDescriptor creation which is currently in Texture::new into the default impl for TextureConfig and expose it that way.
...
Using ..Default() for TextureConfig means that this does not impact other users.

This would work fine. It is backwards incompatible since it will break for users not using ..Default() which should only be done for a major semver change, but being a 0.x semver I guess it's ok?

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

No branches or pull requests

2 participants