supagu

I've got some code that works fine when not running via pix, how ever when i run it through pix it crashes. I've found that the crash is caused when i call either:

SetResource

or

SetMatrix

here is my code:

void DX10Effect::SetTexture(EffectParamHandle handle, Texture* texture)

{

HRESULT hr = ((ID3D10EffectShaderResourceVariable*)handle)->SetResource(static_cast<DX10Texture*>(texture)->GetTextureRV());

int nothing = 0;

}

void DX10Effect::SetMatrix4(EffectParamHandle handle, const Matrix4& matrix)

{

HRESULT hr = ((ID3D10EffectMatrixVariable*)handle)->SetMatrix((float*)&matrix);

int nothing = 0;

}

EffectParamHandle is typdef'ed as a void*

so hr = S_OK when not running through PIX.

if i comment out these calls and run through pix, no crashes.



Re: Direct3D 10 PIX crash when attempting to set shader variable

Ralf Kornmann

I have a suspicion were there problem is based.

How do you create this two ¡°handles¡±






Re: Direct3D 10 PIX crash when attempting to set shader variable

supagu

 

ID3D10Effect* mEffect

 

D3D10_EFFECT_DESC desc;

HRESULT hr = mEffect->GetDesc(&desc);

 

for (unsigned int i = 0; i < desc.GlobalVariables; ++i)

{

ID3D10EffectVariable* d3dParam = GetEffect()->GetVariableByIndex(i);

 

d3dParam then gets cast to a EffectParamHandle

 

i check  the semantic of the variable before calling SetMatrix or SetTexture so i know its of the right type (i also have double checked this with:

 

ID3D10EffectMatrixVariable* matrixVar = ((ID3D10EffectVariable*)handle)->AsMatrix();

and

ID3D10EffectShaderResourceVariable* resourceVar = ((ID3D10EffectVariable*)handle)->AsShaderResource();

in the appropriate function.





Re: Direct3D 10 PIX crash when attempting to set shader variable

Ralf Kornmann

Is EffectParamHandle a typedef for void* or something like this

Using GetVariableByIndex could be dangerous as there is no guaranteed order. You should use GetVariableByName or use the variable description to make sure you have the right one.






Re: Direct3D 10 PIX crash when attempting to set shader variable

Gibbz

yep EffectParamHandle is actually a void*

I will try out your suggestion, thank you




Re: Direct3D 10 PIX crash when attempting to set shader variable

supagu

okay the problem was caused by not me using ->AsMatrix() on the effect variable, i was doing a strait cast, which is odd as it returned a pointer to the same address.



Re: Direct3D 10 PIX crash when attempting to set shader variable

Ralf Kornmann

Yes, but only if you run without pix and use the ¡°right¡± AsXXX method. As Pix add an additional layer they behavior of such undocumented ¡°features¡± could differ.