Sign in to follow this  
BenS1

What does the HLSL printf function do?

Recommended Posts

BenS1    352
I see from the MSDN HLSL reference that there is a printf function in HLSL:

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

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

Share this post


Link to post
Share on other sites
Radikalizm    4807
I assume this is the information queue they're talking about:[url="http://msdn.microsoft.com/en-us/library/ff476538(v=VS.85).aspx"] [/url][url="http://msdn.microsoft.com/en-us/library/ff476538(v=VS.85).aspx"]http://msdn.microsof...f476538(v=VS.85[/url]).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. Edited by MJP

Share this post


Link to post
Share on other sites
BenS1    352
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

Share this post


Link to post
Share on other sites
Radikalizm    4807
[quote name='BenS1' timestamp='1353337190' post='5002348']
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
[/quote]

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

Share this post


Link to post
Share on other sites
BenS1    352
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this