What does the HLSL printf function do?

Started by
4 comments, last by BenS1 11 years, 5 months ago
I see from the MSDN HLSL reference that there is a printf function in HLSL:

http://msdn.microsoft.com/en-gb/library/windows/desktop/ff728755(v=vs.85).aspx

However the description of "Submits a custom shader message to the information queue." doesn't really explain what it does. What is the Information Queue.

It also includes the remark "This operation does nothing on devices that do not support it.".

So, what does it do (On devices that do support it)?

Obviously it can't output a message for every invocation as pixel shaders are exeuted millions of times a second (Typically).

I thought maybe it outputs something but only when stepping through the code in a debugger, so I tried that...

Compiling a shader with a printf in the code succeeds and it runs fine (But with the printf not doing anything obvious), but if I try to debug it (In Visual Studio 2012) the debugger crashes immediately (i.e. long before it ever actually gets to execute the printf line).

Any idea? Just curious.

Thanks
Ben
Advertisement
I assume this is the information queue they're talking about: http://msdn.microsof...f476538(v=VS.85).aspx

I believe I've also read some time ago that the printf function in HLSL does not work on hardware devices, only ref devices. Not sure about this though, I should really look it up.

I gets all your texture budgets!

Thanks Radikalizm, (Note the link is slightly broken, but if you manually add the "(.aspx" onto the end then it works)

Hmmmm, somehow I'd completely missed that section of the MSDN documentation despite using the DX11 documentation on there loads.

Thanks
Ben

Thanks Radikalizm, (Note the link is slightly broken, but if you manually add the "(.aspx" onto the end then it works)

Hmmmm, somehow I'd completely missed that section of the MSDN documentation despite using the DX11 documentation on there loads.

Thanks
Ben


I noticed the broken link, the forum software must've automatically shortened the link
For some strange reason it won't allow me to edit my post though

I gets all your texture budgets!

I think I sorta fixed the link, but something is still messed up with the text.

Anyway AFAIK nobody actually implements printf in HLSL except for the REF device.
Thanks Matt,

What annoys me is that the HLSL documentation doesn't clearly state that. There are other functions in HLSL that it doesn't seem to be clear on too, such as the 'noise' function that isn't actually a HLSL function at all but rather part of the Effects Framework as far as I could tell (As the ability to fill a texture from a function is part of the Effects framework).

Thanks again
Ben

This topic is closed to new replies.

Advertisement