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!
4 replies to this topic
#1 GDNet+ - Reputation: 2368
Posted 24 July 2012 - 08:52 PM
Jason Zink :: DirectX MVP
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article
Ad:
#2 Members - Reputation: 521
Posted 24 July 2012 - 11:33 PM
According to http://msdn.microsoft.com/en-us/library/windows/desktop/bb509607%28v=vs.85%29.aspx
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
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 Crossbones+ - Reputation: 5153
Posted 25 July 2012 - 04:59 AM
A better part to quote would be:
The documentation is accurate for all high-level shader models.
To my knowledge, it simply can’t be done.
L. Spiro
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
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
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
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
#4 Moderators - Reputation: 5417
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 GDNet+ - Reputation: 2368
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.
Jason Zink :: DirectX MVP
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article






