Getting HLSL parameter default value pb ...

Started by
2 comments, last by janta 17 years, 1 month ago
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, &parameter_desc, &parameter_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
Advertisement
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)?
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.
.
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 ?

This topic is closed to new replies.

Advertisement