Recently I've been working on an HLSL interpreter, which can execute shader code entirely on the CPU https://t.co/jsbCLv4NzK
I used it to make a cute little interactive debugger demo. You can try it yourself at https://t.co/kJMUPmBHAn
More info on Bsky: https://t.co/xh94ZIgVgM
@DyLhun You are still re-rendering the scene for every light that casts realtime shadows (moving occluder) with this technique, which is a big part of the overhead.. I really wouldn't recommend using many such lights
"Nobody reviews compiler output, why review AI code?"
Wrong. We do review compiler output. Godbolt exists. Disassemblers exist. Anyone doing serious performance work reads what the compiler produced. The premise is false.
But the analogy itself is flawed. It compares two things that aren't comparable.
A compiler takes a formal language as input. Languages with grammars and semantics defined precisely enough that "what does this code mean" has only one answer.
An LLM takes natural language as input. Natural languages are ambiguous. "Write me a function that handles user input safely" has a thousand valid interpretations and a thousand more invalid ones. The LLM picks one. You don't know which. Unless you look at the code.
Compilers are built from specifications and designed to meet them. The output is the result of a defined translation. When the output violates the spec, it's a bug.
LLMs are built from whatever was in their training data. There is no spec. There can't be one, natural languages have no defined semantics that map to code.
Compilers are semantically deterministic. The same input produces output with the same behaviour, every time. LLMs are not. Partly by design and partly due to hardware variance, batch size, inference order, and floating point operations (and no setting temperature to zero does not address those). All of which can push the same prompt to produce different code.
Compilers complain loudly when the input is nonsensical. LLMs fail silently, producing plausible-looking, but wrong code.
We trust compiler output because the trust was earned across decades of use, with millions of engineers using the same tools. Early compilers were reviewed heavily. Hand-written assembly was the default because trust hadn't been earned yet.
We're at the hand-written assembly stage with AI. We may never get to the trust-the-output stage for the reasons explained above.
If you’re a software developer, you should own what goes to production. The compiler analogy is a way of skipping that responsibility.
@phi16_ If you think about it, CRT is basically just an asset that does Blit() for you. So I don't really see why not. Might need to mess with ZTest an ZWrite though.
@phi16_ With VRCGraphics.Blit I think it should work if you use geometry shader. Blit just renders a full screen quad. The repo I sent you does random write with CRT by spawning geometry in front of the 'virtual camera' used by the CRT...
@phi16_@raii_VRC In case you don't know this trick already: You can have (pseudo) random writes by using a geometry or vertex shader to spawn pixel primitives or tiny quads at the corresponding location in front of the camera. That way you can do 1 write per pixel per dispatch.
@phi16_@raii_VRC Very cool. The tediousness of preparing shader gimmicks is part of the reason why I don't really make stuff for VRC anymore. Might try this out.
I made an experimental "GPU mode" in my toy shader debugger (https://t.co/kJMUPmBHAn). Runs the shader on the GPU with WebGPU by transpiling to WGSL with the Slang compiler. You can click on a pixel to drop into the interpreter and start debugging. Also added image previews.
@bkaradzic FWIW, it's already based on tracing. Once you start debugging, the shader has already finished running. That's why I can support stuff like "step back" too.
Recently I've been working on an HLSL interpreter, which can execute shader code entirely on the CPU https://t.co/jsbCLv4NzK
I used it to make a cute little interactive debugger demo. You can try it yourself at https://t.co/kJMUPmBHAn
More info on Bsky: https://t.co/xh94ZIgVgM
@bkaradzic You mean executing in the GPU first, then switching to CPU when clicking a pixel? As I wrote on bsky:
That's a neat idea. Would require some way to run HLSL on the web, though. WebGL uses GLSL and WebGPU uses WGSL, so I don't see a way to do this without some kind of transpiler
@AlMansey_Games@monogame I'm a GLSL hater 😆
I didn't make a way to capture GPU execution or anything like that, if you want to debug something you need to copy paste it. It's a proof of concept, really.