diff --git a/extern/poshlib/posh.h b/extern/poshlib/posh.h index c12be41..9586402 100644 --- a/extern/poshlib/posh.h +++ b/extern/poshlib/posh.h @@ -203,6 +203,9 @@ Metrowerks: - __INTEL__ for x86 targets - __POWERPC__ +LLVM: + - __llvm__ + - __clang__ */ /* @@ -237,9 +240,9 @@ Metrowerks: #if defined __clang__ # define POSH_COMPILER_STRING "Clang" # define POSH_COMPILER_CLANG 1 +#endif -#elif defined __GNUC__ - +#if defined __GNUC__ && !defined __clang__ # define POSH_COMPILER_STRING "Gnu GCC" # define POSH_COMPILER_GCC 1 #endif diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp index 9c852d1..2dc22dc 100644 --- a/src/nvcore/Debug.cpp +++ b/src/nvcore/Debug.cpp @@ -486,10 +486,11 @@ namespace #endif } - static void printStackTrace(void * trace[], int size, int start=0) { + + static void writeStackTrace(void * trace[], int size, int start, Array & lines) { + StringBuilder builder(512); char ** string_array = backtrace_symbols(trace, size); - nvDebug( "\nDumping stacktrace:\n" ); for(int i = start; i < size-1; i++ ) { # if NV_CC_GNUC // defined(HAVE_CXXABI_H) // @@ Write a better parser for the possible formats. @@ -510,34 +511,48 @@ namespace char * name = abi::__cxa_demangle(begin+1, 0, 0, &stat); if (module == NULL) { if (name == NULL || stat != 0) { - nvDebug( " In: '%s'\n", begin+1 ); + builder.format(" In: '%s'\n", begin+1); } else { - nvDebug( " In: '%s'\n", name ); + builder.format(" In: '%s'\n", name); } } else { if (name == NULL || stat != 0) { - nvDebug( " In: [%s] '%s'\n", module, begin+1 ); + builder.format(" In: [%s] '%s'\n", module, begin+1); } else { - nvDebug( " In: [%s] '%s'\n", module, name ); + builder.format(" In: [%s] '%s'\n", module, name); } } free(name); } else { - nvDebug( " In: '%s'\n", string_array[i] ); + builder.format(" In: '%s'\n", string_array[i]); } # else - nvDebug( " In: '%s'\n", string_array[i] ); + builder.format(" In: '%s'\n", string_array[i]); # endif + lines.append(builder.release()); } - nvDebug("\n"); free(string_array); } + static void printStackTrace(void * trace[], int size, int start=0) { + nvDebug( "\nDumping stacktrace:\n" ); + + Array lines; + writeStackTrace(trace, size, 1, lines); + + for (uint i = 0; i < lines.count(); i++) { + nvDebug(lines[i]); + delete lines[i]; + } + + nvDebug("\n"); + } + #endif // defined(HAVE_EXECINFO_H) static void * callerAddress(void * secret) @@ -818,6 +833,7 @@ int nvAbort(const char * exp, const char * file, int line, const char * func/*=N // Abnormal termination. Create mini dump and output call stack. void debug::terminate(int code) { +#if NV_OS_WIN32 EnterCriticalSection(&s_handler_critical_section); writeMiniDump(NULL); @@ -843,6 +859,7 @@ void debug::terminate(int code) } LeaveCriticalSection(&s_handler_critical_section); +#endif exit(code); } @@ -908,6 +925,7 @@ void debug::resetAssertHandler() } +#if NV_OS_WIN32 #if USE_SEPARATE_THREAD static void initHandlerThread() @@ -951,7 +969,8 @@ static void shutHandlerThread() { // @@ Free stuff. Terminate thread. } -#endif +#endif // USE_SEPARATE_THREAD +#endif // NV_OS_WIN32 // Enable signal handler. diff --git a/src/nvcore/Debug.h b/src/nvcore/Debug.h index f0f73d9..5ba868c 100644 --- a/src/nvcore/Debug.h +++ b/src/nvcore/Debug.h @@ -32,21 +32,28 @@ #else // NV_NO_ASSERT # if NV_CC_MSVC -// @@ Does this work in msvc-6 and earlier? + // @@ Does this work in msvc-6 and earlier? # define nvDebugBreak() __debugbreak() -//# define nvDebugBreak() __asm { int 3 } -# elif NV_CC_GNUC && NV_CPU_PPC && NV_OS_DARWIN -// @@ Use __builtin_trap() on GCC -# define nvDebugBreak() __asm__ volatile ("trap"); -# elif NV_CC_GNUC && NV_CPU_X86 && NV_OS_DARWIN -# define nvDebugBreak() __asm__ volatile ("int3"); -# elif NV_CC_GNUC && NV_CPU_X86 + //#define nvDebugBreak() __asm { int 3 } +# elif NV_CC_GNUC +# define nvDebugBreak() __builtin_trap() +# else +# error "No nvDebugBreak()!" +# endif + +/* +# elif NV_CC_GNUC || NV_CPU_PPC && NV_OS_DARWIN + // @@ Use __builtin_trap() on GCC +# define nvDebugBreak() __asm__ volatile ("trap") +# elif (NV_CC_GNUC || NV_CPU_X86 || NV_CPU_X86_64) && NV_OS_DARWIN +# define nvDebugBreak() __asm__ volatile ("int3") +# elif NV_CC_GNUC || NV_CPU_X86 || NV_CPU_X86_64 # define nvDebugBreak() __asm__ ( "int %0" : :"I"(3) ) # else # include -# define nvDebugBreak() raise(SIGTRAP); -// define nvDebugBreak() *((int *)(0)) = 0 +# define nvDebugBreak() raise(SIGTRAP) # endif +*/ #define nvDebugBreakOnce() \ NV_MULTI_LINE_MACRO_BEGIN \ diff --git a/src/nvcore/DefsGnucDarwin.h b/src/nvcore/DefsGnucDarwin.h index b228840..9d27730 100644 --- a/src/nvcore/DefsGnucDarwin.h +++ b/src/nvcore/DefsGnucDarwin.h @@ -25,7 +25,7 @@ #endif #define NV_FASTCALL __attribute__((fastcall)) -#define NV_FORCEINLINE __attribute__((always_inline)) +#define NV_FORCEINLINE inline __attribute__((always_inline)) #define NV_DEPRECATED __attribute__((deprecated)) #if __GNUC__ > 2 diff --git a/src/nvimage/DirectDrawSurface.cpp b/src/nvimage/DirectDrawSurface.cpp index 303d62b..0ca3d8a 100644 --- a/src/nvimage/DirectDrawSurface.cpp +++ b/src/nvimage/DirectDrawSurface.cpp @@ -343,9 +343,10 @@ namespace case DXGI_FORMAT_B8G8R8X8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: return 8*4; + default: + return 0; } - - return 0; + nvUnreachable(); } } // namespace diff --git a/src/nvimage/ErrorMetric.cpp b/src/nvimage/ErrorMetric.cpp index 06c1ea1..8c14575 100644 --- a/src/nvimage/ErrorMetric.cpp +++ b/src/nvimage/ErrorMetric.cpp @@ -349,8 +349,8 @@ float nv::averageAngularError(const FloatImage * img0, const FloatImage * img1) Vector3 n0 = Vector3(x0[i], y0[i], z0[i]); Vector3 n1 = Vector3(x1[i], y1[i], z1[i]); - n0 = 2 * n0 - Vector3(1); - n1 = 2 * n1 - Vector3(1); + n0 = 2.0f * n0 - Vector3(1); + n1 = 2.0f * n1 - Vector3(1); n0 = normalizeSafe(n0, Vector3(0), 0.0f); n1 = normalizeSafe(n1, Vector3(0), 0.0f); @@ -387,8 +387,8 @@ float nv::rmsAngularError(const FloatImage * img0, const FloatImage * img1) Vector3 n0 = Vector3(x0[i], y0[i], z0[i]); Vector3 n1 = Vector3(x1[i], y1[i], z1[i]); - n0 = 2 * n0 - Vector3(1); - n1 = 2 * n1 - Vector3(1); + n0 = 2.0f * n0 - Vector3(1); + n1 = 2.0f * n1 - Vector3(1); n0 = normalizeSafe(n0, Vector3(0), 0.0f); n1 = normalizeSafe(n1, Vector3(0), 0.0f); diff --git a/src/nvmath/Fitting.cpp b/src/nvmath/Fitting.cpp index 0106ef8..ff170d4 100644 --- a/src/nvmath/Fitting.cpp +++ b/src/nvmath/Fitting.cpp @@ -411,8 +411,8 @@ int nv::Fit::compute4Means(int n, const Vector3 *__restrict points, const float cluster[0] = centroid + mindps * principal; cluster[1] = centroid + maxdps * principal; - cluster[2] = (2 * cluster[0] + cluster[1]) / 3; - cluster[3] = (2 * cluster[1] + cluster[0]) / 3; + cluster[2] = (2.0f * cluster[0] + cluster[1]) / 3.0f; + cluster[3] = (2.0f * cluster[1] + cluster[0]) / 3.0f; // Now we have to iteratively refine the clusters. while (true) diff --git a/src/nvtt/CMakeLists.txt b/src/nvtt/CMakeLists.txt index a47b837..7289f2d 100644 --- a/src/nvtt/CMakeLists.txt +++ b/src/nvtt/CMakeLists.txt @@ -21,7 +21,7 @@ SET(NVTT_SRCS CompressionOptions.h CompressionOptions.cpp InputOptions.h InputOptions.cpp OutputOptions.h OutputOptions.cpp - TaskDispatcher.h TaskDispatcher.cpp + TaskDispatcher.h #TaskDispatcher.cpp Surface.h Surface.cpp CubeSurface.h CubeSurface.cpp cuda/CudaUtils.h cuda/CudaUtils.cpp diff --git a/src/nvtt/CubeSurface.cpp b/src/nvtt/CubeSurface.cpp index c3a3b14..f906472 100644 --- a/src/nvtt/CubeSurface.cpp +++ b/src/nvtt/CubeSurface.cpp @@ -523,6 +523,30 @@ Vector3 CubeSurface::Private::applyCosinePowerFilter(const Vector3 & filterDir, int x0 = 0, x1 = L; int y0 = 0, y1 = L; + if (false) { + // New approach? + + // For each face, we are looking for 4 planes that bound the cone. + + // All planes go through the origin. + // Plane fully determined by its normal. + // We only care about planes aligned to one axis. So, for the XY face, we have 4 planes: + + // Plane goes through origin. + // Plane normal is unit length. + + // Plane must be tangent to cone -> + // angle between plane normal and cone axis is 90 - cone angle & 90 + cone angle + // dot(N, D) == cos(90 - cone angle) + // dot(N, D) == cos(90 + cone angle) + + // Plane must contain face UV axis + + // Find the 4 planes and how they intersect the unit face, which gives us (u0,v0, u1,v1). + + // Expand uv coordinates, clamp to + } + // @@ Ugh. This is wrong, or only right when filterDir is aligned to one axis. if (false) { // uv coordinates corresponding to filterDir. diff --git a/src/nvtt/QuickCompressDXT.cpp b/src/nvtt/QuickCompressDXT.cpp index 084ad52..50bab8d 100644 --- a/src/nvtt/QuickCompressDXT.cpp +++ b/src/nvtt/QuickCompressDXT.cpp @@ -83,7 +83,7 @@ inline static void findMinMaxColorsBox(const Vector3 * block, uint num, Vector3 inline static void selectDiagonal(const Vector3 * block, uint num, Vector3 * restrict maxColor, Vector3 * restrict minColor) { - Vector3 center = (*maxColor + *minColor) * 0.5; + Vector3 center = (*maxColor + *minColor) * 0.5f; Vector2 covariance = Vector2(0.0f); for (uint i = 0; i < num; i++) @@ -714,8 +714,8 @@ void QuickCompress::compressDXT5(const ColorBlock & rgba, BlockDXT5 * dxtBlock, void QuickCompress::outputBlock4(const ColorSet & set, const Vector3 & start, const Vector3 & end, BlockDXT1 * block) { - Vector3 minColor = start * 255; - Vector3 maxColor = end * 255; + Vector3 minColor = start * 255.0f; + Vector3 maxColor = end * 255.0f; uint16 color0 = roundAndExpand(&maxColor); uint16 color1 = roundAndExpand(&minColor); @@ -727,15 +727,15 @@ void QuickCompress::outputBlock4(const ColorSet & set, const Vector3 & start, co block->col0 = Color16(color0); block->col1 = Color16(color1); - block->indices = computeIndices4(set, maxColor / 255, minColor / 255); + block->indices = computeIndices4(set, maxColor / 255.0f, minColor / 255.0f); //optimizeEndPoints4(set, block); } void QuickCompress::outputBlock3(const ColorSet & set, const Vector3 & start, const Vector3 & end, BlockDXT1 * block) { - Vector3 minColor = start * 255; - Vector3 maxColor = end * 255; + Vector3 minColor = start * 255.0f; + Vector3 maxColor = end * 255.0f; uint16 color0 = roundAndExpand(&minColor); uint16 color1 = roundAndExpand(&maxColor); @@ -747,7 +747,7 @@ void QuickCompress::outputBlock3(const ColorSet & set, const Vector3 & start, co block->col0 = Color16(color0); block->col1 = Color16(color1); - block->indices = computeIndices3(set, maxColor / 255, minColor / 255); + block->indices = computeIndices3(set, maxColor / 255.0f, minColor / 255.0f); //optimizeEndPoints3(set, block); } diff --git a/src/nvtt/tests/hdrtest.cpp b/src/nvtt/tests/hdrtest.cpp index 09884d8..8c98582 100644 --- a/src/nvtt/tests/hdrtest.cpp +++ b/src/nvtt/tests/hdrtest.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include // free #include // memcpy diff --git a/src/nvtt/tools/ddsview.cpp b/src/nvtt/tools/ddsview.cpp index 3296d62..86a67fc 100644 --- a/src/nvtt/tools/ddsview.cpp +++ b/src/nvtt/tools/ddsview.cpp @@ -105,6 +105,7 @@ GLuint createTexture(nv::DirectDrawSurface & dds) else { // Add support for cubemaps. } + return tex; } void drawQuad() diff --git a/src/nvtt/tools/thumbnailer.cpp b/src/nvtt/tools/thumbnailer.cpp index 69c9efb..7b9690a 100644 --- a/src/nvtt/tools/thumbnailer.cpp +++ b/src/nvtt/tools/thumbnailer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include