Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gl: ASTC_HDR feature detection #3042

Merged
merged 3 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,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 {
cwfitzgerald marked this conversation as resolved.
Show resolved Hide resolved
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