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

Update target_pixel_byte_cost and target_component_alignment #5934

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 82 additions & 5 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3655,27 +3655,35 @@ impl TextureFormat {
/// <https://gpuweb.github.io/gpuweb/#render-target-pixel-byte-cost>
pub fn target_pixel_byte_cost(&self) -> Option<u32> {
match *self {
Self::R8Unorm | Self::R8Uint | Self::R8Sint => Some(1),
Self::R8Unorm | Self::R8Snorm | Self::R8Uint | Self::R8Sint => Some(1),
Self::Rg8Unorm
| Self::Rg8Snorm
| Self::Rg8Uint
| Self::Rg8Sint
| Self::R16Uint
| Self::R16Sint
| Self::R16Unorm
| Self::R16Snorm
| Self::R16Float => Some(2),
Self::Rgba8Uint
| Self::Rgba8Sint
| Self::Rg16Uint
| Self::Rg16Sint
| Self::Rg16Unorm
| Self::Rg16Snorm
| Self::Rg16Float
| Self::R32Uint
| Self::R32Sint
| Self::R32Float => Some(4),
Self::Rgba8Unorm
| Self::Rgba8UnormSrgb
| Self::Rgba8Snorm
| Self::Bgra8Unorm
| Self::Bgra8UnormSrgb
| Self::Rgba16Uint
| Self::Rgba16Sint
| Self::Rgba16Unorm
| Self::Rgba16Snorm
| Self::Rgba16Float
| Self::Rg32Uint
| Self::Rg32Sint
Expand All @@ -3684,14 +3692,45 @@ impl TextureFormat {
| Self::Rgb10a2Unorm
| Self::Rg11b10Float => Some(8),
Self::Rgba32Uint | Self::Rgba32Sint | Self::Rgba32Float => Some(16),
Self::Rgba8Snorm | Self::Rg8Snorm | Self::R8Snorm => None,
_ => None,
Self::Stencil8
| Self::Depth16Unorm
| Self::Depth24Plus
| Self::Depth24PlusStencil8
| Self::Depth32Float
| Self::Depth32FloatStencil8
| Self::NV12
| Self::Rgb9e5Ufloat
| Self::Bc1RgbaUnorm
| Self::Bc1RgbaUnormSrgb
| Self::Bc2RgbaUnorm
| Self::Bc2RgbaUnormSrgb
| Self::Bc3RgbaUnorm
| Self::Bc3RgbaUnormSrgb
| Self::Bc4RUnorm
| Self::Bc4RSnorm
| Self::Bc5RgUnorm
| Self::Bc5RgSnorm
| Self::Bc6hRgbUfloat
| Self::Bc6hRgbFloat
| Self::Bc7RgbaUnorm
| Self::Bc7RgbaUnormSrgb
| Self::Etc2Rgb8Unorm
| Self::Etc2Rgb8UnormSrgb
| Self::Etc2Rgb8A1Unorm
| Self::Etc2Rgb8A1UnormSrgb
| Self::Etc2Rgba8Unorm
| Self::Etc2Rgba8UnormSrgb
| Self::EacR11Unorm
| Self::EacR11Snorm
| Self::EacRg11Unorm
| Self::EacRg11Snorm
| Self::Astc { .. } => None,
}
}

/// See <https://gpuweb.github.io/gpuweb/#render-target-component-alignment>
pub fn target_component_alignment(&self) -> Option<u32> {
match self {
match *self {
Self::R8Unorm
| Self::R8Snorm
| Self::R8Uint
Expand All @@ -3709,12 +3748,18 @@ impl TextureFormat {
| Self::Bgra8UnormSrgb => Some(1),
Self::R16Uint
| Self::R16Sint
| Self::R16Unorm
| Self::R16Snorm
| Self::R16Float
| Self::Rg16Uint
| Self::Rg16Sint
| Self::Rg16Unorm
| Self::Rg16Snorm
| Self::Rg16Float
| Self::Rgba16Uint
| Self::Rgba16Sint
| Self::Rgba16Unorm
| Self::Rgba16Snorm
| Self::Rgba16Float => Some(2),
Self::R32Uint
| Self::R32Sint
Expand All @@ -3728,7 +3773,39 @@ impl TextureFormat {
| Self::Rgb10a2Uint
| Self::Rgb10a2Unorm
| Self::Rg11b10Float => Some(4),
_ => None,
Self::Stencil8
| Self::Depth16Unorm
| Self::Depth24Plus
| Self::Depth24PlusStencil8
| Self::Depth32Float
| Self::Depth32FloatStencil8
| Self::NV12
| Self::Rgb9e5Ufloat
| Self::Bc1RgbaUnorm
| Self::Bc1RgbaUnormSrgb
| Self::Bc2RgbaUnorm
| Self::Bc2RgbaUnormSrgb
| Self::Bc3RgbaUnorm
| Self::Bc3RgbaUnormSrgb
| Self::Bc4RUnorm
| Self::Bc4RSnorm
| Self::Bc5RgUnorm
| Self::Bc5RgSnorm
| Self::Bc6hRgbUfloat
| Self::Bc6hRgbFloat
| Self::Bc7RgbaUnorm
| Self::Bc7RgbaUnormSrgb
| Self::Etc2Rgb8Unorm
| Self::Etc2Rgb8UnormSrgb
| Self::Etc2Rgb8A1Unorm
| Self::Etc2Rgb8A1UnormSrgb
| Self::Etc2Rgba8Unorm
| Self::Etc2Rgba8UnormSrgb
| Self::EacR11Unorm
| Self::EacR11Snorm
| Self::EacRg11Unorm
| Self::EacRg11Snorm
| Self::Astc { .. } => None,
}
}

Expand Down
Loading