[Migrated] Move Output vars to return position (was: Storage class inference interface)
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 3.4k
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/416
Old labels: mcp: accepted
Originally creatd by khyperia on 2021-02-11T13:41:36Z
Storage class inference is now a thing as of #300/#414. This details the design for the interface system taking advantage of inference, pointing out all the rules of how storage classes are specified in entry points.
There are a handful of ways of specifying a storage class:
- direct attribute:
fn main(#[spirv(input)] x: &f32). This uses the current list of storage classes. - via builtin:
fn main(#[spirv(position)] x: &Vector3)(inferred as input). This uses the current list of builtins (a table is needed to map builtin to storage class, I think some are input, some are output, and there may be others) - via image:
fn main(x: &Image2d)(inferred as uniform_constant). I thiiink images are always uniform_constant and not uniform, but I'm not sure. - unspecified future inference rules that we haven't discovered yet (the spec is light on what goes in what storage class), suggestions are welcome
If exactly one of these rules matches, then use the storage class it specifies.
If more than one of these rules matches, and they all compute the same storage class, emit a warning (e.g. #[spirv(position, input)], warn on input and say it's redundant). If more than one of these rules matches, and they compute different storage classes, emit an error.
If none of these rules matches, then we have an open design question. The options here are a trade-off between catching user errors that may be difficult to diagnose/guiding users with explicit syntax suggestions, and not annoying people with overly explicit syntax that takes a while to type out and read.
fn main(x: &f32)-> is this an error, or does it default toinput? (or something else)fn main(x: &Struct)-> is this an error, does it default toinput, or does it default touniform? (or something else)fn main(x: &mut f32)-> is this an error, or does it default tooutput? (or something else)
For 2, I don't know if it's valid to have a struct (or any other non-scalar) be an input/output variable, more research is needed.
An alternative is to keep the current system of Input<T> and friends. We would remove the .load() and .store() methods entirely, and implement Deref/DerefMut (when applicable) for them. I much prefer the readability, recognizability, and usability of using plain references, but I understand others don't feel the same way~
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、#300 と #414 で参照されているストレージクラス推論の作業と、issue で説明されている現在の Input および関連インターフェースを確認します。未確定の推論およびデフォルト設定のルールを解決し、次に、競合する、または冗長なストレージクラスアノテーションに対するインターフェースの変更と検証を定義します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100