Sign in to follow this  

Get PixelShader from ID3DXEffect

This topic is 1593 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

mmm, mabye in this way it should work, even if it's not the best way to get it.

IDirect3DPixelShader9 *GetPixelShader(ID3DXEffect *Effect, IDirect3DDevice9 *device, char* TechniqueThatContainsPixelShader)
{
Effect->SetTechnique(TechniqueThatContainsPixelShader);
IDirect3DPixelShader9 *pPixelShader;

device->GetPixelShader(&pPixelShader);
device->SetPixelShader(NULL);
device->SetVertexShader(NULL);

return pPixelShader;
//Pixel Shader's reference count has been increased. So you have to release the interface.


IDirect3DPixelShader9 pixel = GetPixelShader(myEffect,device,"SimpleTech");
//Stuff....

pixel->Release();
}



You can use the same method for Vertex Shader.

I know that is not the best way to get it and it's also the worse in performances terms, but if you really need it, mabye for now it can be good.

Share this post


Link to post
Share on other sites
Hey wait a moment: i was thinking to your problem and i had an illumination: mabye the D3DXHANDLE parameter that DirectX asks you in GetPixelShader function it's the technique name from which D3D will fetch your pixel shader!!!

Try it and let us know.

Share this post


Link to post
Share on other sites

Hey wait a moment: i was thinking to your problem and i had an illumination: mabye the D3DXHANDLE parameter that DirectX asks you in GetPixelShader function it's the technique name from which D3D will fetch your pixel shader!!!

Try it and let us know.

 

I'm in the same boat.  I've tried passing both the Technique and the Pass handle, but both generate the D3DERR_INVALIDCALL and the debug runtime says its an invalid handle.  Yet they're non-zero and the "GetPassByName" that I use to get the handle succeeds.

Anyone come up with a solution to this yet?

Share this post


Link to post
Share on other sites

You are falling in a trap. Let me clarify. Technique consists of passes and a pass consists of a vertex-pixel function pair. You never cut the pair, and I cannot imagine why on earth you want to get pixel shader function. To use a technique defined in an effect you do following:

 

-Gettechniquebyname

-settechnique

-beginpass(index)

-settexture(slot)

-setstream(layoutvertexdeclartion,index)

-setuniforms

-drawindexedprimitive

-endpass

//begin other pass of the technique if desired and set resources that gets set in beginpass/endpass

 

you use passes, not vertex or pixel functions. And read the reference of the effect class at msdn as for what objects you can get from it actualy, as I'm not sure wheather it can return functions at all, if ever you need them somehow

 

Share this post


Link to post
Share on other sites

ANd if you want to combine existing functions writen in the fx file, define another pass with apropriate v/p pair of functions within a technique, or, define a new technique with a pass of the apropriate pair. You may create a pair just as you like, with existing vertex function and a new pixel function, or any how.

Share this post


Link to post
Share on other sites

I've already moved away from the Effects framework so I cannot try it (and I never needed to get the pixel shader when I was using Effects). But after some searching it seems that you maybe could be more lucky by using the GetPassDesc function.

http://www.gamedev.net/topic/646178-given-an-effect-technique-pass-handle-how-to-get-the-pixelshader/

Share this post


Link to post
Share on other sites

This topic is 1593 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this