Jump to content

  • Log In with Google      Sign In   
  • Create Account

Function Calls in HLSL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 24 July 2012 - 08:52 PM

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!

Sponsor:

#2 Ripiz   Members   -  Reputation: 529

Like
1Likes
Like

Posted 24 July 2012 - 11:33 PM

According to http://msdn.microsoft.com/en-us/library/windows/desktop/bb509607%28v=vs.85%29.aspx

Modifier that redefines a function declaration. inline is currently the only modifier value.


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

#3 L. Spiro   Crossbones+   -  Reputation: 13600

Like
1Likes
Like

Posted 25 July 2012 - 04:59 AM

A better part to quote would be:

Therefore, a function is inline regardless of whether you specify inline, and all functions in HLSL are inline.


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


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#4 MJP   Moderators   -  Reputation: 11385

Like
1Likes
Like

Posted 25 July 2012 - 11:55 AM

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 good 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, 25 July 2012 - 11:55 AM.


#5 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 29 July 2012 - 08:19 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS