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.

Recommended Posts

ID3DXEffect::GetPixelShader(D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9* ppPShader I want to retrieve the pixelshader from an effect but I cant figure out what goes into hParameter?

Share on other sites
I *think* you can just specify the name of the pixel shader function and use the string as a handle, or use GetParameterByName to cache handle. I'm not sure though, I've never done it.

Share on other sites
That's what I expected.

float4 MainPS( PS_INPUT Input ) : COLOR0
{
}

{
// some code
}

Need help :(

Share on other sites
Try to get more detail from error: DXGetErrorString may help you.

Share on other sites
Anything from the debug runtimes?

Share on other sites
Quote:
 Original post by Evil SteveAnything from the debug runtimes?

You say everytime the SAME THING!!!
:D:D:D:D:D

Share on other sites
DXGetErrorString returns D3DERR_INVALIDCALL, but this was also mentioned in the SDK docs.

Is there not a single person that knows how to use GetPixelShader?

Share on other sites
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 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 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 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 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 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.

Share on other sites

I thought you couldn't necro bump threads over 60 days old?

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.

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

• Forum Statistics

• Total Topics
628745
• Total Posts
2984488

• 12
• 25
• 12
• 10
• 17