Function Calls in HLSL

Started by
3 comments, last by Jason Z 11 years, 8 months ago
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!
Advertisement
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.[/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
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.[/quote]

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


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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.
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.

This topic is closed to new replies.

Advertisement