logoalt Hacker News

An Experimental Approach to Printf in HLSL

31 pointsby ibobevlast Wednesday at 9:53 AM2 commentsview on HN

Comments

exDM69today at 9:23 AM

Using printf in shaders is awesome, it makes a huge difference when writing and debugging shaders. Vulkan and GLSL (and Slang) have a usable printf out of the box, but HLSL and D3D do not.

Afaik the way it works in Vulkan is that all the string formatting is actually done on the CPU. The GPU writes only writes the data to buffers with structs based on the format string.

All the shader prints are captured by tools such as Renderdoc, so you can easily find the vertex or pixel that printed something and then replay the shader execution in a debugger.

I only wish that we would've had this 20 years ago, it would have saved me so much time, effort and frustration.

Charon77today at 10:05 AM

Not putting strings on GPU looks very much like how some system approaches semihosting

darubedarobtoday at 9:10 AM

[dead]