Rust-GPU / Rust-GPU/rust-gpu

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

Ouverte
#70 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Rust
Étoiles
3.4k
Forks
126
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la page de documentation writing-shader-crates.html et le code de test spriv-std référencé dans l'issue. Examinez examples/shaders/reduce/src/lib.rs et les exemples wgpu liés afin d'identifier les conseils manquants concernant les bindings, les barrières, les opérations sur les images, les fonctionnalités Rust prises en charge, les capacités et le débogage. Le travail sera considéré comme terminé lorsqu'il comprendra un guide de portage cohérent avec des exemples avant-après couvrant les concepts de shaders demandés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rust
Domaine
computer-graphics, documentation
Type d'issue
Documentation
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.