From badb3c88ea29acb159d333e2f60b1cc305bbd512 Mon Sep 17 00:00:00 2001 From: multisn8 Date: Tue, 5 Mar 2024 15:01:38 +0100 Subject: [PATCH] feat: const feature defaults (#5343) * feat: make downlevel feature defaults const * docs: add 5343 to changelog --- CHANGELOG.md | 1 + wgpu-types/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebcd5bd08..0e1c4be5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,6 +115,7 @@ By @cwfitzgerald in [#5325](https://github.com/gfx-rs/wgpu/pull/5325). - `wgpu::Id` now implements `PartialOrd`/`Ord` allowing it to be put in `BTreeMap`s. By @cwfitzgerald and @9291Sam in [#5176](https://github.com/gfx-rs/wgpu/pull/5176) - `wgpu::CommandEncoder::write_timestamp` requires now the new `wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS` feature which is available on all native backends but not on WebGPU (due to a spec change `write_timestamp` is no longer supported on WebGPU). By @wumpf in [#5188](https://github.com/gfx-rs/wgpu/pull/5188) - Breaking change: [`wgpu_core::pipeline::ProgrammableStageDescriptor`](https://docs.rs/wgpu-core/latest/wgpu_core/pipeline/struct.ProgrammableStageDescriptor.html#structfield.entry_point) is now optional. By @ErichDonGubler in [#5305](https://github.com/gfx-rs/wgpu/pull/5305). +- `Features::downlevel{_webgl2,}_features` was made const by @MultisampledNight in [#5343](https://github.com/gfx-rs/wgpu/pull/5343) #### GLES diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index d73d0b70d..a68945452 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1217,7 +1217,7 @@ impl Limits { /// max_non_sampler_bindings: 1_000_000, /// }); /// ``` - pub fn downlevel_defaults() -> Self { + pub const fn downlevel_defaults() -> Self { Self { max_texture_dimension_1d: 2048, max_texture_dimension_2d: 2048, @@ -1295,7 +1295,7 @@ impl Limits { /// max_non_sampler_bindings: 1_000_000, /// }); /// ``` - pub fn downlevel_webgl2_defaults() -> Self { + pub const fn downlevel_webgl2_defaults() -> Self { Self { max_uniform_buffers_per_shader_stage: 11, max_storage_buffers_per_shader_stage: 0, @@ -1323,7 +1323,7 @@ impl Limits { /// This is useful because the swapchain might need to be larger than any other image in the application. /// /// If your application only needs 512x512, you might be running on a 4k display and need extremely high resolution limits. - pub fn using_resolution(self, other: Self) -> Self { + pub const fn using_resolution(self, other: Self) -> Self { Self { max_texture_dimension_1d: other.max_texture_dimension_1d, max_texture_dimension_2d: other.max_texture_dimension_2d, @@ -1335,7 +1335,7 @@ impl Limits { /// Modify the current limits to use the buffer alignment limits of the adapter. /// /// This is useful for when you'd like to dynamically use the "best" supported buffer alignments. - pub fn using_alignment(self, other: Self) -> Self { + pub const fn using_alignment(self, other: Self) -> Self { Self { min_uniform_buffer_offset_alignment: other.min_uniform_buffer_offset_alignment, min_storage_buffer_offset_alignment: other.min_storage_buffer_offset_alignment,