嘗試 WebGPU 過程中掉的一些坑

題葉發表於2023-04-10

TODO

兩個試驗專案


uniform buffer 的編碼規則. 資料會按照大小對齊, 但是編碼的時候

https://www.w3.org/TR/WGSL/#address-space-layout-constraints

可以試試自己加上 padding 來 buffer

https://stackoverflow.com/questions/74186801/is-there-any-way-to-enforce-a-16-byte-alignment-for-a-uniform-buffer-in-glsl

按照檔案說的, 不止對 uniform buffer 是這樣, 我還沒處理過.


沒有 FBO 怎麼辦.

https://www.cnblogs.com/onsummer/p/the-missing-fbo-and-rbo-in...

整體思路可以參考 blur 的做法, 至少能跑通的,

https://webgpu.github.io/webgpu-samples/samples/imageBlur#../...


binding 的 expectation 有的是跟 WGSL 裡定義的 texture 型別定義的, 在 js 程式碼中看不到. 比如 multisampilsed.


調整 canvas.style.height 之後, canvas.height 也需要更新, 而且也要考慮 pixel ratio.
canvas context 的 getCurrentTexture 獲取的 size 這時也是要改變的.


TODO

相關文章