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

Add feature float32-filterable #4759

Merged
merged 24 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions deno_webgpu/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5164,6 +5164,7 @@ webidl.converters["GPUFeatureName"] = webidl.createEnumConverter(
"texture-compression-astc",
"rg11b10ufloat-renderable",
"bgra8unorm-storage",
"float32-filterable",

// extended from spec

Expand Down
7 changes: 7 additions & 0 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
if features.contains(wgpu_types::Features::BGRA8UNORM_STORAGE) {
return_features.push("bgra8unorm-storage");
}
if features.contains(wgpu_types::Features::FLOAT32_FILTERABLE) {
return_features.push("float32-filterable");
}

// extended from spec

Expand Down Expand Up @@ -498,6 +501,10 @@ impl From<GpuRequiredFeatures> for wgpu_types::Features {
wgpu_types::Features::BGRA8UNORM_STORAGE,
required_features.0.contains("bgra8unorm-storage"),
);
features.set(
wgpu_types::Features::FLOAT32_FILTERABLE,
required_features.0.contains("float32-filterable"),
);

// extended from spec

Expand Down
1 change: 1 addition & 0 deletions deno_webgpu/webgpu.idl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ enum GPUFeatureName {
"shader-f16",
"rg11b10ufloat-renderable",
"bgra8unorm-storage",
"float32-filterable",

// extended from spec

Expand Down
7 changes: 6 additions & 1 deletion wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ impl super::PrivateCapabilities {
function_specialization: Self::supports_any(device, FUNCTION_SPECIALIZATION_SUPPORT),
depth_clip_mode: Self::supports_any(device, DEPTH_CLIP_MODE),
texture_cube_array: Self::supports_any(device, TEXTURE_CUBE_ARRAY_SUPPORT),
supports_float_filtering: device.supports_32bit_float_filtering(),
almarklein marked this conversation as resolved.
Show resolved Hide resolved
format_depth24_stencil8: os_is_mac && device.d24_s8_supported(),
format_depth32_stencil8_filter: os_is_mac,
format_depth32_stencil8_none: !os_is_mac,
Expand Down Expand Up @@ -828,7 +829,11 @@ impl super::PrivateCapabilities {
| F::SHADER_F16
| F::DEPTH32FLOAT_STENCIL8
| F::BGRA8UNORM_STORAGE;


features.set(
F::FLOAT32_FILTERABLE,
self.supports_float_filtering,
);
features.set(
F::INDIRECT_FIRST_INSTANCE | F::MULTI_DRAW_INDIRECT,
self.indirect_draw_dispatch,
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ struct PrivateCapabilities {
function_specialization: bool,
depth_clip_mode: bool,
texture_cube_array: bool,
supports_float_filtering: bool,
format_depth24_stencil8: bool,
format_depth32_stencil8_filter: bool,
format_depth32_stencil8_none: bool,
Expand Down
23 changes: 19 additions & 4 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,17 @@ bitflags::bitflags! {

// ? const NORM16_FILTERABLE = 1 << 17; (https://github.com/gpuweb/gpuweb/issues/3839)
// ? const NORM16_RESOLVE = 1 << 18; (https://github.com/gpuweb/gpuweb/issues/3839)
// TODO const FLOAT32_FILTERABLE = 1 << 19;

/// Allows textures with formats "r32float", "rg32float", and "rgba32float" to be filterable.
///
/// Supported Platforms: (TODO is this correct?)
/// - Vulkan
/// - DX12
/// - Metal
almarklein marked this conversation as resolved.
Show resolved Hide resolved
///
/// This is a web and native feature.
const FLOAT32_FILTERABLE = 1 << 19;

// ? const FLOAT32_BLENDABLE = 1 << 20; (https://github.com/gpuweb/gpuweb/issues/3556)
// ? const 32BIT_FORMAT_MULTISAMPLE = 1 << 21; (https://github.com/gpuweb/gpuweb/issues/3844)
// ? const 32BIT_FORMAT_RESOLVE = 1 << 22; (https://github.com/gpuweb/gpuweb/issues/3844)
Expand Down Expand Up @@ -3068,7 +3078,7 @@ impl TextureFormat {
let noaa = TextureFormatFeatureFlags::empty();
let msaa = TextureFormatFeatureFlags::MULTISAMPLE_X4;
let msaa_resolve = msaa | TextureFormatFeatureFlags::MULTISAMPLE_RESOLVE;

// Flags
let basic =
TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING;
Expand Down Expand Up @@ -3172,9 +3182,14 @@ impl TextureFormat {

Self::Astc { .. } => ( noaa, basic),
};

let sample_type = self.sample_type(None);
let mut is_filterable =
sample_type == Some(TextureSampleType::Float { filterable: true });
if device_features.contains(Features::FLOAT32_FILTERABLE) {
is_filterable |= sample_type == Some(TextureSampleType::Float { filterable: false });
}

let is_filterable =
self.sample_type(None) == Some(TextureSampleType::Float { filterable: true });
teoxoy marked this conversation as resolved.
Show resolved Hide resolved
flags.set(TextureFormatFeatureFlags::FILTERABLE, is_filterable);
flags.set(TextureFormatFeatureFlags::BLENDABLE, is_filterable);

Expand Down
4 changes: 4 additions & 0 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ const FEATURES_MAPPING: [(wgt::Features, web_sys::GpuFeatureName); 10] = [
wgt::Features::BGRA8UNORM_STORAGE,
web_sys::GpuFeatureName::Bgra8unormStorage,
),
(
wgt::Features::FLOAT32_FILTERABLE,
web_sys::GpuFeatureName::Float32Filterable,
),
almarklein marked this conversation as resolved.
Show resolved Hide resolved
];

fn map_wgt_features(supported_features: web_sys::GpuSupportedFeatures) -> wgt::Features {
Expand Down
Loading