`loadPixels` and `PGraphics` dependency batching in WebGPU
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
研究方向
首先追蹤 issue 中描述的 loadPixels、PGraphics 以及 drawStart、flush 和 drawEnd 生命週期的 WebGPU 實作。檢查每個 surface 如何設定 CameraOutputMode,然後使用同步 readback 驗證 immediate-mode 方法,以及所述的渲染順序和可見性需求。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Java
- 星號
- 497
- 分支
- 183
- 平均合併
- 4 小時 39 分鐘
- 30 天內合併 PR
- 3
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
processing/processing4 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 64/100
processing/processing4#1554 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
processing/processing4#1515 · 1 個 reaction ·
-
bug
難度 3/5 1-2 天 新手友好度 55/100
processing/processing4#1573 ·
-
startup error 未關閉
難度 4/5 3-5 天 新手友好度 25/100
processing/processing4#1569 · 7 則留言 ·
-
Binaries under bin directory lack executable permissions for the snap and .deb packages for Linux 未關閉bug
processing/processing4#1567 · 3 則留言 · 1 個 reaction · 已指派 1 人 ·
查看 processing/processing4 的全部 Issue
相似的 Issue
-
area/plugin
難度 2/5 1-3 小時 新手友好度 75/100
kestra-io/plugin-kestra#190 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
apache/rocketmq-dashboard#5064 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
wso2/dpdp-accelerator#287 ·