Skip to content

Instantly share code, notes, and snippets.

View jimblandy's full-sized avatar

Jim Blandy jimblandy

View GitHub Profile
@jimblandy
jimblandy / vulkan_pipeline_barriers.md
Last active October 18, 2025 00:22
Good explanation of Vulkan pipeline barriers from ChatGPT

I'm generally familiar with Vulkan, but I don't quite understand the rules around vkCmdPipelineBarrier, specifically for buffer memory barriers. My understanding is that depending on the source and destination access masks, a pipeline barrier may not always be necessary. Why is this?

ChatGPT:

Short answer: because a barrier only solves hazards, and many access-mask pairs don’t describe a hazard.

In Vulkan, a pipeline barrier does two distinct things:

  1. Execution dependency
@jimblandy
jimblandy / girard-desire.md
Created September 13, 2025 17:26
Girard's mimetic desire theory

Me:

I've heard someone summarize Rene Girard's theories about mimetic desire, including this quote:

"Man is the creature who does not know what to desire, and he turns to others in order to make up his mind. We desire what others desire because we imitate their desires."

And this summary (not a quote):

Girard's idea proposes that all desire is merely an imitation of another's desire, and the desire only occurs because others have deemed said object as worthwhile. This means that a desirable object is only desired because of societal ideas, and is not based on personal preference like most believe.

@jimblandy
jimblandy / remote-texture.org
Created August 14, 2025 14:51
Notes on Firefox's remote texture architecture

Remote textures

  • Relationships (‘<==>’ means ‘is one-to-one with’)
    • GPU process <==> RemoteTextureMap
    • RemoteTextureOwnerClient <==> WebGPUParent (and thus WebGPUChild)
    • TextureOwner <==> CanvasContext, when configured
  • Tracking
    • TextureOwner
      • has various queues of
        • TextureDataHolder, a struct of
          • TextureHost (?)

What historical analogues or precedents are there for Free / Open Source software? Has there ever been such an open-ended, broad, collaborative process like this? How were those communities supported?

The Free and Open Source Software (FOSS) movement has some remarkable historical analogues, even though its exact scale, breadth, and technological basis are relatively new. However, certain precedents echo the same core themes: open access, collaborative development, communal ownership, and mutual aid across institutions and borders. Below are some key examples:


1. Scientific Collaboration (17th Century Onwards)

Analogy: The rise of modern science in the 17th century brought about a new ethos of publishing and peer review. Scholars like Galileo, Newton, and later Darwin published their methods and findings for others to test, refine, or build upon.

WebGPU’s Rust implementation, wgpu, uses Naga to translate WGSL into backend shading languages.

This is not quite the right way to phrase this. WebGPU is a W3C standard, and it has at least three implementations that I'm aware of:

  • Google's Dawn

  • wgpu, an open-source project to which Mozilla heavily contributes, but which we do not control (in classic open-source style)

I get around 7.25 hours of sleep a night on average, and for a long time I have wanted to get eight hours instead. But despite having this as a goal, when it's time for me to go to bed, I often find myself casting about for some sort of activity to do instead: "let me just check YouTube" "maybe a bit of reading before bed would be nice" "I wonder if there's anything really important on the NYT web site", and so on. None of these activities are urgent, and none of them couldn't perfectly well be put off until morning. This often leads to my staying up much later than I'd planned.

There's something in me that feels like going to bed is irritating, a waste of time, a missed opportunity to spend a few moments enjoying myself. Or perhaps it feels like a capitulation, giving up on this day and putting off fun things until tomorrow. I know these feelings are counterproductive, but it seems like they usually win out.

My question is not about strategies for going to bed on time. Rather, my question is abou

I'm writing a book about Rust. One phenomenon I've noticed while working on the book is that, after I've been working on a particular passage for a while and I've read it over many times, it becomes hard for me to really "see" the text of the passage clearly, and follow its flow the way a new reader would. The process of revision becomes difficult because it's harder to actually pay attention to the text that I've read so many times before. Subjectively, it's almost as if something in my mind has become saturated, and can't absorb any more.

From a cognitive science or psychological point of view, what's going on here? Is there anything I can do to help me work on my text more effectively?

What you're describing is a well-documented cognitive phenomenon known as textual habituation or perceptual fluency. Essentially, the brain becomes so familiar with the text that it stops processing it deeply. Instead of actively reading each word, your mind starts skimming or filling in gaps based on memory. This mak

@jimblandy
jimblandy / ChatGPT-Naga-IR.md
Last active February 13, 2025 00:10
ChatGPT's advice on Naga IR design

I work on a Rust crate called Naga that translates GPU shaders from one language (say, the WebGPU shading language, also called WGSL) to another (say, Vulkan's SPIR-V). Naga is divided into front ends that parse shader modules into Naga's own IR, a middle end that does validation and analysis in language-independent code, and back ends that generate shader modules from IR.

At first, we had a principle that the IR should only represent concepts needed to preserve the original shader code's meaning, and concerns that were specific to some front end should be isolated in that front end. For example, WGSL promises that expressions containing only compile-time constants are fully evaluated at compile time, so that users can write general expressions for array sizes, alignment attributes on structure members, and other values that need to be known at compile time. At first, Naga's IR did not permit general expressions to occur in such places, requiring the front end to determine their final value itself befo

@jimblandy
jimblandy / 200-asynchronous.md
Last active November 15, 2024 10:04
Asynchronous Programming

Asynchronous Programming

In the last chapter, we explained how to use threads in Rust to spread compute-intensive work across multiple processor cores, putting the entire machine to work. But threads are more than just a way to get things done faster: they also make a programming language more expressive. The clearest way to write a program that carries out multiple activities independently, but concurrently, is by creating a thread to handle each one.

diff --git a/gfx/wgpu_bindings/Cargo.toml b/gfx/wgpu_bindings/Cargo.toml
--- a/gfx/wgpu_bindings/Cargo.toml
+++ b/gfx/wgpu_bindings/Cargo.toml
@@ -17,7 +17,7 @@ default = []
[dependencies.wgc]
package = "wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
-rev = "3fda684eb9e69c78b16312a3e927e3ea82e853d1"
+rev = "d3e09dd63ad54e2982ef744a6d74df468e232ff0"
# TODO: remove the replay feature on the next update containing https://github.com/gfx-rs/wgpu/pull/5182