Jump to content
  • Advertisement
Sign in to follow this  
JediZeus

16-bit floats and HLSL

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Has anyone managed to get 16-bit floats working in HLSL. I have created a vertex declaration using : D3DDECLTYPE_FLOAT16_4 as the data type and have specified the variables in my vertex structure with : D3DXFLOAT16 Does anyone have an example of where this is used. Thanks a lot

Share this post


Link to post
Share on other sites
Advertisement
Hi,

Yes I am currently using the half4. Does anyone know how to check if one's graphics card supports 16-bit floats?

Thanks.

Share this post


Link to post
Share on other sites
In terms of what can run where this should be transparent. The only way I know to find out the actual accuracy is to run a shader and check results. Though basically only NVIDIA supports half variables natively. ATI will use higher accuracy.

Input format here shouldn't be related to shader variable format. Use Half inputs when you want to save space and your data doesn't need extra accuracy. Use Half in the shader when you want it to work faster on NVIDIA and the calculation doesn't need high accuracy.

Share this post


Link to post
Share on other sites
Quote:
Original post by JediZeus
Yes I am currently using the half4. Does anyone know how to check if one's graphics card supports 16-bit floats?


You have to remember than no matter what you do it's only a hint to the compiler. The legal specification is very limited in what it defines and only tells you what the *expected* minimal storage for the temporary register is. For example it doesn't tell you how instructions should be implemented, and it doesn't prevent the hardware to give you more precision than that. And there is no CAPS that tells you if HALF will get faster or not (it's usually not that simple).

Only use the HALF format when you calculate something that doesn't necessarily need good consistency. For example, if you render in LDR (8 bits per pixels), with a texture multiplied by a per vertex color, then HALF for the temporary registers is more than enough.
Also when you use FULL precision but in conjunction to PS2.x don't expect to get 32 bits precision because it isn't true on most Radeon cards. The spec only requires a minimum of 24 bits for temporary registers.

On SM3.0, everything has been simplified to only use 32 bits of precisions for all temporary registers.

If you're confused and really need this info, you may want to check the performance tools from NVIDIA.
Like nvShaderPerf.
Writing optimal shaders is not a trivial task, and sometimes putting a HALF hint in good faith will actually slow you down (depending on your register usage).
That's why you need those tools.

LeGreg

Share this post


Link to post
Share on other sites
Quote:
Original post by JediZeus
Hi,

Yes I am currently using the half4. Does anyone know how to check if one's graphics card supports 16-bit floats?

Thanks.


D3DDTCAPS_FLOAT16_2
D3DDTCAPS_FLOAT16_4

in D3DCAPS9.DeclTypes


Though as has been mentioned, that won't tell you whether there's any performance benefit (or indeed cost) to using 16-bit floats.

Share this post


Link to post
Share on other sites
Quote:
Original post by LeGreg
On SM3.0, everything has been simplified to only use 32 bits of precisions for all temporary registers.

LeGreg


You can still use partial precision with SM3 and as with SM2 it stands for 16 bit floating point values. Only full precision are upgraded to 32 bit values.

Share this post


Link to post
Share on other sites
Quote:
Original post by Demirug
You can still use partial precision with SM3 and as with SM2 it stands for 16 bit floating point values. Only full precision are upgraded to 32 bit values.


Yep ;) sorry

LeGreg

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!