Skip to content

Commit

Permalink
gl: ASTC_HDR feature detection (gfx-rs#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Oct 5, 2022
1 parent 5c33e23 commit 4992de5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ SurfaceConfiguration {
- Use the use effective api version for determining device features instead of wrongly assuming `VkPhysicalDeviceProperties.apiVersion`
is the actual version of the device. By @i509VCB in [#3011](https://github.com/gfx-rs/wgpu/pull/3011)

#### GLES
- `TEXTURE_COMPRESSION_ASTC_HDR` feature detection by @jinleili in [#3042](https://github.com/gfx-rs/wgpu/pull/3042)

### Performance

- Made `StagingBelt::write_buffer()` check more thoroughly for reusable memory; by @kpreid in [#2906](https://github.com/gfx-rs/wgpu/pull/2906)
Expand Down
24 changes: 18 additions & 6 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,22 @@ impl super::Adapter {
// This is a part of GLES-3 but not WebGL2 core
!cfg!(target_arch = "wasm32") || extensions.contains("WEBGL_compressed_texture_etc"),
);
features.set(
wgt::Features::TEXTURE_COMPRESSION_ASTC_LDR,
extensions.contains("GL_KHR_texture_compression_astc_ldr")
|| extensions.contains("WEBGL_compressed_texture_astc"),
);
// `OES_texture_compression_astc` provides 2D + 3D, LDR + HDR support
if extensions.contains("WEBGL_compressed_texture_astc")
|| extensions.contains("GL_OES_texture_compression_astc")
{
features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC_LDR);
features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR);
} else {
features.set(
wgt::Features::TEXTURE_COMPRESSION_ASTC_LDR,
extensions.contains("GL_KHR_texture_compression_astc_ldr"),
);
features.set(
wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR,
extensions.contains("GL_KHR_texture_compression_astc_hdr"),
);
}

let mut private_caps = super::PrivateCapabilities::empty();
private_caps.set(
Expand Down Expand Up @@ -668,6 +679,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
let bcn_features = feature_fn(wgt::Features::TEXTURE_COMPRESSION_BC, filterable);
let etc2_features = feature_fn(wgt::Features::TEXTURE_COMPRESSION_ETC2, filterable);
let astc_features = feature_fn(wgt::Features::TEXTURE_COMPRESSION_ASTC_LDR, filterable);
let astc_hdr_features = feature_fn(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR, filterable);

let private_caps_fn = |f, caps| {
if self.shared.private_caps.contains(f) {
Expand Down Expand Up @@ -765,7 +777,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
Tf::Astc {
block: _,
channel: AstcChannel::Hdr,
} => Tfc::empty(),
} => astc_hdr_features,
}
}

Expand Down
3 changes: 1 addition & 2 deletions wgpu-hal/src/gles/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl super::AdapterShared {
Tf::EacRg11Unorm => (glow::COMPRESSED_RG11_EAC, glow::RG, 0),
Tf::EacRg11Snorm => (glow::COMPRESSED_SIGNED_RG11_EAC, glow::RG, 0),
Tf::Astc { block, channel } => match channel {
AstcChannel::Unorm => match block {
AstcChannel::Unorm | AstcChannel::Hdr => match block {
AstcBlock::B4x4 => (glow::COMPRESSED_RGBA_ASTC_4x4_KHR, glow::RGBA, 0),
AstcBlock::B5x4 => (glow::COMPRESSED_RGBA_ASTC_5x4_KHR, glow::RGBA, 0),
AstcBlock::B5x5 => (glow::COMPRESSED_RGBA_ASTC_5x5_KHR, glow::RGBA, 0),
Expand Down Expand Up @@ -159,7 +159,6 @@ impl super::AdapterShared {
(glow::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, glow::RGBA, 0)
}
},
AstcChannel::Hdr => unimplemented!(),
},
};

Expand Down
1 change: 1 addition & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ bitflags::bitflags! {
/// Supported Platforms:
/// - Metal
/// - Vulkan
/// - OpenGL
///
/// This is a native-only feature.
const TEXTURE_COMPRESSION_ASTC_HDR = 1 << 40;
Expand Down

0 comments on commit 4992de5

Please sign in to comment.