Float precision with 32F textures


Does someone know how many bits are used for the integer part of a float in the 32F textures?

I want to store in a texture integers of minimum 24 bits, but the maximum integer texture are 16 bits, but exists float textures of 32 bits.


32F textures can store 24-bit integers because they have 24 bits for their fraction. So it’s 24 bits worth of contiguous values, whatever your exponent is. You can get more values if you are using signed integers.

32 bit IEEE floats only have 23 bits of mantissa.

32 bit IEEE floats only have 23 bits of mantissa.
And 1 sign bit, hence 24-bit precision. The other 8 bits are the signed exponent.

I also have to ask: why do you need to store textures with such high precision? What are you doing that needs it?

32 bit IEEE floats have 1 sign bit, 8 exponent bits, and 23 mantissa bits.

But because the format is normalized (except for numbers very close to 0 – called denorms), there’s an implied 1 as the MSB of the mantissa.

So in most circumstances you get 24 bits of mantissa, and you can definitely represent 24 bit unsigned integers.

I don’t know what the original poster is using this for, but one example is storing an index value alongside positions for sorting.

Thank you very much!

As was mentioned, I need to store the index position to sort my texture. The maximum size of a texture in my card is 4096x4096, and I need 24bits to represent all the positions.