Lighting: Compute the GE's pow from the float's bits

Read as an integer, a float's bits are its log2 with the mantissa a
straight line between powers of two, scaled by 2^23, and writing an
integer back is the matching exp2. That's exactly the GE's
approximation, without log2/exp2/floor. pspPow now also returns 1 for
e <= 0 itself, so the callers drop their checks. Shader languages
without integers fall back to a true pow.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-30 15:47:16 -06:00
1 parent 9162592493
commit 333035df03
4 files changed
+41 -44

No files matched your search

+4
View File
@@ -37,6 +37,8 @@ const char * const hlsl_preamble_fs =
"#define inversesqrt rsqrt\n"
"#define floatBitsToUint asuint\n"
"#define uintBitsToFloat asfloat\n"
"#define floatBitsToInt asint\n"
"#define intBitsToFloat asfloat\n"
"\n";
static const char * const hlsl_d3d11_preamble_fs =
@@ -71,6 +73,8 @@ static const char * const hlsl_preamble_vs =
"#define inversesqrt rsqrt\n"
"#define floatBitsToUint asuint\n"
"#define uintBitsToFloat asfloat\n"
"#define floatBitsToInt asint\n"
"#define intBitsToFloat asfloat\n"
"\n";
static const char * const semanticNames[] = {