Rust-GPU / Rust-GPU/rust-gpu

[Migrated] documentation and examples for porting WGSL/GLSL shaders

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

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

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

説明

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1096
Old labels: t: enhancement
Originally creatd by johnny-smitherson on 2023-11-07T18:49:37Z 👍: 3


I've been porting some WGSL code like like these into rust and the documentation for actually writing shaders is very sparse: https://embarkstudios.github.io/rust-gpu/book/writing-shader-crates.html

I only managed to get the above program working by reading through the spriv-std test code.

Here are some pain points I have:

  • confusion about the various binding types and how WGSL declaration syntax converts to rust-spirv attribute equivalent for basic types
  • confusion about various barrier types: which of these ones should i use for wgsl storageBarrier() ? what about atomic ops?
  • basic operations, like reading and writing to image textures, image sampling, are not documented nor in examples
  • what Rust types are allowed by default? I found out at runtime u8 are not a thing - not a problem, but should be outlined for the non-initiated
  • is this assembly here the only way to do this thing? What is even this thing that's being done?
  • what Rust language features are known not to work? I discovered the hard way while and loop and/or for don't work - I just can't remember which ones
  • how do i configure capabilities?? - this should be a documentation page
  • how do i debug? - this should be a documentation page

Having a small body of real-life examples, ported from the wgpu wgsl examples for instance, would greatly help outside people actually get into your ecosystem, without really going through the spirv specification and diffing it to the wgsl specification to display a couple of spinning triangles.

I get it that some concepts will not be translateable 1-to-1 but a few more starting examples showing off basic shader features (all shader types, most of binding types, various barrier types, various combinations of globals, uniforms -- these would all help porting WGSL and GLSL into rust

I propose a Before + After rust conversion from each example, so everyone can see how the porting gets done, what gets translated into what. And you can also do benchmarks and correctness testIng on the rust shader vs. the original shader.

Maybe the original WGPU example runner can be used with minimal modification to accept spirv-type shaders alongside the original wgsl, so you won't have to rebuild all the runner bind group code from scratch.

Otherwise, I feel like without being a GPU pipeline engineer, I can't be the target audience for this project, but I really want to be, WGSL is awful, Rust is great.

edit found

Are there any other resources that exist for this?

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

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

はじめの一歩

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

調査の方向性

writing-shader-crates.html のドキュメントページと、issue で参照されている spriv-std のテストコードから始めます。examples/shaders/reduce/src/lib.rs とリンクされている wgpu の例を確認し、バインディング、バリア、画像操作、サポートされている Rust の機能、機能要件、デバッグについて不足している説明を特定します。完了条件は、要求されたシェーダーの概念を網羅する、変更前と変更後の例を含む一貫した移植ガイドが作成されていることです。

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

評価

技術スタック
rust
領域
computer-graphics, documentation
issue の種類
ドキュメント
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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