# FindNextValidTechnique fails

My effect file compiles successfully, but FindNextValidTechnique fails.

technique Diffuse
{
pass Pass0
{
}
}


I try to get the first valid technique after compilation:

pEffect->FindNextValidTechnique(NULL, pValidTechnique);


This returns some minus value which doesn't go along with D3D_OK.

I've used other flags than D3DCREATE_HARDWARE_VERTEXPROCESSING to test, but no result with them either.

UPDATE

I've read in documentation that, "Applying Compiler Flags or Assembler Flags to the incorrect API will fail shader validation.", but I'm not sure this applies to the compile time validation or afterwards. I have no problem in compile.

I compile with these flags:

D3DXSHADER_DEBUG |

• Have you tried using the debug runtime? It may have more information for you. – P. Avery Apr 1 '15 at 16:29
• @P.Avery I'm in debug, but nothing. And this function doesn't return anything special really according to the documentation. – MahanGM Apr 1 '15 at 19:40
• Have you tried compiling the effect without those flags? – P. Avery Apr 1 '15 at 23:56
• @P.Avery I usually try all the possible ways to fix the bug. Changing flags from nothing to everything was one of it. I read in documentation that two of my flags D3DXSHADER_FORCE_VS... and the other one need REF or software vertex processing to work. I cut them off. – MahanGM Apr 2 '15 at 0:06
• can you post the code you use to create the effect? – P. Avery Apr 2 '15 at 5:59

I didn't get FindNextValidTechnique to work and I resorted to ValidateTechnique instead. I used the base method ID3DXEffect::GetDesc to get effect description and then counted techniques through a for loop and checked each technique:

D3DXHANDLE* pValidTechnique = NULL;

for (unsigned int i = 0; i < effectDesc.Techniques; i++)
{
D3DXHANDLE technique = pEffect->GetTechnique(i);

if (pValidTechnique == NULL)
{
if (pEffect->ValidateTechnique(technique) == S_OK)
{
pValidTechnique = &technique;

break;
}
}
}


ValidateTechnique works while FindNextValidTechnique doesn't. Weird!

• should you be using an D3DXHANDLE pointer? try D3DXHANDLE pValidTechnique; and reference the handle in the call to findnextvalidtechnique – P. Avery Apr 2 '15 at 6:03
• @P.Avery This answer is my workaround and I'm OK with it. What you're saying is basically a compile time matter. I don't have such problem. Thanks for your help anyway. – MahanGM Apr 2 '15 at 18:18
• You should be using the SUCCEEDED or FAILED macros instead of checking for S_OK; also please see msdn.microsoft.com/en-us/library/windows/desktop/… where the return values for failure are given; these may assist in troubleshooting what you're doing wrong. – Maximus Minimus Nov 11 '16 at 16:00