Sign in to follow this  
Jason Z

Function Calls in HLSL

Recommended Posts

Jason Z    6434
Hello,

On a recent project, I am being asked to produce shaders that will produce function calls in the assembly output from HLSL. I have tried many, many different ways to get it to happen but without any luck yet. It seems that pretty much no matter what I do, the compiler always inlines the contents of the function instead of making a function call.

Does anyone out there know how to push the compiler toward making function calls??? There must be some way to do it, but I can't seem to find any way to make it happen...

Any help is greatly appreciated!

Share this post


Link to post
Share on other sites
Ripiz    539
According to http://msdn.microsoft.com/en-us/library/windows/desktop/bb509607%28v=vs.85%29.aspx
[quote]Modifier that redefines a function declaration. inline is currently the only modifier value.[/quote]

However it seems Xbox 360 does have it, just write [call] before function (with brackets).
Source: http://msdn.microsoft.com/en-us/library/bb313973%28v=xnagamestudio.10%29.aspx

Share this post


Link to post
Share on other sites
L. Spiro    25621
A better part to quote would be:
[quote]Therefore, a function is inline regardless of whether you specify inline, and all functions in HLSL are inline.[/quote]

The documentation is accurate for all high-level shader models.
To my knowledge, it simply can’t be done.


L. Spiro

Share this post


Link to post
Share on other sites
MJP    19754
The compiler will always inline, and if optimizations are enabled it will aggressively optimize away parts of the function based on how it was called. I consider this a [i]good[/i] thing, since it means that the GPU never executes unnecessary ALU or flow control instructions. Besides...even if you did get the compiler to spit out a call instruction, there's no guarantee that the driver won't just flatten it when it JIT compiles to microcode. In fact I'm not even sure that recent architectures even support function calls at a microcode level, I've never checked. Edited by MJP

Share this post


Link to post
Share on other sites
Jason Z    6434
Thanks for the replies - this more or less clears up the situation, and I'll act accordingly... Perhaps the call functionality was from early on in the HLSL evolution and has more or less gone the way of the Dodo.

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