Skip to content

Commit 62e932b

Browse files
authored
Add missing DEPTH_BIAS_CLAMP and FULL_DRAW_INDEX_UINT32 downlevel flags (#3316)
* add missing `DEPTH_BIAS_CLAMP` and `FULL_DRAW_INDEX_UINT32` downlevel flags * add changelog entry * use require_downlevel_flags
1 parent c91cae4 commit 62e932b

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non
116116
- Lower the `max_buffer_size` limit value for compatibility with Apple2 and WebGPU compliance. By @jinleili in [#3255](https://github.com/gfx-rs/wgpu/pull/3255)
117117
- Dereferencing a buffer view is now marked inline. By @Wumpf in [#3307](https://github.com/gfx-rs/wgpu/pull/3307)
118118
- The `strict_assert` family of macros was moved to `wgpu-types`. By @i509VCB in [#3051](https://github.com/gfx-rs/wgpu/pull/3051)
119+
- Add missing `DEPTH_BIAS_CLAMP` and `FULL_DRAW_INDEX_UINT32` downlevel flags. By @teoxoy in [#3316](https://github.com/gfx-rs/wgpu/pull/3316)
119120

120121
#### WebGPU
121122

wgpu-core/src/device/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,10 @@ impl<A: HalApi> Device<A> {
27382738
if let Some(e) = error {
27392739
return Err(pipeline::CreateRenderPipelineError::DepthStencilState(e));
27402740
}
2741+
2742+
if ds.bias.clamp != 0.0 {
2743+
self.require_downlevel_flags(wgt::DownlevelFlags::DEPTH_BIAS_CLAMP)?;
2744+
}
27412745
}
27422746

27432747
if desc.layout.is_none() {

wgpu-hal/src/dx11/adapter.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ impl super::Adapter {
110110
downlevel |= wgt::DownlevelFlags::INDEPENDENT_BLEND;
111111
// formally FL9_1 supports aniso 2, but we don't support that level of distinction
112112
downlevel |= wgt::DownlevelFlags::ANISOTROPIC_FILTERING;
113+
// this is actually the first FL that supports u32 at all
114+
downlevel |= wgt::DownlevelFlags::FULL_DRAW_INDEX_UINT32;
113115
}
114116

115117
if feature_level >= FL9_3 {
@@ -120,6 +122,7 @@ impl super::Adapter {
120122
downlevel |= wgt::DownlevelFlags::INDEPENDENT_BLEND;
121123
downlevel |= wgt::DownlevelFlags::FRAGMENT_STORAGE;
122124
downlevel |= wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE;
125+
downlevel |= wgt::DownlevelFlags::DEPTH_BIAS_CLAMP;
123126
features |= wgt::Features::DEPTH_CLIP_CONTROL;
124127
features |= wgt::Features::TIMESTAMP_QUERY;
125128
features |= wgt::Features::PIPELINE_STATISTICS_QUERY;

wgpu-hal/src/gles/adapter.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ impl super::Adapter {
255255
} else {
256256
0
257257
};
258+
let max_element_index = unsafe { gl.get_parameter_i32(glow::MAX_ELEMENT_INDEX) } as u32;
258259

259260
// WORKAROUND: In order to work around an issue with GL on RPI4 and similar, we ignore a
260261
// zero vertex ssbo count if there are vertex sstos. (more info:
@@ -316,6 +317,10 @@ impl super::Adapter {
316317
wgt::DownlevelFlags::UNRESTRICTED_INDEX_BUFFER,
317318
!cfg!(target_arch = "wasm32"),
318319
);
320+
downlevel_flags.set(
321+
wgt::DownlevelFlags::FULL_DRAW_INDEX_UINT32,
322+
max_element_index == u32::MAX,
323+
);
319324

320325
let mut features = wgt::Features::empty()
321326
| wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES

wgpu-hal/src/vulkan/adapter.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,18 @@ impl PhysicalDeviceFeatures {
316316
| F::WRITE_TIMESTAMP_INSIDE_PASSES
317317
| F::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
318318
| F::CLEAR_TEXTURE;
319-
let mut dl_flags = Df::all();
319+
320+
let mut dl_flags = Df::COMPUTE_SHADERS
321+
| Df::BASE_VERTEX
322+
| Df::READ_ONLY_DEPTH_STENCIL
323+
| Df::NON_POWER_OF_TWO_MIPMAPPED_TEXTURES
324+
| Df::COMPARISON_SAMPLERS
325+
| Df::VERTEX_STORAGE
326+
| Df::FRAGMENT_STORAGE
327+
| Df::DEPTH_TEXTURE_AND_BUFFER_COPIES
328+
| Df::WEBGPU_TEXTURE_FORMAT_SUPPORT
329+
| Df::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED
330+
| Df::UNRESTRICTED_INDEX_BUFFER;
320331

321332
dl_flags.set(Df::CUBE_ARRAY_TEXTURES, self.core.image_cube_array != 0);
322333
dl_flags.set(Df::ANISOTROPIC_FILTERING, self.core.sampler_anisotropy != 0);
@@ -326,6 +337,11 @@ impl PhysicalDeviceFeatures {
326337
);
327338
dl_flags.set(Df::MULTISAMPLED_SHADING, self.core.sample_rate_shading != 0);
328339
dl_flags.set(Df::INDEPENDENT_BLEND, self.core.independent_blend != 0);
340+
dl_flags.set(
341+
Df::FULL_DRAW_INDEX_UINT32,
342+
self.core.full_draw_index_uint32 != 0,
343+
);
344+
dl_flags.set(Df::DEPTH_BIAS_CLAMP, self.core.depth_bias_clamp != 0);
329345

330346
features.set(
331347
F::INDIRECT_FIRST_INSTANCE,

wgpu-types/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,16 @@ bitflags::bitflags! {
11291129
///
11301130
/// WebGL doesn't support this.
11311131
const UNRESTRICTED_INDEX_BUFFER = 1 << 16;
1132+
1133+
/// Supports full 32-bit range indices (2^32-1 as opposed to 2^24-1 without this flag)
1134+
///
1135+
/// Corresponds to Vulkan's `VkPhysicalDeviceFeatures.fullDrawIndexUint32`
1136+
const FULL_DRAW_INDEX_UINT32 = 1 << 17;
1137+
1138+
/// Supports depth bias clamping
1139+
///
1140+
/// Corresponds to Vulkan's `VkPhysicalDeviceFeatures.depthBiasClamp`
1141+
const DEPTH_BIAS_CLAMP = 1 << 18;
11321142
}
11331143
}
11341144

0 commit comments

Comments
 (0)