u64 with `trailing_zeros` returns incorrect values

未关闭
#501 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust

调研方向

首先跟踪编译 shader 时使用的 u64 trailing_zeros() 入口点,并将其行为与 Rust 标准库实现进行比较。使用列出的三个 u64 值运行 shader 复现,并添加或使用覆盖结果 0、32 和 63 的测试。完成的标准是所有示例都返回预期的末尾零位数量。

由索引模型根据 Issue 内容生成。

描述

bug
Expected Behaviour

We expect the trailing_zeros() function on u64 values to match the behavior of Rust's standard library implementation, returning the count of trailing zero bits.

For example:

  • 0x0000000000000001_u64.trailing_zeros() should return 0
  • 0x0000000100000000_u64.trailing_zeros() should return 32
  • 0x8000000000000000_u64.trailing_zeros() should return 63
Example & Steps To Reproduce
  • 0x0000000000000001 Expected: 0, Result: 32
  • 0x0000000100000000 Expected: 32, Result: 0
  • 0x8000000000000000 Expected: 63, Result: 31

Run a shader that calculates trailing zeros on a u64. I am creating a pull request that contains test to validate the function and a fix for this issue.

#![no_std]
use spirv_std::spirv;

#[spirv(compute(threads(1)))]
pub fn main_cs(
    #[spirv(storage_buffer, descriptor_set = 0, binding = 0)] output: &mut [u32],
) {
    // Expected: 0, Actual: 32
    output[0] = 0x0000000000000001_u64.trailing_zeros();
    
    // Expected: 32, Actual: 0  
    output[1] = 0x0000000100000000_u64.trailing_zeros();
}
主要语言
Rust
星标
3.4k
派生
126
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Rust-GPU/rust-gpu 的其他 Issue

查看 Rust-GPU/rust-gpu 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。