• Advertisement

Archived

This topic is now archived and is closed to further replies.

ID3DXEffect

This topic is 5809 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''m using the ID3DXEffect class for vertex/pixel shaders. Overall I think it''s a pretty good system. There are two problems I''m having that I was hoping someone could answer. Question the First: I call ID3DXEffect::Begin() to start drawing a bunch of stuff. Then I call ID3DXEffect::SetMatrix(), draw some stuff, call SetMatrix() again, etc... After drawing I call ID3DXEffect::End(). It seems that the matrices aren''t getting updated in between Begin() and End() calls however. Is this correct behaviour? Do I incur a speed hit by calling Begin(), End(). If I do, how would I be able to draw a bunch of objects that use the same effect but different world transforms? Question the Last: The docs say that ID3DXEffect::SetTexture increments the reference count on that texture so I should call release when I''m done using it. If I SetTexture(), draw, Release(), and repeat, then I get a crash because the Texture is invalid or has been released. Are the docs wrong? Thank you very much.

Share this post


Link to post
Share on other sites
Advertisement
I just done a bit more testing on that reference count on the textures. Here''s what I do in case anyone wants to double check...


UINT count = pTex->AddRef();
// print count
pTex->Release();
SetTexture("texture", pTex);
count = pTex->AddRef();
// print count
pTex->Release();

Both times, before and after the SetTexture(), the returned reference count is the same. Guess the docs are wrong.

Anyone know anything about the first problem?

Share this post


Link to post
Share on other sites
The docs are misleading. Effect will take care of any resource managment it needs to. For any D3DX function you NEVER have to call a release afterwords (with exception to creates, of course )

BTW, Do don''t put any calls to var changes in between the begin end pair. It''s never needed. Calling Pass(dwPassNum) should set them correctly, but for performance sake its better to set them outside your rendering loop.

Share this post


Link to post
Share on other sites
The situation I have for changing the effect params between begin()/end() is that I want to use the same effect for multiple objects that each have different world transformation matrices. Do I incur a speed hit for begin()/end() and is there a way to change matrices without incurring a speed hit from changing the shader or effect?

Share this post


Link to post
Share on other sites
Calls between Begin and End will work, but they will ''fall through'' to the device, that is, the effect will not remember you set them.

So, if you make changes between the begin() and end(), don''t count on them being saved.

BTW, be sure to use the latested D3DX, 8.1. There were some bug fixes over 8.0.

Share this post


Link to post
Share on other sites

  • Advertisement