Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the printf function in HLSL do?

Tags:

c++

shader

hlsl

The MSDN HLSL reference states this about printf:

"Submits a custom shader message to the information queue."

https://msdn.microsoft.com/en-us/library/windows/desktop/ff728755%28v=vs.85%29.aspx

What is the information queue and how can I see the shader message? Does it mean that when used in pixel shader it will output width*height (screen pixels) messages?

Thanks!

like image 779
SvinSimpe Avatar asked Nov 09 '22 09:11

SvinSimpe


1 Answers

It can be used for shader tracing, basically. The D3D11_TRACE_STEP structure can help you get the message passed by printf from HLSL, an example would be the following, which seems okay at first glance (although written in D) :

https://github.com/evilrat666/directx-d/blob/master/src/directx/d3d11shadertracing.d

Can be used together with this interface to access the tracing information :

https://msdn.microsoft.com/en-us/library/windows/desktop/hh446840(v=vs.85).aspx

Disclaimer : this is just what I found researching the topic, so I cannot provide actual code example. For debugging shaders I would rather advise using Renderdoc or the VS Graphics Debugger

like image 84
Laszlo Fuleki Avatar answered Nov 15 '22 05:11

Laszlo Fuleki