2
\$\begingroup\$

My effect file compiles successfully, but FindNextValidTechnique fails.

Technique part of the shader:

technique Diffuse
{
    pass Pass0
    {
        VertexShader = compile vs_2_0 VertexShaderMain();
        PixelShader = compile ps_2_0 PixelShaderMain();
    }
}

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 |
D3DXSHADER_NO_PRESHADER |
D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT | 
D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
\$\endgroup\$
  • \$\begingroup\$ Have you tried using the debug runtime? It may have more information for you. \$\endgroup\$ – P. Avery Apr 1 '15 at 16:29
  • \$\begingroup\$ @P.Avery I'm in debug, but nothing. And this function doesn't return anything special really according to the documentation. \$\endgroup\$ – MahanGM Apr 1 '15 at 19:40
  • \$\begingroup\$ Have you tried compiling the effect without those flags? \$\endgroup\$ – P. Avery Apr 1 '15 at 23:56
  • \$\begingroup\$ @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. \$\endgroup\$ – MahanGM Apr 2 '15 at 0:06
  • \$\begingroup\$ can you post the code you use to create the effect? \$\endgroup\$ – P. Avery Apr 2 '15 at 5:59
1
\$\begingroup\$

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!

\$\endgroup\$
  • \$\begingroup\$ should you be using an D3DXHANDLE pointer? try D3DXHANDLE pValidTechnique; and reference the handle in the call to findnextvalidtechnique \$\endgroup\$ – P. Avery Apr 2 '15 at 6:03
  • \$\begingroup\$ @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. \$\endgroup\$ – MahanGM Apr 2 '15 at 18:18
  • \$\begingroup\$ 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. \$\endgroup\$ – Maximus Minimus Nov 11 '16 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.