Dynamic shader linkage

May 4, 2013 at 10:36 PM
Are you planning on adding dynamic shader linkage to the engine?There seem to be some really interesting uses for it, like "function pointers in HLSL" - http://www.pouet.net/topic.php?which=8469 however I'm not sure if it's good performance-wise.
Coordinator
May 5, 2013 at 3:33 PM
That's a pretty interesting link. From what I understand, that code should be compilable without modification of the engine itself - especially if it works in SM3 and SM4, there shouldn't be any engine side stuff needed. In fact, I think what he is referring to as functors and closures are more like compile time macros using the class/interface syntax.

Still, it is pretty cool indeed :) It would be interesting to try it out - have you given it a shot yet? It could make for some pretty cool demo material (wink wink)!
May 6, 2013 at 8:27 AM
I've tried it before, but I couldn't at the time find much use for it, I guess the guys on that site got really creative, however I'm not sure how it's used with the reflection.In the types enumeration there's Object, InterfaceClass, InterfacePointer.I think it would need a special ShaderClassParameter that contains an array of ID3D11ClassInstance pointers and is bound during BindShader, however so far the only description I found was: D3D_SVC_OBJECT - The shader variable is an object.Maybe only D3D_SVC_INTERFACE_CLASS and D3D_SVC_INTERFACE_POINTER refer to shader classes?
Coordinator
May 6, 2013 at 12:15 PM
I wrote my reflection code long ago, but I seem to remember the interface class and pointer objects as being the way to support the dynamic shader linkages. At least early on in D3D11's lifetime there were lots of reports of bad performance with this feature, at least if I recall correctly. Still, it would be nice to add the option to the engine... I can investigate this if some free time opens up in the next couple of days, and I'll report back about what I find.

It appears that there is some decent descriptions in the DXSDK docs, so I will probably start there... Can you think of any sufficiently interesting use cases for this? There is the obvious case of using shading/lighting, but what else could we use to produce a demo here?