mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Add Rgb10a2Uint format (#4199)
This commit is contained in:
parent
1cf3bdf0bd
commit
422c636877
@ -104,6 +104,7 @@ By @wumpf in [#4147](https://github.com/gfx-rs/wgpu/pull/4147)
|
||||
- Support dual source blending in OpenGL ES, Metal, Vulkan & DX12. By @freqmod in [4022](https://github.com/gfx-rs/wgpu/pull/4022)
|
||||
- Add stub support for device destroy and device validity. By @bradwerth in [4163](https://github.com/gfx-rs/wgpu/pull/4163)
|
||||
- Add trace-level logging for most entry points in wgpu-core By @nical in [4183](https://github.com/gfx-rs/wgpu/pull/4183)
|
||||
- Add `Rgb10a2Uint` format. By @teoxoy in [4199](https://github.com/gfx-rs/wgpu/pull/4199)
|
||||
|
||||
#### Vulkan
|
||||
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1601,7 +1601,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/gfx-rs/naga?rev=df8107b7#df8107b78812cc2b1e3d5de35279cedc1f0da3fb"
|
||||
source = "git+https://github.com/gfx-rs/naga?rev=6668d0694cc51ee66c71c2ca3a1ab1081956299b#6668d0694cc51ee66c71c2ca3a1ab1081956299b"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"bitflags 2.4.0",
|
||||
|
||||
@ -51,7 +51,7 @@ version = "0.17"
|
||||
|
||||
[workspace.dependencies.naga]
|
||||
git = "https://github.com/gfx-rs/naga"
|
||||
rev = "df8107b7"
|
||||
rev = "6668d0694cc51ee66c71c2ca3a1ab1081956299b"
|
||||
version = "0.13.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
|
||||
@ -24,6 +24,7 @@ static TEXTURE_FORMATS_UNCOMPRESSED_GLES_COMPAT: &[wgpu::TextureFormat] = &[
|
||||
wgpu::TextureFormat::Rgba8Sint,
|
||||
wgpu::TextureFormat::Bgra8Unorm,
|
||||
wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
wgpu::TextureFormat::Rgb10a2Uint,
|
||||
wgpu::TextureFormat::Rgb10a2Unorm,
|
||||
wgpu::TextureFormat::Rg11b10Float,
|
||||
wgpu::TextureFormat::Rg32Uint,
|
||||
|
||||
@ -72,7 +72,7 @@ thiserror = "1"
|
||||
|
||||
[dependencies.naga]
|
||||
git = "https://github.com/gfx-rs/naga"
|
||||
rev = "df8107b7"
|
||||
rev = "6668d0694cc51ee66c71c2ca3a1ab1081956299b"
|
||||
version = "0.13.0"
|
||||
features = ["clone", "span", "validate"]
|
||||
|
||||
|
||||
@ -296,6 +296,7 @@ fn map_storage_format_to_naga(format: wgt::TextureFormat) -> Option<naga::Storag
|
||||
Tf::Rgba8Uint => Sf::Rgba8Uint,
|
||||
Tf::Rgba8Sint => Sf::Rgba8Sint,
|
||||
|
||||
Tf::Rgb10a2Uint => Sf::Rgb10a2Uint,
|
||||
Tf::Rgb10a2Unorm => Sf::Rgb10a2Unorm,
|
||||
Tf::Rg11b10Float => Sf::Rg11b10Float,
|
||||
|
||||
@ -350,6 +351,7 @@ fn map_storage_format_from_naga(format: naga::StorageFormat) -> wgt::TextureForm
|
||||
Sf::Rgba8Uint => Tf::Rgba8Uint,
|
||||
Sf::Rgba8Sint => Tf::Rgba8Sint,
|
||||
|
||||
Sf::Rgb10a2Uint => Tf::Rgb10a2Uint,
|
||||
Sf::Rgb10a2Unorm => Tf::Rgb10a2Unorm,
|
||||
Sf::Rg11b10Float => Tf::Rg11b10Float,
|
||||
|
||||
@ -667,7 +669,7 @@ impl NumericType {
|
||||
| Tf::Rgb10a2Unorm
|
||||
| Tf::Rgba16Float
|
||||
| Tf::Rgba32Float => (NumericDimension::Vector(Vs::Quad), Sk::Float),
|
||||
Tf::Rgba8Uint | Tf::Rgba16Uint | Tf::Rgba32Uint => {
|
||||
Tf::Rgba8Uint | Tf::Rgba16Uint | Tf::Rgba32Uint | Tf::Rgb10a2Uint => {
|
||||
(NumericDimension::Vector(Vs::Quad), Sk::Uint)
|
||||
}
|
||||
Tf::Rgba8Sint | Tf::Rgba16Sint | Tf::Rgba32Sint => {
|
||||
|
||||
@ -120,14 +120,14 @@ android_system_properties = "0.1.1"
|
||||
|
||||
[dependencies.naga]
|
||||
git = "https://github.com/gfx-rs/naga"
|
||||
rev = "df8107b7"
|
||||
rev = "6668d0694cc51ee66c71c2ca3a1ab1081956299b"
|
||||
version = "0.13.0"
|
||||
features = ["clone"]
|
||||
|
||||
# DEV dependencies
|
||||
[dev-dependencies.naga]
|
||||
git = "https://github.com/gfx-rs/naga"
|
||||
rev = "df8107b7"
|
||||
rev = "6668d0694cc51ee66c71c2ca3a1ab1081956299b"
|
||||
version = "0.13.0"
|
||||
features = ["wgsl-in"]
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option<dxgifor
|
||||
Tf::Rgba8Uint => DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
Tf::Rgba8Sint => DXGI_FORMAT_R8G8B8A8_SINT,
|
||||
Tf::Rgb9e5Ufloat => DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
|
||||
Tf::Rgb10a2Uint => DXGI_FORMAT_R10G10B10A2_UINT,
|
||||
Tf::Rgb10a2Unorm => DXGI_FORMAT_R10G10B10A2_UNORM,
|
||||
Tf::Rg11b10Float => DXGI_FORMAT_R11G11B10_FLOAT,
|
||||
Tf::Rg32Uint => DXGI_FORMAT_R32G32_UINT,
|
||||
|
||||
@ -828,6 +828,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
||||
Tf::Rgba8Snorm => filterable,
|
||||
Tf::Rgba8Uint => renderable | storage,
|
||||
Tf::Rgba8Sint => renderable | storage,
|
||||
Tf::Rgb10a2Uint => renderable,
|
||||
Tf::Rgb10a2Unorm => filterable_renderable,
|
||||
Tf::Rg11b10Float => filterable | float_renderable,
|
||||
Tf::Rg32Uint => renderable,
|
||||
|
||||
@ -35,6 +35,11 @@ impl super::AdapterShared {
|
||||
Tf::Bgra8Unorm => (glow::RGBA8, glow::BGRA, glow::UNSIGNED_BYTE), //TODO?
|
||||
Tf::Rgba8Uint => (glow::RGBA8UI, glow::RGBA_INTEGER, glow::UNSIGNED_BYTE),
|
||||
Tf::Rgba8Sint => (glow::RGBA8I, glow::RGBA_INTEGER, glow::BYTE),
|
||||
Tf::Rgb10a2Uint => (
|
||||
glow::RGB10_A2UI,
|
||||
glow::RGBA_INTEGER,
|
||||
glow::UNSIGNED_INT_2_10_10_10_REV,
|
||||
),
|
||||
Tf::Rgb10a2Unorm => (
|
||||
glow::RGB10_A2,
|
||||
glow::RGBA,
|
||||
|
||||
@ -166,6 +166,11 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
||||
flags.set(Tfc::STORAGE, pc.format_rgba8_srgb_all);
|
||||
flags
|
||||
}
|
||||
Tf::Rgb10a2Uint => {
|
||||
let mut flags = Tfc::COLOR_ATTACHMENT | msaa_count;
|
||||
flags.set(Tfc::STORAGE, pc.format_rgb10a2_uint_write);
|
||||
flags
|
||||
}
|
||||
Tf::Rgb10a2Unorm => {
|
||||
let mut flags = all_caps;
|
||||
flags.set(Tfc::STORAGE, pc.format_rgb10a2_unorm_all);
|
||||
@ -399,7 +404,7 @@ const RGB10A2UNORM_ALL: &[MTLFeatureSet] = &[
|
||||
MTLFeatureSet::macOS_GPUFamily1_v1,
|
||||
];
|
||||
|
||||
const RGB10A2UINT_COLOR_WRITE: &[MTLFeatureSet] = &[
|
||||
const RGB10A2UINT_WRITE: &[MTLFeatureSet] = &[
|
||||
MTLFeatureSet::iOS_GPUFamily3_v1,
|
||||
MTLFeatureSet::tvOS_GPUFamily2_v1,
|
||||
MTLFeatureSet::macOS_GPUFamily1_v1,
|
||||
@ -636,8 +641,7 @@ impl super::PrivateCapabilities {
|
||||
format_rgba8_srgb_no_write: !Self::supports_any(device, RGBA8_SRGB),
|
||||
format_rgb10a2_unorm_all: Self::supports_any(device, RGB10A2UNORM_ALL),
|
||||
format_rgb10a2_unorm_no_write: !Self::supports_any(device, RGB10A2UNORM_ALL),
|
||||
format_rgb10a2_uint_color: !Self::supports_any(device, RGB10A2UINT_COLOR_WRITE),
|
||||
format_rgb10a2_uint_color_write: Self::supports_any(device, RGB10A2UINT_COLOR_WRITE),
|
||||
format_rgb10a2_uint_write: Self::supports_any(device, RGB10A2UINT_WRITE),
|
||||
format_rg11b10_all: Self::supports_any(device, RG11B10FLOAT_ALL),
|
||||
format_rg11b10_no_write: !Self::supports_any(device, RG11B10FLOAT_ALL),
|
||||
format_rgb9e5_all: Self::supports_any(device, RGB9E5FLOAT_ALL),
|
||||
@ -971,6 +975,7 @@ impl super::PrivateCapabilities {
|
||||
Tf::Bgra8Unorm => BGRA8Unorm,
|
||||
Tf::Rgba8Uint => RGBA8Uint,
|
||||
Tf::Rgba8Sint => RGBA8Sint,
|
||||
Tf::Rgb10a2Uint => RGB10A2Uint,
|
||||
Tf::Rgb10a2Unorm => RGB10A2Unorm,
|
||||
Tf::Rg11b10Float => RG11B10Float,
|
||||
Tf::Rg32Uint => RG32Uint,
|
||||
|
||||
@ -208,8 +208,7 @@ struct PrivateCapabilities {
|
||||
format_rgba8_srgb_no_write: bool,
|
||||
format_rgb10a2_unorm_all: bool,
|
||||
format_rgb10a2_unorm_no_write: bool,
|
||||
format_rgb10a2_uint_color: bool,
|
||||
format_rgb10a2_uint_color_write: bool,
|
||||
format_rgb10a2_uint_write: bool,
|
||||
format_rg11b10_all: bool,
|
||||
format_rg11b10_no_write: bool,
|
||||
format_rgb9e5_all: bool,
|
||||
|
||||
@ -34,6 +34,7 @@ impl super::PrivateCapabilities {
|
||||
Tf::Bgra8Unorm => F::B8G8R8A8_UNORM,
|
||||
Tf::Rgba8Uint => F::R8G8B8A8_UINT,
|
||||
Tf::Rgba8Sint => F::R8G8B8A8_SINT,
|
||||
Tf::Rgb10a2Uint => F::A2B10G10R10_UINT_PACK32,
|
||||
Tf::Rgb10a2Unorm => F::A2B10G10R10_UNORM_PACK32,
|
||||
Tf::Rg11b10Float => F::B10G11R11_UFLOAT_PACK32,
|
||||
Tf::Rg32Uint => F::R32G32_UINT,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Lets keep these on one line
|
||||
#[rustfmt::skip]
|
||||
pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 114] = [
|
||||
pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 115] = [
|
||||
wgpu::TextureFormat::R8Unorm,
|
||||
wgpu::TextureFormat::R8Snorm,
|
||||
wgpu::TextureFormat::R8Uint,
|
||||
@ -29,6 +29,7 @@ pub const TEXTURE_FORMAT_LIST: [wgpu::TextureFormat; 114] = [
|
||||
wgpu::TextureFormat::Rgba8Sint,
|
||||
wgpu::TextureFormat::Bgra8Unorm,
|
||||
wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
wgpu::TextureFormat::Rgb10a2Uint,
|
||||
wgpu::TextureFormat::Rgb10a2Unorm,
|
||||
wgpu::TextureFormat::Rg11b10Float,
|
||||
wgpu::TextureFormat::Rg32Uint,
|
||||
|
||||
@ -2148,6 +2148,8 @@ pub enum TextureFormat {
|
||||
// Packed 32 bit formats
|
||||
/// Packed unsigned float with 9 bits mantisa for each RGB component, then a common 5 bits exponent
|
||||
Rgb9e5Ufloat,
|
||||
/// Red, green, blue, and alpha channels. 10 bit integer for RGB channels, 2 bit integer for alpha channel. Unsigned in shader.
|
||||
Rgb10a2Uint,
|
||||
/// Red, green, blue, and alpha channels. 10 bit integer for RGB channels, 2 bit integer for alpha channel. [0, 1023] ([0, 3] for alpha) converted to/from float [0, 1] in shader.
|
||||
Rgb10a2Unorm,
|
||||
/// Red, green, and blue channels. 11 bit float with no sign bit for RG channels. 10 bit float with no sign bit for blue channel. Float in shader.
|
||||
@ -2408,6 +2410,7 @@ impl<'de> Deserialize<'de> for TextureFormat {
|
||||
"rgba8sint" => TextureFormat::Rgba8Sint,
|
||||
"bgra8unorm" => TextureFormat::Bgra8Unorm,
|
||||
"bgra8unorm-srgb" => TextureFormat::Bgra8UnormSrgb,
|
||||
"rgb10a2uint" => TextureFormat::Rgb10a2Uint,
|
||||
"rgb10a2unorm" => TextureFormat::Rgb10a2Unorm,
|
||||
"rg11b10ufloat" => TextureFormat::Rg11b10Float,
|
||||
"rg32uint" => TextureFormat::Rg32Uint,
|
||||
@ -2534,6 +2537,7 @@ impl Serialize for TextureFormat {
|
||||
TextureFormat::Rgba8Sint => "rgba8sint",
|
||||
TextureFormat::Bgra8Unorm => "bgra8unorm",
|
||||
TextureFormat::Bgra8UnormSrgb => "bgra8unorm-srgb",
|
||||
TextureFormat::Rgb10a2Uint => "rgb10a2uint",
|
||||
TextureFormat::Rgb10a2Unorm => "rgb10a2unorm",
|
||||
TextureFormat::Rg11b10Float => "rg11b10ufloat",
|
||||
TextureFormat::Rg32Uint => "rg32uint",
|
||||
@ -2724,6 +2728,7 @@ impl TextureFormat {
|
||||
| Self::Bgra8Unorm
|
||||
| Self::Bgra8UnormSrgb
|
||||
| Self::Rgb9e5Ufloat
|
||||
| Self::Rgb10a2Uint
|
||||
| Self::Rgb10a2Unorm
|
||||
| Self::Rg11b10Float
|
||||
| Self::Rg32Uint
|
||||
@ -2822,6 +2827,7 @@ impl TextureFormat {
|
||||
| Self::Bgra8Unorm
|
||||
| Self::Bgra8UnormSrgb
|
||||
| Self::Rgb9e5Ufloat
|
||||
| Self::Rgb10a2Uint
|
||||
| Self::Rgb10a2Unorm
|
||||
| Self::Rg11b10Float
|
||||
| Self::Rg32Uint
|
||||
@ -2931,6 +2937,7 @@ impl TextureFormat {
|
||||
Self::Rgba8Sint => ( msaa, all_flags),
|
||||
Self::Bgra8Unorm => (msaa_resolve, attachment),
|
||||
Self::Bgra8UnormSrgb => (msaa_resolve, attachment),
|
||||
Self::Rgb10a2Uint => ( msaa, attachment),
|
||||
Self::Rgb10a2Unorm => (msaa_resolve, attachment),
|
||||
Self::Rg11b10Float => ( msaa, rg11b10f),
|
||||
Self::Rg32Uint => ( noaa, all_flags),
|
||||
@ -3036,7 +3043,8 @@ impl TextureFormat {
|
||||
| Self::Rgba16Uint
|
||||
| Self::R32Uint
|
||||
| Self::Rg32Uint
|
||||
| Self::Rgba32Uint => Some(uint),
|
||||
| Self::Rgba32Uint
|
||||
| Self::Rgb10a2Uint => Some(uint),
|
||||
|
||||
Self::R8Sint
|
||||
| Self::Rg8Sint
|
||||
@ -3124,7 +3132,9 @@ impl TextureFormat {
|
||||
| Self::Rg16Sint
|
||||
| Self::Rg16Float => Some(4),
|
||||
Self::R32Uint | Self::R32Sint | Self::R32Float => Some(4),
|
||||
Self::Rgb9e5Ufloat | Self::Rgb10a2Unorm | Self::Rg11b10Float => Some(4),
|
||||
Self::Rgb9e5Ufloat | Self::Rgb10a2Uint | Self::Rgb10a2Unorm | Self::Rg11b10Float => {
|
||||
Some(4)
|
||||
}
|
||||
|
||||
Self::Rgba16Unorm
|
||||
| Self::Rgba16Snorm
|
||||
@ -3232,7 +3242,7 @@ impl TextureFormat {
|
||||
| Self::Rgba32Float => 4,
|
||||
|
||||
Self::Rgb9e5Ufloat | Self::Rg11b10Float => 3,
|
||||
Self::Rgb10a2Unorm => 4,
|
||||
Self::Rgb10a2Uint | Self::Rgb10a2Unorm => 4,
|
||||
|
||||
Self::Stencil8 | Self::Depth16Unorm | Self::Depth24Plus | Self::Depth32Float => 1,
|
||||
|
||||
@ -3431,6 +3441,10 @@ fn texture_format_serialize() {
|
||||
serde_json::to_string(&TextureFormat::Bgra8UnormSrgb).unwrap(),
|
||||
"\"bgra8unorm-srgb\"".to_string()
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::to_string(&TextureFormat::Rgb10a2Uint).unwrap(),
|
||||
"\"rgb10a2uint\"".to_string()
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::to_string(&TextureFormat::Rgb10a2Unorm).unwrap(),
|
||||
"\"rgb10a2unorm\"".to_string()
|
||||
@ -3723,6 +3737,10 @@ fn texture_format_deserialize() {
|
||||
serde_json::from_str::<TextureFormat>("\"bgra8unorm-srgb\"").unwrap(),
|
||||
TextureFormat::Bgra8UnormSrgb
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_str::<TextureFormat>("\"rgb10a2uint\"").unwrap(),
|
||||
TextureFormat::Rgb10a2Uint
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_str::<TextureFormat>("\"rgb10a2unorm\"").unwrap(),
|
||||
TextureFormat::Rgb10a2Unorm
|
||||
|
||||
@ -197,6 +197,9 @@ fn map_texture_format(texture_format: wgt::TextureFormat) -> web_sys::GpuTexture
|
||||
TextureFormat::Bgra8UnormSrgb => tf::Bgra8unormSrgb,
|
||||
// Packed 32-bit formats
|
||||
TextureFormat::Rgb9e5Ufloat => tf::Rgb9e5ufloat,
|
||||
TextureFormat::Rgb10a2Uint => {
|
||||
unimplemented!("Current version of web_sys is missing {texture_format:?}")
|
||||
}
|
||||
TextureFormat::Rgb10a2Unorm => tf::Rgb10a2unorm,
|
||||
TextureFormat::Rg11b10Float => tf::Rg11b10ufloat,
|
||||
// 64-bit formats
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user