Skip to content

Commit

Permalink
[spv-out] Replace map_dim with a From implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy authored and kvark committed Aug 30, 2021
1 parent b35e40e commit 995a775
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/back/spv/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,15 @@ impl From<crate::StorageFormat> for spirv::ImageFormat {
}
}
}

impl From<crate::ImageDimension> for spirv::Dim {
fn from(dim: crate::ImageDimension) -> Self {
use crate::ImageDimension as Id;
match dim {
Id::D1 => Self::Dim1D,
Id::D2 => Self::Dim2D,
Id::D3 => Self::Dim3D,
Id::Cube => Self::DimCube,
}
}
}
11 changes: 1 addition & 10 deletions src/back/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,6 @@ impl Function {
}
}

fn map_dim(dim: crate::ImageDimension) -> spirv::Dim {
match dim {
crate::ImageDimension::D1 => spirv::Dim::Dim1D,
crate::ImageDimension::D2 => spirv::Dim::Dim2D,
crate::ImageDimension::D3 => spirv::Dim::Dim3D,
crate::ImageDimension::Cube => spirv::Dim::DimCube,
}
}

/// Characteristics of a SPIR-V `OpTypeImage` type.
///
/// SPIR-V requires non-composite types to be unique, including images. Since we
Expand Down Expand Up @@ -198,7 +189,7 @@ impl LocalImageType {
flags
};

let dim = map_dim(dim);
let dim = spirv::Dim::from(dim);

match class {
crate::ImageClass::Sampled { kind, multi } => LocalImageType {
Expand Down

0 comments on commit 995a775

Please sign in to comment.