Skip to content

[naga]: Add no_std polyfill for round_ties_even for f32 and f64 #7585

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --all-features
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu --all-features

# Building for no_std platforms where every feature is enabled except "std".
# Building for no_std platforms.
- name: Check `no_std`
if: matrix.kind == 'no_std'
shell: bash
Expand All @@ -301,9 +301,11 @@ jobs:

# check with no features
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features

# Check with all features except "std".
# Check with all compatible features
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features --features strict_asserts,fragile-send-sync-non-atomic-wasm,serde,counters
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features --features dot-out,compact
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't correct for naga - I think you should pull them out into their own lines instead of attaching them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just updated the comments to be more broad. I do like the two groups (no features, all compatible features), but I'm happy to split it up (either crate by crate or just each line on it's own)


# Building for native platforms with standard tests.
- name: Check native
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Bottom level categories:

### New Features

#### Naga

- Added `no_std` support with default features disabled. By @Bushrat011899 in [#7585](https://github.com/gfx-rs/wgpu/pull/7585).

#### General

- Add support for rendering to slices of 3D texture views and single layered 2D-Array texture views (this requires `VK_KHR_maintenance1` which should be widely available on newer drivers). By @teoxoy in [#7596](https://github.com/gfx-rs/wgpu/pull/7596)
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions naga/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ hashbrown.workspace = true
half = { workspace = true, features = ["num-traits"] }
rustc-hash.workspace = true
indexmap.workspace = true
# Earliest version of libm with rint and rintf
libm = { version = "0.2.6", default-features = false }
log.workspace = true
num-traits.workspace = true
once_cell = { workspace = true, features = ["alloc", "race"] }
Expand Down
7 changes: 7 additions & 0 deletions naga/src/back/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pub type NeedBakeExpressions = crate::FastHashSet<crate::Handle<crate::Expressio
///
/// [`Expression`]: crate::Expression
/// [`Handle`]: crate::Handle
#[cfg_attr(
not(any(glsl_out, hlsl_out, msl_out, wgsl_out)),
allow(
dead_code,
reason = "shared helpers can be dead if none of the enabled backends need it"
)
)]
struct Baked(crate::Handle<crate::Expression>);

impl core::fmt::Display for Baked {
Expand Down
4 changes: 2 additions & 2 deletions naga/src/proc/constant_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,8 @@ impl<'a> ConstantEvaluator<'a> {
}
crate::MathFunction::Round => {
component_wise_float(self, span, [arg], |e| match e {
Float::Abstract([e]) => Ok(Float::Abstract([e.round_ties_even()])),
Float::F32([e]) => Ok(Float::F32([e.round_ties_even()])),
Float::Abstract([e]) => Ok(Float::Abstract([libm::rint(e)])),
Float::F32([e]) => Ok(Float::F32([libm::rintf(e)])),
Float::F16([e]) => {
// TODO: `round_ties_even` is not available on `half::f16` yet.
//
Expand Down
Loading