Patrick Walton
pcwalton.bsky.social
Patrick Walton
@pcwalton.bsky.social
2.5K followers 41 following 120 posts
Programming languages and graphics person. Rust compiler, Firefox, and Bevy contributor. Currently working on an unannounced project!
Posts Media Videos Starter Packs
Project that'd be fun but that I have no time for: Compile and run native code on-device on iOS by running macOS (or Windows?) interpreted in a VM on-device, and have the VM talk to the iOS device via a tiny device ($5 microcontroller?) you plug into the USB port that loops the USB back.
I noticed that x86 APX has a prefix that allows for 3-operand insns (e.g. add rax,rbx,rcx instead of mov rax,rbx; add rax,rcx). I wonder what the advantage of that over the 2 instruction pair is? Couldn't the CPU fuse the latter instruction pair into effectively a 3-operand insn?
OK, the way Clippy told me to replace cos(pi / 4) with the FRAC_1_SQRT_2 constant is wild. Clippy is becoming self-aware.
Bevy 0.17! I only have minor improvements in this one, because my engine-level work has been focused on VFX instead of Bevy proper, but the improvements everyone has contributed to this have been awesome to see!
bevy.org Bevy @bevy.org · Sep 30
Bevy 0.17 is out now! It features Raytracing, Improved Observers / Events, UI Widgets, Rust Hotpatching, Light Textures, DLSS, Tilemap Chunks, Web Assets, Reflect Auto-Registration, UI Gradients, Raymarched Atmosphere, Virtual Geometry BVH Culling, and more!

bevy.org/news/bevy-0-17
Bevy 0.17
Bevy is a refreshingly simple data-driven game engine built in Rust. It is free and open-source forever!
bevy.org
OK, I love this. tl;dr using knowledge of your allocator, speed up linked list traversal by adding a branch that guesses where the next linked list element is and pre-populates the "next" variable to eliminate stalls if the allocations are well-behaved.
Wrote up how Unity's "Freeform Stretching" and "Rotate With Stretch" features work so that the next person who wants to run them on GPU doesn't end up pulling their hair out: gist.github.com/pcwalton/ff7...
Unity Freeform Stretching
Unity Freeform Stretching. GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
Just reverse engineered Unity's "Freeform Stretching" and "Rotate With Stretch" particle system features. Never had a problem devolve into "write down as many random observations as I can until I get down to 2 equations with 2 unknowns and can solve for the result" before, but sometimes it works!
RTX in Bevy!
New blog post: "Realtime Raytracing in Bevy 0.17 (Solari)"
jms55.github.io/posts/2025-0...
The particles were launched randomly. So when the normalization code looked at the vector length, it would effectively make a random vector, take its length, then make a *new* random vector, and divide the new vector by the length of the *old* one!
Solution: add more temporaries. Compilers! 3/3
I look at the shader source. Wait, why are there so many calls to random here?
Turns out, the Hanabi node-graph-to-WGSL compiler wasn't generating temporaries for side-effecting expressions like random. So every time you used a random node it would generate a new random number. 2/
Well, that was certainly a bug.
Problem: Hanabi particles are too fast. I store direction and magnitude separately, but direction wasn't being normalized. Hmm. Bug in my normalization code? No, it looks right... 1/
This is temporary, because upstream also wants to implement batching, just in a different incompatible way. Once that happens I'll deprecate this fork.
I made my temporary fork of Bevy Hanabi more concrete. It's now called Hanabi-Batched: github.com/pcwalton/bev...

This is a temporary fork that provides much better performance in real-life scenarios, making the difference between a shippable game and not in most cases.
GitHub - pcwalton/bevy_hanabi: A fork of Bevy Hanabi, the GPU-driven VFX system for Bevy, with improved performance and functionality
A fork of Bevy Hanabi, the GPU-driven VFX system for Bevy, with improved performance and functionality - pcwalton/bevy_hanabi
github.com
Also true for Rust.
everyone is so impressed with LLMs ability to generate JavaScript that they try to start applying it to things like Kotlin or Swift and then rapidly find out the hard way that there exists orders of magnitude more training data for JS
With the GPU-driven rendering work I did earlier this year and the Hanabi VFX work I'm doing now, Bevy is consistently hitting 120 FPS for me. Looks really nice on a high refresh rate display.

Building a GPU-driven renderer is a ton of work, but the results *really* pay off.
Just pushed a branch of Hanabi, the GPU VFX system for #bevyengine, with a significant overhaul of the way scheduling works: github.com/pcwalton/bev...

In my tests, I can now have 500+ different particle *systems*, each with many particles, on screen at once and still hit 120 FPS.
GitHub - pcwalton/bevy_hanabi at batching-2
🎆 Hanabi — a GPU particle system plugin for the Bevy game engine. - GitHub - pcwalton/bevy_hanabi at batching-2
github.com
Asking ChatGPT "what is two-phase occlusion culling?" and it confidently gives the wrong answer, saying that it involves artists placing occluders manually, when a huge draw of 2-phase is that it *doesn't* require artists to do that.
It's hilarious to me that ChatGPT can now write decent Rust, but it's completely useless at doing anything but the most basic operations in ImageMagick. ImageMagick is objectively more difficult than the borrow checker
Always resist the temptation to store extra data alongside indirect draw parameters. It may seem convenient now, but you will want to support multidraw indirect eventually and then you will have to redo all your bind group management and you will hate yourself.
Iterator with a 1-element queue, like ungetc().
peekable() is nice for iterators, but usually what I really want is pushbackable(). i.e. let me use the equivalent of ungetc(), to push back a single element.
Current status: Debugging a race condition in which the easiest way to repro is "put my laptop to sleep, stick it in a bag for at least 10 minutes, turn it on without A/C power, and then start the program".
Reposted by Patrick Walton
wrote about some of the work i've done in the past year and what i'm hoping to accomplish next year in bevy! ✨

www.charlotte.fyi/posts/bevys-...
I'm just amazed I remembered enough context after 13 years to be able to usefully google for the answer!