Rust-GPU / Rust-GPU/rust-gpu

Possible inlining bug

オープン
#45 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug performance
主要言語
Rust
スター
3.4k
フォーク
126
PR マージ指標
30日以内にマージされた PR はありません

説明

It seems that this function has different results depending on whether or not #[inline(always)] is used:

/// Return `1.0` when `value` is less than or equal to `edge`
/// and `0.0` when `value` is greater than `edge`.
#[inline(always)]
pub fn step_le(value: f32, edge: f32) -> f32 {
    ((value <= edge) as u32) as f32
}

I have a shader you can see here that uses this function.

Expected Behaviour

Using ((sphere_aabb.max.z <= 1.0) as u32) as f32, which is a manual inlining of the body of the function, produces the expected results.

Using crate::math::step_le(sphere_aabb.max.z, 1.0) while having an #[inline(always)] annotation on step_le produces the expected results.

Using crate::math::step_le(sphere_aabb.max.z, 1.0) without having an #[inline(always)] annotation on step_le produces the opposite of the expected result.

Example & Steps To Reproduce

I can work on a minimal reproducible shader.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンク先の行にある crates/renderling/src/debug.rs の shader から始め、crate::math::step_le の使用箇所を追跡してください。issue で言及されている最小再現可能な shader を作成し、手動でのインライン化、#[inline(always)]、inline アノテーションなしを比較してください。異なる結果が再現され、動作が修正されるか明確に切り分けられれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
compilers, computer-graphics
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
説明が足りない
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。