Skip to content

Commit

Permalink
Merge pull request gfx-rs#1829 from kocsis1david/more-storage-formats
Browse files Browse the repository at this point in the history
Add mapping for more storage formats
  • Loading branch information
cwfitzgerald authored Aug 19, 2021
2 parents 5643304 + b0d43f9 commit 0b1657f
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion wgpu-core/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,43 +243,68 @@ pub enum StageError {
fn map_storage_format_to_naga(format: wgt::TextureFormat) -> Option<naga::StorageFormat> {
use naga::StorageFormat as Sf;
use wgt::TextureFormat as Tf;
// Using the table in https://gpuweb.github.io/gpuweb/#plain-color-formats

Some(match format {
Tf::R8Unorm => Sf::R8Unorm,
Tf::R8Snorm => Sf::R8Snorm,
Tf::R8Uint => Sf::R8Uint,
Tf::R8Sint => Sf::R8Sint,

Tf::R16Uint => Sf::R16Uint,
Tf::R16Sint => Sf::R16Sint,
Tf::R16Float => Sf::R16Float,
Tf::Rg8Unorm => Sf::Rg8Unorm,
Tf::Rg8Snorm => Sf::Rg8Snorm,
Tf::Rg8Uint => Sf::Rg8Uint,
Tf::Rg8Sint => Sf::Rg8Sint,

Tf::R32Uint => Sf::R32Uint,
Tf::R32Sint => Sf::R32Sint,
Tf::R32Float => Sf::R32Float,
Tf::Rg16Uint => Sf::Rg16Uint,
Tf::Rg16Sint => Sf::Rg16Sint,
Tf::Rg16Float => Sf::Rg16Float,
Tf::Rgba8Unorm => Sf::Rgba8Unorm,
Tf::Rgba8Snorm => Sf::Rgba8Snorm,
Tf::Rgba8Uint => Sf::Rgba8Uint,
Tf::Rgba8Sint => Sf::Rgba8Sint,

Tf::Rgb10a2Unorm => Sf::Rgb10a2Unorm,
Tf::Rg11b10Float => Sf::Rg11b10Float,

Tf::Rg32Uint => Sf::Rg32Uint,
Tf::Rg32Sint => Sf::Rg32Sint,
Tf::Rg32Float => Sf::Rg32Float,
Tf::Rgba16Uint => Sf::Rgba16Uint,
Tf::Rgba16Sint => Sf::Rgba16Sint,
Tf::Rgba16Float => Sf::Rgba16Float,

Tf::Rgba32Uint => Sf::Rgba32Uint,
Tf::Rgba32Sint => Sf::Rgba32Sint,
Tf::Rgba32Float => Sf::Rgba32Float,

_ => return None,
})
}

fn map_storage_format_from_naga(format: naga::StorageFormat) -> wgt::TextureFormat {
use naga::StorageFormat as Sf;
use wgt::TextureFormat as Tf;

match format {
Sf::R8Unorm => Tf::R8Unorm,
Sf::R8Snorm => Tf::R8Snorm,
Sf::R8Uint => Tf::R8Uint,
Sf::R8Sint => Tf::R8Sint,

Sf::R16Uint => Tf::R16Uint,
Sf::R16Sint => Tf::R16Sint,
Sf::R16Float => Tf::R16Float,
Sf::Rg8Unorm => Tf::Rg8Unorm,
Sf::Rg8Snorm => Tf::Rg8Snorm,
Sf::Rg8Uint => Tf::Rg8Uint,
Sf::Rg8Sint => Tf::Rg8Sint,

Sf::R32Uint => Tf::R32Uint,
Sf::R32Sint => Tf::R32Sint,
Sf::R32Float => Tf::R32Float,
Expand All @@ -290,14 +315,17 @@ fn map_storage_format_from_naga(format: naga::StorageFormat) -> wgt::TextureForm
Sf::Rgba8Snorm => Tf::Rgba8Snorm,
Sf::Rgba8Uint => Tf::Rgba8Uint,
Sf::Rgba8Sint => Tf::Rgba8Sint,

Sf::Rgb10a2Unorm => Tf::Rgb10a2Unorm,
Sf::Rg11b10Float => Tf::Rg11b10Float,

Sf::Rg32Uint => Tf::Rg32Uint,
Sf::Rg32Sint => Tf::Rg32Sint,
Sf::Rg32Float => Tf::Rg32Float,
Sf::Rgba16Uint => Tf::Rgba16Uint,
Sf::Rgba16Sint => Tf::Rgba16Sint,
Sf::Rgba16Float => Tf::Rgba16Float,

Sf::Rgba32Uint => Tf::Rgba32Uint,
Sf::Rgba32Sint => Tf::Rgba32Sint,
Sf::Rgba32Float => Tf::Rgba32Float,
Expand Down

0 comments on commit 0b1657f

Please sign in to comment.