Get PixelShader from ID3DXEffect

Started by
13 comments, last by Tispe 10 years, 8 months ago
ID3DXEffect::GetPixelShader(D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9* ppPShader I want to retrieve the pixelshader from an effect but I cant figure out what goes into hParameter?
Advertisement
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.
That's what I expected.

float4 MainPS( PS_INPUT Input ) : COLOR0
{
// shader code
}


LPDIRECT3DPIXELSHADER9 _shader
if(effect->GetPixelShader("MainPS", &_shader) == D3D_OK) // fails
{
// some code
}
Need help :(
Try to get more detail from error: DXGetErrorString may help you.
Anything from the debug runtimes?
Quote:Original post by Evil Steve
Anything from the debug runtimes?



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

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?

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.
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.

This topic is closed to new replies.

Advertisement