Skip to main content
GameDev.net gamedev.net
🔒 Locked

Question about ID3DXBaseEffect::GetVertexShader and ID3DXBaseEffect::GetPixelShader

Started by Jofu Jan 10, 2010 at 12:47 AM 3 replies 1.4k views
Original Post
Jofu
Jofu
Hello guys, I think this is a simple question, but can't figure it out :( Direct3D 9's ID3DXBaseEffect interface has functions GetVertexShader and GetPixelShader. Each takes a D3DXHANDLE, which I can't for the life of me find where I get them from... The MS online documentation found using the link below isn't at all clear about it, unless of course I missed something obvious: http://msdn.microsoft.com/en-us/library/ee420729(VS.85).aspx And yes I know I could go ahead and use effects without calling those functions ;) But for reasons I don't care to go into, I was hoping to get to them. Many thanks in advance!!! Jofu
Nik02
Nik02
You can use ID3DXBaseEffect::GetParameterByName to look up stuff from an effect. That method returns a handle to the desired parameter (such as a shader), which you can subsequently use when you get or set its value.

Note that because a D3DXHANDLE is internally just a string pointer, you can use a null-terminated string to address the effect variable directly. However, this will reduce performance because the effect system has to enumerate thru all possible symbols when it looks up the variable. For this reason, it is better to save the handle in advance, and address the effect variables via it during rendering.

This explains the handles pretty well, in my opinion.
Niko Suni
Jofu
Jofu
Thanks a bunch Nik for the reply!

What you say does make sense, but actually the name of the vertex and/or pixel shader is one of the things I was hoping to eventually get from all this :P

Well, maybe it won't be possible, but at any rate I don't know the name of the vertex or pixel shader, as it's user-provided in the pass description in the FX file.

Interestingly, as I have my effect pointer (which I got from calling D3DXCreateEffect), I decided to loop through all parameters by doing the following:

{
D3DXHANDLE parameterHandle;
D3DXPARAMETER_DESC parameterDesc;

for (int i = 0; (parameterHandle = pEffect->GetParameter (NULL, i)) != NULL; i++)
{
if (pEffect->GetParameterDesc (parameterHandle, &parameterDesc) != D3D_OK)
break;

printf (" Parameter %d: Name = '%s' Type = %d\n", i, parameterDesc.Name, parameterDesc.Type);
}
}

I see all global uniforms, but do not see my structs nor my shaders. It's as if it's not seeing my technique/passes because I didn't set it or compiled it... Is there some preamble step I'm missing?...

I can post my FX file if it'll help, but it's just one I took from somewhere online, and the 2 shaders are reeeeeaaaaally basic.

Thanks again for the help so far,

Jofu
JohnnyCode
JohnnyCode
Quote:
Original post by Jofu
Direct3D 9's ID3DXBaseEffect interface has functions GetVertexShader and GetPixelShader. Each takes a D3DXHANDLE, which I can't for the life of me find where I get them from


ID3DXBaseEffect gettechnique and following methods would have more information about effect I think. In effect you have more techniques, each with passes, and passes composed of two functions.
Jofu
Jofu
Quote:
Original post by JohnnyCode
ID3DXBaseEffect gettechnique and following methods would have more information about effect I think. In effect you have more techniques, each with passes, and passes composed of two functions.


Indeed, that's how you get to techniques and passes, but when you query a pass' D3DXPASS_DESC, you get the pass name, its annotations, and then 2 DWORD array pointers, one for VertexShaderFunction and one for PixelShaderFunction. Maybe it's what I need afterall, but there's nothing in the documentation as to what those are exactly :( At this point I assume they're pointers to shader binary representations? It sure seems this way when I look at the memory content...

Jofu

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.