Sign in to follow this  
ClementLuminy

Getting HLSL parameter default value pb ...

Recommended Posts

ClementLuminy    121
Hello ! I need to get the default parameter value of a global HLSL parameter. Here is my parameter declaration inside my HSLS file: ... const int Light_SupportedOrthographicLightCount = 1; ... and inside my application, i use the follwoing code: ... D3DXCONSTANT_DESC parameter_desc; UINT parameter_count; parameter_count = 1; GetVertexShaderConstantTable()->GetConstantDesc( parameterhandle, ¶meter_desc, ¶meter_count ); int value; value = *((INT*)parameter_desc.DefaultValue); ... I'm sure that i acces the good parameter, because, inside the resulting parameter descriptor, every fields are valid ( parameter name and so on ... ) The only thing that is not valid is the "DefaultValue" field, when i derefence it, i do not get the expected default value ( 1 ) but a value like 0x40800000 .... Does anybody know what is wrong here ??? Thanks a lot !! CLement

Share this post


Link to post
Share on other sites
Rompa    307
0x40800000 looks a bit like a pointer to me (for the PC). Do you get a crash if you use *(UINT**)parameter_desc.DefaultValue ? I've never played with this stuff, but perhaps its returning an array of default values (of which a scalar has one element)?

Share this post


Link to post
Share on other sites
Mastaba    761
It also looks very similar to a floating point number. If the constant was mapped to a c register then it would be a floating point value, and not the integer value you assume. I have seen the HLSL compiler do just that too.

Share this post


Link to post
Share on other sites
janta    345
int i = 0x3f800000;
float f = *(float*)&i; // f == 1.0f (use reinterpret_cast if you like)


Maybe what you're seeing is the int representation of a float value ?

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