Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Effect reflection stack error - Effects11

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 andyhansen   Members   

105
Like
0Likes
Like

Posted 28 May 2012 - 12:16 PM

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.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.