Skip to content

Commit

Permalink
Byte texture format
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoqsh committed Feb 28, 2024
1 parent d357593 commit ba38f54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ members = [
]

[workspace.package]
version = "0.3.0-rc"
version = "0.3.0-rc.1"
edition = "2021"
license = "MIT"
authors = ["nanoqsh"]
Expand All @@ -25,9 +25,9 @@ repository = "https://github.com/nanoqsh/dunge"
rust-version = "1.76"

[workspace.dependencies]
dunge = { version = "=0.3.0-rc", path = "dunge" }
dunge_macros = { version = "=0.3.0-rc", path = "dunge_macros" }
dunge_shader = { version = "=0.3.0-rc", path = "dunge_shader" }
dunge = { version = "=0.3.0-rc.1", path = "dunge" }
dunge_macros = { version = "=0.3.0-rc.1", path = "dunge_macros" }
dunge_shader = { version = "=0.3.0-rc.1", path = "dunge_shader" }
bytemuck = "1.13"
glam = "0.25"
env_logger = "0.11"
Expand Down
4 changes: 4 additions & 0 deletions dunge/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ pub enum Format {
RgbAlpha,
BgrAlpha,
Depth,
Byte,
}

impl Format {
pub(crate) const fn bytes(self) -> u32 {
match self {
Self::SrgbAlpha | Self::SbgrAlpha | Self::RgbAlpha | Self::BgrAlpha | Self::Depth => 4,
Self::Byte => 1,
}
}

Expand All @@ -25,6 +27,7 @@ impl Format {
Self::RgbAlpha => TextureFormat::Rgba8Unorm,
Self::BgrAlpha => TextureFormat::Bgra8Unorm,
Self::Depth => TextureFormat::Depth32Float,
Self::Byte => TextureFormat::R8Uint,
}
}

Expand All @@ -35,6 +38,7 @@ impl Format {
TextureFormat::Rgba8Unorm => Self::RgbAlpha,
TextureFormat::Bgra8Unorm => Self::BgrAlpha,
TextureFormat::Depth32Float => Self::Depth,
TextureFormat::R8Uint => Self::Byte,
_ => panic!("unsupported format"),
}
}
Expand Down

0 comments on commit ba38f54

Please sign in to comment.