Last night I implemented DirectX10 effect pools in the Dak code. Wrapping it all up was pretty easy - you end up with a tree of parent shaders and child shaders. To achieve this you merely load the child effect with the D3D10_EFFECT_COMPILE_CHILD_EFFECT flag set; but it doesn't always work and sometimes it fails silently.
This problem manifested itself for me as D3DX10CreateEffectFromFile returning E_FAIL and a null error buffer pointer - not a lot of use. Hours of experimenting were wasted to discover the fault was in the shader code and for some reason the compiler couldn't tell me what it was! More experimenting revealed that it was to do with my DepthStencilState in the effect pool header. I hadn't marked it as shared and, for each shader it was included in, it was generating multiple copies of the state. Why the compiler didn't see this I have no idea; but prefixing it with 'shared' solved the problem. It's not the only declaration that fails in this way; a quick experiment showed that a number of other declarations also fail silently.
If you're having silent failures from the D3DX10CreateEffectXXXX functions and you're using effect pools. Check your header declarations are shared properly! |