SetFloat, SetVector, SetMatrix have no effect

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

Recommended Posts

I'm having trouble setting shader variables, as in I'm unable to.  In the FX file, I have:

//cbuffer ExplosionData : register(b0) // BUGBUG consistent casing
//{
float    secondsRemaining;
float    explosionSpeed;
float4x4 worldViewProjection;
Texture  particleTexture;
float3   startPosition;
//}

I get the D3DXHANDLEs to them by name, and they come back with valid handles.  As you can see I originally had them in a cbuffer but moved them out just to see if it made a difference, which it did not.  This is all vs3_0 and ps3_0 stuff.

_hSecondsLiftime       = _ptrEffect->GetParameterByName(0, "secondsLifetime");
_hSecondsRemaining     = _ptrEffect->GetParameterByName(0, "secondsRemaining");
_hExplosionSpeed       = _ptrEffect->GetParameterByName(0, "explosionSpeed");
_hWorldViewProjection  = _ptrEffect->GetParameterByName(0, "worldViewProjection");
_hParticleTexture      = _ptrEffect->GetParameterByName(0, "particleTexture");
_hStartPosition        = _ptrEffect->GetParameterByName(0, "startPosition");
In my render code I do BeginScene, SetTechnique, abd BeginPass.  Then I SetVertexDeclaration, SetVertexShader, SetPixel shader, all good so far.  Then I start to set my shader variables.

In PIX, however, I can see this:
IDIRECT3DDevice9::SetFloat(0xFEFE5B7B, 0.000f);
IDIRECT3DDevice9::SetFloat(0xFEFE5B23, 0.000f);
...
IDIRECT3DDevice9::SetMatrix(0xFEFE5A73, 0x3FE7C3B5)


The problem, as you can see, is that no matter values (and I've walked it and verified they are non-zero at the call) get passed through as zero, and my worldViewProjection winds up as an empty matrix.

The question, then, is:  "What could I be doing wrong based on the above to cause setting my shader variables to do nothing?"

I've stuck a RAR of the PIX file at the end, for what that's worth!  Many thanks for any tips!

Share on other sites

You're making your Set calls after BeginPass so you need to call ID3DXEffect::CommitChanges before you can draw.

If the application changes any effect state using any of the Effect::Setx methods inside of a ID3DXEffect::BeginPass/ID3DXEffect::EndPass matching pair, the application must call ID3DXEffect::CommitChanges to set the update the device with the state changes.

Edited by mhagain

Share on other sites

My issue turned out to be a pretty basic one - not calling effect->Begin(...) on the effect itself, although I had called Begin on the scene and on the pass.

• 13
• 18
• 29
• 11
• 27