Rust-GPU / Rust-GPU/rust-gpu

incorrect bool/Option(bool) support

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

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

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

説明

Expected Behaviour

no crash when using bool / Option(bool) (note: in particular, the bug was observed when using iterators over bool)

Example & Steps To Reproduce

This code fail to compile:

#![cfg_attr(target_arch = "spirv", no_std)]

use spirv_std::glam::UVec3;
use spirv_std::spirv;

#[spirv(compute(threads(64)))]
pub fn main_cs(
    #[spirv(global_invocation_id)] id: UVec3,
    #[spirv(storage_buffer, descriptor_set = 0, binding = 0)] buffer: &mut [u32],
) {
    let mut t =test();
    buffer[1] += t.next().unwrap() as u32;
}
struct T{}
#[inline(never)]
pub fn test()->impl Iterator<Item = bool>{
    T{}
}

impl  Iterator for T {
    type Item=bool;
    fn next(&mut self) -> Option<Self::Item> {
        return Some(true);
    }
}

The relevant part of the error

 error: error:0:0 - Expected Result Type to be a pointer or int or float vector or scalar type: Bitcast
           %40 = OpBitcast %bool %33

NB: the error also happen the other way arround (cast from bool to char).
It also seem that these cast force to use the Capability::Int8 when no Int8 is used in similar cases

System Info

  • Rust: rustc 1.90.0-nightly
  • OS: artix linux with kernel 6.17.8-artix1-1
  • GPU: NVIDIA Corporation GA102 [GeForce RTX 3080 Ti]
  • SPIR-V: SPIRV-Tools v2025.4 v2025.4-0-g7f2d9ee92

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

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

はじめの一歩

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

調査の方向性

bool のイテレータと報告された OpBitcast 検証エラーを使用する Rust reproducer から始めます。bool と Option がどのように SPIR-V に lower されるかを追跡します。これには、逆方向の bool-to-char のケースと、予期しない Int8 capability も含まれます。無効な Bitcast や不要な Int8 capability がないことを、示されている reproducer と SPIR-V Tools で検証します。

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

評価

技術スタック
rust
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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