Advertisement Jump to content
Sign in to follow this  
andyhansen

DX11 Effect reflection stack error - Effects11

This topic is 2430 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am attempting to use the reflection features of the effects11 library to retrieve the argument list for a pass's vertex shader.
When I call GetInputSignatureElementDesc() I get a runtime check error, "Run-Time Check Failure #2 - Stack around the variable ParamDesc was corrupted."

Is this something other people have experienced? I'm hoping it isn't due to a memory error buried somewhere in my code.

Here is the code where I compile the effect an try to read in a parameter.



DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DCOMPILE_DEBUG;
#endif

ID3DBlob* pErrorBlob;
ID3DBlob* compiled;

HRESULT hr=D3DX11CompileFromFile(file.c_str(),NULL,NULL,NULL,GetProfile(device).c_str(),dwShaderFlags,NULL,NULL,&compiled,&pErrorBlob,NULL);

if( FAILED(hr) )
{
if( pErrorBlob != NULL ){
throw runtime_error((char*)pErrorBlob->GetBufferPointer());
if( pErrorBlob ) pErrorBlob->Release();
}
else{
throw runtime_error("Failed to compile effect "+StringUtil::WstrToStr(file));
}
}

hr=D3DX11CreateEffectFromMemory(compiled->GetBufferPointer(),compiled->GetBufferSize(),NULL,device.GetDevice(),&effect);

compiled->Release();

if(FAILED(hr)){
throw runtime_error("Failed to create effect from file");
}

UINT i=0;
ID3DX11EffectTechnique* technique=effect->GetTechniqueByIndex(i++);

while(technique->IsValid()){
D3DX11_PASS_SHADER_DESC vsDesc;
technique->GetPassByIndex(0)->GetVertexShaderDesc(&vsDesc);
D3D11_SIGNATURE_PARAMETER_DESC paramDesc;
vsDesc.pShaderVariable->GetInputSignatureElementDesc(vsDesc.ShaderIndex,0,&paramDesc);
technique=effect->GetTechniqueByIndex(i++);
}


Right now I'm just trying to read the first parameter of the first pass of each technique to see if it will work. After the runtime error is triggered, I can hover my mouse over paramDesc, and it seems to have at least some of the correct data in it. I can't find any actual examples of how to do effect reflection, so I may be doing something wrong.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!