From 9de43e7757c082b2ccb33ed1447f8569487a564c Mon Sep 17 00:00:00 2001 From: castano Date: Wed, 28 Sep 2011 22:02:46 +0000 Subject: [PATCH] Fix build errors/warnings. --- extern/poshlib/posh.h | 4 ++-- src/nvmath/nvmath.h | 10 ++++++---- src/nvtt/Surface.cpp | 16 ++++++++-------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/extern/poshlib/posh.h b/extern/poshlib/posh.h index 787419c..61d6fb7 100644 --- a/extern/poshlib/posh.h +++ b/extern/poshlib/posh.h @@ -692,8 +692,8 @@ typedef unsigned long posh_u64_t; # define POSH_64BIT_INTEGER 1 typedef __int64 posh_i64_t; typedef unsigned __int64 posh_u64_t; -# define POSH_I64( x ) ((posh_i64_t)x) -# define POSH_U64( x ) ((posh_u64_t)x) +# define POSH_I64( x ) ((posh_i64_t)(x##i64)) +# define POSH_U64( x ) ((posh_u64_t)(x##ui64)) # define POSH_I64_PRINTF_PREFIX "I64" #elif defined __GNUC__ || defined __MWERKS__ || defined __SUNPRO_C || defined __SUNPRO_CC || defined __APPLE_CC__ || defined POSH_OS_IRIX || defined _LONG_LONG || defined _CRAYC # define POSH_64BIT_INTEGER 1 diff --git a/src/nvmath/nvmath.h b/src/nvmath/nvmath.h index d3ef217..717157c 100644 --- a/src/nvmath/nvmath.h +++ b/src/nvmath/nvmath.h @@ -238,15 +238,17 @@ namespace nv // I'm always confused about which quantizer to use. I think we should choose a quantizer based on how the values are expanded later and this is generally using the 'exact endpoints' rule. // Quantize a [0, 1] full precision float, using exact endpoints. - inline float quantizeFloat(float f, int bits) { - float scale = (1 << bits) - 1; + inline float quantizeFloat(float f, uint bits) { + nvDebugCheck(bits <= 16); + float scale = float((1 << bits) - 1); float offset = 0.0f; return floor(saturate(f) * scale + offset) / scale; } // Quantize a [0, 1] full precision float, using uniform bins. - /*inline float quantizeFloat(float f, int bits) { - float scale = (1 << bits); + /*inline float quantizeFloat(float f, uint bits) { + nvDebugCheck(bits <= 16); + float scale = float(1 << bits); float offset = 0.5f; return floor(saturate(f) * scale + offset) / scale; }*/ diff --git a/src/nvtt/Surface.cpp b/src/nvtt/Surface.cpp index 1927248..1e8fe6c 100644 --- a/src/nvtt/Surface.cpp +++ b/src/nvtt/Surface.cpp @@ -1469,10 +1469,10 @@ void Surface::toRGBE(int mantissaBits, int exponentBits) int E = max(- exponentBias - 1, floatExponent(M)) + 1 + exponentBias; nvDebugCheck(E >= 0 && E < (1 << exponentBits)); - double denom = pow(2, E - exponentBias - mantissaBits); + double denom = pow(2.0, double(E - exponentBias - mantissaBits)); // Refine exponent: - int m = iround(M / denom); + int m = iround(float(M / denom)); nvDebugCheck(m <= (1 << mantissaBits)); if (m == (1 << mantissaBits)) { @@ -1481,9 +1481,9 @@ void Surface::toRGBE(int mantissaBits, int exponentBits) nvDebugCheck(E < (1 << exponentBits)); } - R = floatRound(R / denom); - G = floatRound(G / denom); - B = floatRound(B / denom); + R = floatRound(float(R / denom)); + G = floatRound(float(G / denom)); + B = floatRound(float(B / denom)); nvDebugCheck(R >= 0 && R < (1 << mantissaBits)); nvDebugCheck(G >= 0 && G < (1 << mantissaBits)); @@ -1493,7 +1493,7 @@ void Surface::toRGBE(int mantissaBits, int exponentBits) r[i] = R / ((1 << mantissaBits) - 1); g[i] = G / ((1 << mantissaBits) - 1); b[i] = B / ((1 << mantissaBits) - 1); - a[i] = E / ((1 << exponentBits) - 1); + a[i] = float(E) / ((1 << exponentBits) - 1); } } @@ -1529,7 +1529,7 @@ void Surface::fromRGBE(int mantissaBits, int exponentBits) detach(); // exponent bias: 5 -> 15, 8 -> 127 - const float exponentBias = (1 << (exponentBits - 1)) - 1; + const int exponentBias = (1 << (exponentBits - 1)) - 1; FloatImage * img = m->image; float * r = img->channel(0); @@ -1545,7 +1545,7 @@ void Surface::fromRGBE(int mantissaBits, int exponentBits) int B = iround(b[i] * ((1 << mantissaBits) - 1)); int E = iround(a[i] * ((1 << exponentBits) - 1)); - float scale = powf(2, E - exponentBias - mantissaBits); + float scale = powf(2, float(E - exponentBias - mantissaBits)); r[i] = R * scale; g[i] = G * scale;