generate the smallest float/double that preserves the binary representation #2132
Labels
enhancement
New feature to SPIRV-Cross is desired.
maintenance
Non-functional issue / code cleanliness
Currently spirv-cross uses
%.32g
by default to formatfloats
, this can be overridden withSPIRV_CROSS_FLT_FMT
at compile time. When embedding shaders with binaries, reducing their binary footprint can be important.What really matters is to preserve the binary representation of the float in the SPIRV file. 32 digits is overkill for
floats
anddoubles
. We could use respectively 9 and 17 digits, which is always enough, however, this would still generate strings larger than needed.Ideally, we'd want to use the smallest string that preserves the binary representation.
For instance, I have tested the following implementation for
floats
only:For
doubles
andlong doubles
it might better to binary-search the right format length.The text was updated successfully, but these errors were encountered: