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

Add back get_preferred_format and sRGB preference #2785

Closed
wants to merge 1 commit into from

Conversation

victorvde
Copy link
Contributor

Connections
Partially reverts the changes in #2783 .

Description
Adds back the get_preferred_format function, to avoid breaking people's code and get back the preference for sRGB.

Testing
Ran some examples.

///
/// Returns None if the surface is incompatible with the adapter.
pub fn get_supported_formats(&self, adapter: &Adapter) -> Option<Vec<TextureFormat>> {
Context::surface_get_supported_formats(&*self.context, &self.id, &adapter.id)
}

/// Returns an optimal texture format to use for the [`Surface`] with this adapter.
pub fn get_preferred_format(&self, adapter: &Adapter) -> Option<wgt::TextureFormat> {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this separately, both methods of "preferred" format should return the same value. How about inside of get_supported_formats we just bring the srgb formats to the front - caps.format.sort_by_key(|f| !f.describe().srgb . Once we support texture view changing srgb-ness we can remove the sort.

@@ -269,11 +269,7 @@ fn start<E: Example>(
let spawner = Spawner::new();
let mut config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: *surface
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sold on needing a separate api here - especially if we remove the outer option.

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