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 Rgba8UnormSrgb instead of Bgra8UnormSrgb as default swapchain format for WebGL target #1284

Closed
wants to merge 1 commit into from

Conversation

Gordon-F
Copy link
Contributor

WebGL doesn't supports BGRA texture formats

@@ -317,8 +317,14 @@ impl<B: GfxBackend> Adapter<B> {
return Err(GetSwapChainPreferredFormatError::NotFound);
}

// If no formats were returned, use Bgra8UnormSrgb
Ok(wgt::TextureFormat::Bgra8UnormSrgb)
let is_webgl = cfg!(gl) && cfg!(target_arch = "wasm32");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be fixing this at the wgpu-core level.
The semantics of supported_formats is:

If None is returned then the surface has no preferred format and the application may use any desired format.

Obviously, this isn't the case for WebGL. So our OpenGL backend has to return a reasonable set of formats here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gfx-rs fix - gfx-rs/gfx#3699

Obviously, this isn't the case for WebGL. So our OpenGL backend has to return a reasonable set of formats here

Why we return any formats here if supported_formats is none instead of return None to users?

Copy link
Member

Choose a reason for hiding this comment

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

Here? Because in wgpu the get_swap_chain_preferred_format has to return one format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for explain! gfx-rs fix should be enough.

@Gordon-F Gordon-F closed this Mar 25, 2021
@Gordon-F Gordon-F deleted the webgl_swapchain_format branch March 25, 2021 18:27
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