`loadPixels` and `PGraphics` dependency batching in WebGPU
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Domaine
- computer-graphics
Piste de recherche
Commencez par suivre l’implémentation WebGPU de loadPixels, PGraphics et le cycle de vie de drawStart, flush et drawEnd décrits dans l’issue. Vérifiez comment CameraOutputMode est défini pour chaque surface, puis validez l’approche en mode immédiat avec une lecture synchrone et l’ordre de rendu ainsi que les exigences de visibilité indiqués.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
The processing API allows performing arbitrary GPU->CPU readback on demand via the loadPixels method. This is generally an extension of the immediate mode philosophy of processing but poses significant friction with modern graphics architectures. In contrast with opengl, which goes to significant lengths to preserve the illusion that GPU data is easily accessible, WebGPU is designed to foreground that GPU operations are asynchronous relative to the CPU timeline. While the API does support blocking on these operations, the expectation of most framework including bevy is that you won't.
Concretely why this matters is because modern graphics libraries really want to batch rendering together for efficiency reasons. For example, in Bevy, all cameras (which could be considered an analog to a PGraphics instance) want to render at the same time every frame. loadPixels introduces an architectural complication in that the current draw state may need to be flushed and made visible to any other graphics context at any arbitrary time.
In other words, beyond any performance concerns, this highlights a potential dependency problem between PGraphics instances:
- In the event where multiple
PGraphicsinstances aren't dependent on each other, batching works fine and we can delay flushing all their draw state til the end of frame. - When a
PGraphicsis used in anotherPGraphics, e.g. an off-screen texture used by something in rendering to the screen, we could simply just track a relative order to ensure the BevyCamerafor one runs before the other. - If the user calls
loadPixels, we need to flush the draw state right now and make the texture visible to potentially any other CPU code.
Approach for WebGPU with Bevy
We should start just by mirroring the immediate mode API. What this means is that we'll mirror the drawStart, flush, drawEnd lifecycle. Set CameraOutputMode::Skipat the beginning of each frame for each surface to render only to the intermediate texture and CameraOutputMode::Write only when calling drawEnd.
We can handle loadPixels in this way just by doing a synchronous readback after a flush. It's fine, and will superficially look like opengl's behavior from the user perspective.
Because this immediate mode approach likely has some undesirable overhead (although tbd, it may be pretty minimal), we can do our own dependency/dirty tracking if necessary down the line. What this would look like is keeping an in-flight dependency graph of PGraphics and how they're being used, and only trigger flushes when they acutally need to be made visible to other graphics contexts. This isn't hard to do but will make the implementation more confusing.
- Langage dominant
- Java
- Étoiles
- 497
- Forks
- 183
- Merge moyen
- 4 h 39 min
- PR mergées (30 j)
- 3
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de processing/processing4
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
processing/processing4#1554 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
processing/processing4#1515 · 1 réaction ·
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
processing/processing4#1573 ·
-
startup error Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
processing/processing4#1569 · 7 commentaires ·
-
Binaries under bin directory lack executable permissions for the snap and .deb packages for Linux Ouvertebug
processing/processing4#1567 · 3 commentaires · 1 réaction · 1 personne assignée ·
Toutes les issues de processing/processing4
Issues similaires
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Ouvertearea/plugin
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Add canonical URLs and a sitemap Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
apache/rocketmq-dashboard#5064 ·
-
Consent portal: creating a duplicate Purpose shows a generic error instead of "already exists" Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
wso2/dpdp-accelerator#287 ·