Skip to content

Commit

Permalink
Support OES_texture_float_linear in webgl (#3261)
Browse files Browse the repository at this point in the history
closes #3215
  • Loading branch information
expenses authored Dec 5, 2022
1 parent 9cc0ff1 commit 6147c91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non

- Surfaces support now `TextureFormat::Rgba8Unorm` and (non-web only) `TextureFormat::Bgra8Unorm`. By @Wumpf in [#3070](https://github.com/gfx-rs/wgpu/pull/3070)
- Support alpha to coverage. By @Wumpf in [#3156](https://github.com/gfx-rs/wgpu/pull/3156)
- Support filtering f32 textures. By @expenses in [#3261](https://github.com/gfx-rs/wgpu/pull/3261)

#### WebGPU

Expand Down
13 changes: 10 additions & 3 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ impl super::Adapter {
super::PrivateCapabilities::COLOR_BUFFER_FLOAT,
color_buffer_float,
);
private_caps.set(
super::PrivateCapabilities::TEXTURE_FLOAT_LINEAR,
extensions.contains("OES_texture_float_linear"),
);

let max_texture_size = unsafe { gl.get_parameter_i32(glow::MAX_TEXTURE_SIZE) } as u32;
let max_texture_3d_size = unsafe { gl.get_parameter_i32(glow::MAX_3D_TEXTURE_SIZE) } as u32;
Expand Down Expand Up @@ -730,6 +734,9 @@ impl crate::Adapter<super::Api> for super::Adapter {
| Tfc::MULTISAMPLE_RESOLVE,
);

let texture_float_linear =
private_caps_fn(super::PrivateCapabilities::TEXTURE_FLOAT_LINEAR, filterable);

match format {
Tf::R8Unorm => filterable_renderable,
Tf::R8Snorm => filterable,
Expand All @@ -746,7 +753,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
Tf::Rg8Sint => renderable,
Tf::R32Uint => renderable | storage,
Tf::R32Sint => renderable | storage,
Tf::R32Float => unfilterable | storage | float_renderable,
Tf::R32Float => unfilterable | storage | float_renderable | texture_float_linear,
Tf::Rg16Uint => renderable,
Tf::Rg16Sint => renderable,
Tf::Rg16Unorm => empty,
Expand All @@ -761,15 +768,15 @@ impl crate::Adapter<super::Api> for super::Adapter {
Tf::Rg11b10Float => filterable | float_renderable,
Tf::Rg32Uint => renderable,
Tf::Rg32Sint => renderable,
Tf::Rg32Float => unfilterable | float_renderable,
Tf::Rg32Float => unfilterable | float_renderable | texture_float_linear,
Tf::Rgba16Uint => renderable | storage,
Tf::Rgba16Sint => renderable | storage,
Tf::Rgba16Unorm => empty,
Tf::Rgba16Snorm => empty,
Tf::Rgba16Float => filterable | storage | half_float_renderable,
Tf::Rgba32Uint => renderable | storage,
Tf::Rgba32Sint => renderable | storage,
Tf::Rgba32Float => unfilterable | storage | float_renderable,
Tf::Rgba32Float => unfilterable | storage | float_renderable | texture_float_linear,
//Tf::Stencil8 |
Tf::Depth16Unorm
| Tf::Depth32Float
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ bitflags::bitflags! {
const COLOR_BUFFER_HALF_FLOAT = 1 << 8;
/// Supports `f11/f10` and `f32` color buffers
const COLOR_BUFFER_FLOAT = 1 << 9;
/// Supports linear flitering `f32` textures.
const TEXTURE_FLOAT_LINEAR = 1 << 10;
}
}

Expand Down

0 comments on commit 6147c91

Please sign in to comment.