• 10
• 12
• 12
• 14
• 16

# Getting HLSL parameter default value pb ...

This topic is 4056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
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 ?