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

Component count for texture formats was (accidentally?) removed from wgpu types #3837

Closed
Elabajaba opened this issue Jun 5, 2023 · 2 comments · Fixed by #3843
Closed

Component count for texture formats was (accidentally?) removed from wgpu types #3837

Elabajaba opened this issue Jun 5, 2023 · 2 comments · Fixed by #3843
Labels
area: api Issues related to API surface good first issue Good for newcomers help required We need community help to make this happen. type: enhancement New feature or request

Comments

@Elabajaba
Copy link
Contributor

Introduced in #2020, it was dropped in #3436.

@Elabajaba Elabajaba changed the title Component count for texture formats was removed from wgpu types Component count for texture formats was (accidentally?) removed from wgpu types Jun 5, 2023
@cwfitzgerald cwfitzgerald added help required We need community help to make this happen. good first issue Good for newcomers type: enhancement New feature or request area: api Issues related to API surface labels Jun 5, 2023
@teoxoy
Copy link
Member

teoxoy commented Jun 5, 2023

wgpu code was not using it so, I wasn't sure if it was worth keeping around.
I remember looking at the history but it seems I somehow missed #2020.

If this is blocking people, I can go ahead and add it back tomorrow.

Sorry for this, I should have asked if people were relying on this.

@Elabajaba
Copy link
Contributor Author

rend3 was using it, so I added it as a function there.

pub(crate) fn components(format: TextureFormat) -> u8 {
    match format {
        TextureFormat::R8Unorm => 1,
        TextureFormat::R8Snorm => 1,
        TextureFormat::R8Uint => 1,
        TextureFormat::R8Sint => 1,
        TextureFormat::R16Uint => 1,
        TextureFormat::R16Sint => 1,
        TextureFormat::R16Unorm => 1,
        TextureFormat::R16Snorm => 1,
        TextureFormat::R16Float => 1,
        TextureFormat::R32Uint => 1,
        TextureFormat::R32Sint => 1,
        TextureFormat::R32Float => 1,
        TextureFormat::Rg8Unorm => 2,
        TextureFormat::Rg8Snorm => 2,
        TextureFormat::Rg8Uint => 2,
        TextureFormat::Rg8Sint => 2,
        TextureFormat::Rg16Uint => 2,
        TextureFormat::Rg16Sint => 2,
        TextureFormat::Rg16Unorm => 2,
        TextureFormat::Rg16Snorm => 2,
        TextureFormat::Rg16Float => 2,
        TextureFormat::Rg32Uint => 2,
        TextureFormat::Rg32Sint => 2,
        TextureFormat::Rg32Float => 2,
        TextureFormat::Rg11b10Float => 3,
        TextureFormat::Rgb9e5Ufloat => 3,
        TextureFormat::Rgba8Unorm => 4,
        TextureFormat::Rgba8UnormSrgb => 4,
        TextureFormat::Rgba8Snorm => 4,
        TextureFormat::Rgba8Uint => 4,
        TextureFormat::Rgba8Sint => 4,
        TextureFormat::Bgra8Unorm => 4,
        TextureFormat::Bgra8UnormSrgb => 4,
        TextureFormat::Rgb10a2Unorm => 4,
        TextureFormat::Rgba16Uint => 4,
        TextureFormat::Rgba16Sint => 4,
        TextureFormat::Rgba16Unorm => 4,
        TextureFormat::Rgba16Snorm => 4,
        TextureFormat::Rgba16Float => 4,
        TextureFormat::Rgba32Uint => 4,
        TextureFormat::Rgba32Sint => 4,
        TextureFormat::Rgba32Float => 4,
        TextureFormat::Stencil8 => 1,
        TextureFormat::Depth16Unorm => 1,
        TextureFormat::Depth24Plus => 1,
        TextureFormat::Depth24PlusStencil8 => 2,
        TextureFormat::Depth32Float => 1,
        TextureFormat::Depth32FloatStencil8 => 2,
        TextureFormat::Bc1RgbaUnorm => 4,
        TextureFormat::Bc1RgbaUnormSrgb => 4,
        TextureFormat::Bc2RgbaUnorm => 4,
        TextureFormat::Bc2RgbaUnormSrgb => 4,
        TextureFormat::Bc3RgbaUnorm => 4,
        TextureFormat::Bc3RgbaUnormSrgb => 4,
        TextureFormat::Bc4RUnorm => 1,
        TextureFormat::Bc4RSnorm => 1,
        TextureFormat::Bc5RgUnorm => 2,
        TextureFormat::Bc5RgSnorm => 2,
        TextureFormat::Bc6hRgbUfloat => 3,
        TextureFormat::Bc6hRgbFloat => 3,
        TextureFormat::Bc7RgbaUnorm => 4,
        TextureFormat::Bc7RgbaUnormSrgb => 4,
        TextureFormat::Etc2Rgb8Unorm => 3,
        TextureFormat::Etc2Rgb8UnormSrgb => 3,
        TextureFormat::Etc2Rgb8A1Unorm => 4,
        TextureFormat::Etc2Rgb8A1UnormSrgb => 4,
        TextureFormat::Etc2Rgba8Unorm => 4,
        TextureFormat::Etc2Rgba8UnormSrgb => 4,
        TextureFormat::EacR11Unorm => 1,
        TextureFormat::EacR11Snorm => 1,
        TextureFormat::EacRg11Unorm => 2,
        TextureFormat::EacRg11Snorm => 2,
        TextureFormat::Astc { block, channel } => todo!(),
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: api Issues related to API surface good first issue Good for newcomers help required We need community help to make this happen. type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants