Sign in to follow this  
coolhelix

How can I get annotation of function parameter in vertex shader?

Recommended Posts

Hi, guys, For some reason, I want to add some annotation to my vertex shader function. The code would something like this ...... VS_OUTPUT vs_main( float4 Position : POSITION0 <string Token = "ModelPosition";>) { ...... } The compiling is fine. My question is how to use D3D interface to get the annotation of "Token" here. Thanks!

Share this post


Link to post
Share on other sites
Normally you look for the ::GetAnnotation*() type functions on ID3DXEffect - they're pretty straight forward.

However, in your case I wouldn't expect it to work. Only in the latest shader models and compilers do functions truly exist and prior to this they were all inlined by the compiler such that they aren't visible on any public interface - you probably can't even see them in the ASM output except in debug/non-optimized modes.

Annotations are more for global constants or technique/pass descriptions, not for function parameters.

hth
Jack

Share this post


Link to post
Share on other sites
hmm, all that said you might want to try making calls to ID3DXEffect::GetParameter() using the D3DXHANDLE for the function (found via ID3DXEffect::GetFunction()). At the very least you should be able to annotate your VS_INPUT struct if you were to refactor your parameter list to that form...

hth
Jack

Share this post


Link to post
Share on other sites
Thanks.

Like you said, if I could add some annotations to the struct, that would be better.
I tried, but compiling was failed.

Failed Case 1:

struct VS_INPUT
{
float4 Position : POSITION0;
float Height: TEXCOORD0;
float2 TextureUV: TEXCOORD1;
}
<
string Notes1 = "Terrain Vertex";
string Notes2 = "Terrain Height";
string Notes3 = "Terrain Texture";
> ;


Failed Case 2:

struct VS_INPUT
{
float4 Position : POSITION0 <string Notes1 = "Terrain Vertex";> ;
float Height: TEXCOORD0 <string Notes2 = "Terrain Height";> ;
float2 TextureUV: TEXCOORD1 <string Notes3 = "Terrain Texture";>;
};

Share this post


Link to post
Share on other sites

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