KOEN
All notes
CODE & GPU

The tests can turn green without a GPU

vgpu’s mock adapter prompted a question: how far is it from a passing command test to the pixels of a rendered triangle?

A paper triangle on a workbench beside triangular light projected onto a miniature stage

What drew the triangle?

Suppose we are adding a small triangle to the middle of a screen. The code is pushed, CI turns green, and the review shows a list of passing tests. There is no picture of the triangle.

That would make me pause. What did the test observe? A drawing command, the resources prepared for it, or the resulting pixels? These questions all surround the same feature, but answering them takes different kinds of work.

The GPU-free mock caught my attention in vgpu’s documentation. This TypeScript library for WebGPU provides browser, Dawn-backed Node, and mock entry points. Its mock adapter README makes the intended boundary concise: mock for command and resource tests; Node for actual rendering and readback snapshots.

I thought of a cardboard stage model. You can discuss entrances and where a prop belongs around that model. To see where a light casts a shadow across an actor’s face, you need the stage. Having questions the model can answer saves you from booking a theater for every conversation.

The triangle suggests a similar use. In an environment without a GPU, command and resource tests could help catch mistakes before there is a screen to inspect. Exactly which mistakes a test catches still depends on the assertions someone wrote.

It is tempting to ask one green light to stand for both the model and the lighting rehearsal. “Passed” is short. The explanation beside it takes more room.

After there is a picture

Back to the hypothetical feature. If we add a test around resource creation and cleanup, its result should say what was checked: perhaps a call or a state that our assertion expected. A test name that preserves this scope already makes the green light easier for the next person to read.

Now suppose we run an actual rendering path and save a snapshot of the pixels read back. We have an image. We can ask whether the triangle is in the expected place and whether the background has the intended color. We also need to decide which differences should fail the comparison.

I have not installed vgpu or run this experiment for the article. This is a hypothetical review prompted by the distinction in its documentation. In particular, I am making no judgment here about how much shader behavior the mock implements.

Once an image exists, another question remains: which adapter and environment produced it? Reading pixels through Node does not, by itself, identify a particular graphics card. A claim about physical hardware needs evidence from the execution environment.

Performance is another step away. A record of the right picture does not automatically include frame timings. A claim about speed needs measurement conditions and results. Reading a usage example supplies neither.

This adds some work. Several questions attach themselves to one feature. But it gives a failure somewhere to go: a resource-flow assertion, a difference in an image, or an execution problem in a particular environment. Each points toward a narrower next investigation.

Put everything under “GPU tests passed,” and someone will have to find the person who produced the green light. Which GPU was that? Was there a GPU at all?

What I would attach to the review

The appeal of a mock is that it gives us more questions to ask without first obtaining a GPU. Checking the commands and resources we can examine now seems more useful than postponing every check until hardware is available.

The next question needs a place to remain visible. For this hypothetical triangle, I would want the actual rendering result beside the command and resource checks, with its execution environment recorded. If that run has not happened, the space should say so.

An empty space is irritating. It gives someone a reason to come back. I am less sure who comes back to an empty space that has been painted green.

The evidence can vary with the change. Editing code unrelated to the image and changing a shader need not demand identical checks or identical hardware. The review first needs to connect what changed with what was examined.

I picture the review again. A small triangle image now sits beside the green light. Underneath is the environment that produced it. At least we know where this picture was seen.

The remaining question is more specific: will that triangle still be there in the browser the user opens?

Sources