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

Expose conversions between TextureFormat and naga::StorageFormat #6185

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

caelunshun
Copy link

Connections
none

Description
Exposes conversions between TextureFormat and naga::StorageFormat.

This is useful when generating compute shaders at runtime that need to support arbitrary storage texture formats.

Due to the orphan rule, I placed these functions in an extension trait in wgpu::util.

Testing
Doctests included.

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

This is useful when generating compute shaders at runtime that need
to support arbitrary storage texture formats.

Due to the orphan rule, I placed these functions in an extension trait
in wgpu::util.
@caelunshun caelunshun requested a review from a team as a code owner August 30, 2024 23:04
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Small nit, then g2g

Thanks!

/// use wgpu::util::TextureFormatExt;
/// assert_eq!(wgpu::TextureFormat::Bgra8Unorm.to_storage_format(), Some(wgpu::naga::StorageFormat::Bgra8Unorm));
/// ```
#[cfg_attr(docsrs, doc(cfg(any(wgpu_core, naga))))]
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't need this, we have https://github.com/gfx-rs/wgpu/blob/trunk/wgpu/src/lib.rs#L17 which should take care of it.

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