I'm not sure why it takes so long to compile. You'd really need to get someone from the DirectX team to help you out. Historically the loop simulator used for unrolling loops has always been rather slow with HLSL compiler, but it doesn't make sense that it would be so slow for your particular case. It must be doing some sort of bounds-checking that is slowing it done.
I tried changing your shader to use a StructuredBuffer instead of a constant buffer for storing the array of bone matrices, and it compiles almost instantly. So you can do that as a workaround. A StructuredBuffer shouldn't be any slower (in fact it probably takes the same path on most recent hardware), and will give you the same functionality.
As for unrolling, it's almost always something you want to do for loops with a fixed number of iterations. It generally results in better performance, because it allows the compiler to better optimize the resulting code and always prevents the hardware from having to execute looping/branching instructions every iteration. So you'll probably want to be explicit and put an [unroll] attribute on your loop.
MJPMember Since 29 Mar 2007
Offline Last Active Yesterday, 06:33 PM
Graphics/engine programmer for Ready At Dawn Studios
- Group Moderators
- Active Posts 7,973
- Profile Views 23,489
- Submitted Links 0
- Member Title XNA/DirectX Moderator & MVP
- Age Age Unknown
- Birthday Birthday Unknown
Expert Community Member