From fd48da23146f9127c94fb34ba657563b63668d3c Mon Sep 17 00:00:00 2001 From: castano Date: Wed, 21 May 2014 17:47:06 +0000 Subject: [PATCH] Fixes issue 204. --- trunk/src/nvcore/DefsGnucDarwin.h | 20 ---------------- trunk/src/nvcore/DefsGnucLinux.h | 26 +++------------------ trunk/src/nvimage/DirectDrawSurface.cpp | 1 + trunk/src/nvmath/Fitting.cpp | 31 +++++++++++++------------ trunk/src/nvtt/CMakeLists.txt | 8 +++---- trunk/src/nvtt/bc7/avpcl.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode0.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode1.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode2.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode3.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode4.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode5.cpp | 1 + trunk/src/nvtt/bc7/avpcl_mode6.cpp | 2 +- trunk/src/nvtt/bc7/avpcl_mode7.cpp | 1 + trunk/src/nvtt/bc7/utils.h | 2 +- trunk/src/nvtt/tests/CMakeLists.txt | 4 ++-- trunk/src/nvtt/tools/CMakeLists.txt | 12 +++++----- 17 files changed, 42 insertions(+), 72 deletions(-) diff --git a/trunk/src/nvcore/DefsGnucDarwin.h b/trunk/src/nvcore/DefsGnucDarwin.h index 6a3a52b..75dc027 100644 --- a/trunk/src/nvcore/DefsGnucDarwin.h +++ b/trunk/src/nvcore/DefsGnucDarwin.h @@ -39,8 +39,6 @@ #define NV_NOINLINE __attribute__((noinline)) - - // Define __FUNC__ properly. #if __STDC_VERSION__ < 199901L # if __GNUC__ >= 2 @@ -53,21 +51,3 @@ #endif #define restrict __restrict__ - -/* -// Type definitions -typedef uint8_t uint8; -typedef int8_t int8; - -typedef uint16_t uint16; -typedef int16_t int16; - -typedef uint32_t uint32; -typedef int32_t int32; - -typedef uint64_t uint64; -typedef int64_t int64; - -// Aliases -typedef uint32 uint; -*/ diff --git a/trunk/src/nvcore/DefsGnucLinux.h b/trunk/src/nvcore/DefsGnucLinux.h index f8e6f80..79a64de 100644 --- a/trunk/src/nvcore/DefsGnucLinux.h +++ b/trunk/src/nvcore/DefsGnucLinux.h @@ -3,12 +3,12 @@ #endif #include // uint8_t, int8_t, ... uintptr_t -#include // operator new, size_t, NULL +#include // operator new, size_t, NULL // Function linkage #define DLL_IMPORT #if __GNUC__ >= 4 -# define DLL_EXPORT __attribute__((visibility("default"))) +# define DLL_EXPORT __attribute__((visibility("default"))) # define DLL_EXPORT_CLASS DLL_EXPORT #else # define DLL_EXPORT @@ -25,11 +25,10 @@ #endif #define NV_FASTCALL __attribute__((fastcall)) -#define NV_FORCEINLINE __attribute__((always_inline)) +#define NV_FORCEINLINE __attribute__((always_inline)) inline #define NV_DEPRECATED __attribute__((deprecated)) #define NV_THREAD_LOCAL __thread - #if __GNUC__ > 2 #define NV_PURE __attribute__((pure)) #define NV_CONST __attribute__((const)) @@ -52,22 +51,3 @@ #endif #define restrict __restrict__ - -/* -// Type definitions -typedef unsigned char uint8; -typedef signed char int8; - -typedef unsigned short uint16; -typedef signed short int16; - -typedef unsigned int uint32; -typedef signed int int32; - -typedef unsigned long long uint64; -typedef signed long long int64; - -// Aliases -typedef uint32 uint; -*/ - diff --git a/trunk/src/nvimage/DirectDrawSurface.cpp b/trunk/src/nvimage/DirectDrawSurface.cpp index 9788b62..c2531ab 100644 --- a/trunk/src/nvimage/DirectDrawSurface.cpp +++ b/trunk/src/nvimage/DirectDrawSurface.cpp @@ -30,6 +30,7 @@ #include "nvcore/Debug.h" #include "nvcore/Utils.h" // max #include "nvcore/StdStream.h" +#include "nvmath/Vector.inl" #include // memset diff --git a/trunk/src/nvmath/Fitting.cpp b/trunk/src/nvmath/Fitting.cpp index 453ad9b..3cbb712 100644 --- a/trunk/src/nvmath/Fitting.cpp +++ b/trunk/src/nvmath/Fitting.cpp @@ -8,6 +8,7 @@ #include // FLT_MAX #include +#include using namespace nv; @@ -498,7 +499,7 @@ static void EigenSolver3_Tridiagonal(float mat[3][3], float * diag, float * subd diag[0] = a; subd[2] = 0.f; - if ( fabs(c) >= epsilon ) + if (fabsf(c) >= epsilon) { const float ell = sqrtf(b*b+c*c); b /= ell; @@ -538,8 +539,8 @@ static bool EigenSolver3_QLAlgorithm(float mat[3][3], float * diag, float * subd int m; for (m = ell; m <= 1; m++) { - float dd = fabs(diag[m]) + fabs(diag[m+1]); - if ( fabs(subd[m]) + dd == dd ) + float dd = fabsf(diag[m]) + fabsf(diag[m+1]); + if ( fabsf(subd[m]) + dd == dd ) break; } if ( m == ell ) @@ -555,7 +556,7 @@ static bool EigenSolver3_QLAlgorithm(float mat[3][3], float * diag, float * subd for (int i = m-1; i >= ell; i--) { float f = s*subd[i], b = c*subd[i]; - if ( fabs(f) >= fabs(g) ) + if ( fabsf(f) >= fabsf(g) ) { c = g/f; r = sqrtf(c*c+1); @@ -690,7 +691,7 @@ static void EigenSolver4_Tridiagonal(float mat[4][4], float * diag, float * subd float maxElement = FLT_MAX; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) - maxElement = max(maxElement, fabs(mat[i][j])); + maxElement = max(maxElement, fabsf(mat[i][j])); float epsilon = relEpsilon * maxElement; // Iterative algorithm, works for any size of matrix but might be slower than @@ -711,7 +712,7 @@ static void EigenSolver4_Tridiagonal(float mat[4][4], float * diag, float * subd float r = sqrtf(0.5f * (alpha*alpha - A(k+1,k)*alpha)); // If r is zero, skip this column - already in tridiagonal form - if (fabs(r) < epsilon) + if (fabsf(r) < epsilon) continue; float v[n] = {}; @@ -728,12 +729,12 @@ static void EigenSolver4_Tridiagonal(float mat[4][4], float * diag, float * subd Q = mul(Q, P); } - nvDebugCheck(fabs(A(2,0)) < epsilon); - nvDebugCheck(fabs(A(0,2)) < epsilon); - nvDebugCheck(fabs(A(3,0)) < epsilon); - nvDebugCheck(fabs(A(0,3)) < epsilon); - nvDebugCheck(fabs(A(3,1)) < epsilon); - nvDebugCheck(fabs(A(1,3)) < epsilon); + nvDebugCheck(fabsf(A(2,0)) < epsilon); + nvDebugCheck(fabsf(A(0,2)) < epsilon); + nvDebugCheck(fabsf(A(3,0)) < epsilon); + nvDebugCheck(fabsf(A(0,3)) < epsilon); + nvDebugCheck(fabsf(A(3,1)) < epsilon); + nvDebugCheck(fabsf(A(1,3)) < epsilon); for (int i = 0; i < n; ++i) diag[i] = A(i,i); @@ -758,8 +759,8 @@ static bool EigenSolver4_QLAlgorithm(float mat[4][4], float * diag, float * subd int m; for (m = ell; m < 3; m++) { - float dd = fabs(diag[m]) + fabs(diag[m+1]); - if ( fabs(subd[m]) + dd == dd ) + float dd = fabsf(diag[m]) + fabsf(diag[m+1]); + if ( fabsf(subd[m]) + dd == dd ) break; } if ( m == ell ) @@ -775,7 +776,7 @@ static bool EigenSolver4_QLAlgorithm(float mat[4][4], float * diag, float * subd for (int i = m-1; i >= ell; i--) { float f = s*subd[i], b = c*subd[i]; - if ( fabs(f) >= fabs(g) ) + if ( fabsf(f) >= fabsf(g) ) { c = g/f; r = sqrtf(c*c+1); diff --git a/trunk/src/nvtt/CMakeLists.txt b/trunk/src/nvtt/CMakeLists.txt index 7b70860..6cbee94 100644 --- a/trunk/src/nvtt/CMakeLists.txt +++ b/trunk/src/nvtt/CMakeLists.txt @@ -1,8 +1,8 @@ PROJECT(nvtt) ADD_SUBDIRECTORY(squish) -#ADD_SUBDIRECTORY(bc6h) -#ADD_SUBDIRECTORY(bc7) +ADD_SUBDIRECTORY(bc6h) +ADD_SUBDIRECTORY(bc7) SET(NVTT_SRCS nvtt.h nvtt.cpp @@ -12,7 +12,7 @@ SET(NVTT_SRCS BlockCompressor.h BlockCompressor.cpp CompressorDX9.h CompressorDX9.cpp CompressorDX10.h CompressorDX10.cpp -# CompressorDX11.h CompressorDX11.cpp + CompressorDX11.h CompressorDX11.cpp CompressorRGB.h CompressorRGB.cpp Context.h Context.cpp QuickCompressDXT.h QuickCompressDXT.cpp @@ -47,7 +47,7 @@ ELSE(NVTT_SHARED) ADD_LIBRARY(nvtt ${NVTT_SRCS}) ENDIF(NVTT_SHARED) -TARGET_LINK_LIBRARIES(nvtt ${LIBS} nvcore nvmath nvimage nvthread squish) +TARGET_LINK_LIBRARIES(nvtt ${LIBS} nvcore nvmath nvimage nvthread squish bc6h bc7) INSTALL(TARGETS nvtt RUNTIME DESTINATION bin diff --git a/trunk/src/nvtt/bc7/avpcl.cpp b/trunk/src/nvtt/bc7/avpcl.cpp index af017b4..c4dcee5 100644 --- a/trunk/src/nvtt/bc7/avpcl.cpp +++ b/trunk/src/nvtt/bc7/avpcl.cpp @@ -17,6 +17,7 @@ See the License for the specific language governing permissions and limitations #include "nvcore/Debug.h" #include "nvmath/Vector.inl" #include +#include using namespace nv; using namespace AVPCL; diff --git a/trunk/src/nvtt/bc7/avpcl_mode0.cpp b/trunk/src/nvtt/bc7/avpcl_mode0.cpp index ba79447..3464ebc 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode0.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode0.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include #include "shapes_three.h" diff --git a/trunk/src/nvtt/bc7/avpcl_mode1.cpp b/trunk/src/nvtt/bc7/avpcl_mode1.cpp index 8ee3570..2141a0d 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode1.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode1.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include #include "shapes_two.h" diff --git a/trunk/src/nvtt/bc7/avpcl_mode2.cpp b/trunk/src/nvtt/bc7/avpcl_mode2.cpp index bff191a..f6a5909 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode2.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode2.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include #include "shapes_three.h" diff --git a/trunk/src/nvtt/bc7/avpcl_mode3.cpp b/trunk/src/nvtt/bc7/avpcl_mode3.cpp index 4a2f80a..f4e0af5 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode3.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode3.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include #include "shapes_two.h" diff --git a/trunk/src/nvtt/bc7/avpcl_mode4.cpp b/trunk/src/nvtt/bc7/avpcl_mode4.cpp index 80ccdee..7ed5585 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode4.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode4.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include using namespace nv; using namespace AVPCL; diff --git a/trunk/src/nvtt/bc7/avpcl_mode5.cpp b/trunk/src/nvtt/bc7/avpcl_mode5.cpp index fb1c035..f494da0 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode5.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode5.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include using namespace nv; using namespace AVPCL; diff --git a/trunk/src/nvtt/bc7/avpcl_mode6.cpp b/trunk/src/nvtt/bc7/avpcl_mode6.cpp index c168890..d63e5d2 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode6.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode6.cpp @@ -24,7 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include - +#include using namespace nv; using namespace AVPCL; diff --git a/trunk/src/nvtt/bc7/avpcl_mode7.cpp b/trunk/src/nvtt/bc7/avpcl_mode7.cpp index ea9e0ec..fe72d51 100644 --- a/trunk/src/nvtt/bc7/avpcl_mode7.cpp +++ b/trunk/src/nvtt/bc7/avpcl_mode7.cpp @@ -24,6 +24,7 @@ See the License for the specific language governing permissions and limitations #include "utils.h" #include "endpts.h" #include +#include #include "shapes_two.h" diff --git a/trunk/src/nvtt/bc7/utils.h b/trunk/src/nvtt/bc7/utils.h index 4e213a5..149a44e 100644 --- a/trunk/src/nvtt/bc7/utils.h +++ b/trunk/src/nvtt/bc7/utils.h @@ -45,7 +45,7 @@ public: static float metric3premult_alphain(nv::Vector3::Arg rgb0, nv::Vector3::Arg rgb1, int rotatemode); static float metric1premult(float rgb0, float a0, float rgb1, float a1, int rotatemode); - static float Utils::premult(float r, float a); + static float premult(float r, float a); // quantization and unquantization static int unquantize(int q, int prec); diff --git a/trunk/src/nvtt/tests/CMakeLists.txt b/trunk/src/nvtt/tests/CMakeLists.txt index 069ccbf..db3b936 100644 --- a/trunk/src/nvtt/tests/CMakeLists.txt +++ b/trunk/src/nvtt/tests/CMakeLists.txt @@ -1,6 +1,6 @@ ADD_EXECUTABLE(filtertest filtertest.cpp ../tools/cmdline.h) -TARGET_LINK_LIBRARIES(filtertest nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(filtertest nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvtestsuite testsuite.cpp) TARGET_LINK_LIBRARIES(nvtestsuite nvcore nvmath nvimage nvtt) @@ -13,7 +13,7 @@ ADD_TEST(NVTT.TestSuite.Epic.nocuda nvtestsuite -path ${NV_SOURCE_DIR}/data/test IF (CUDA_FOUND) ADD_EXECUTABLE(driverapitest driverapi.cpp) - TARGET_LINK_LIBRARIES(driverapitest nvcore nvmath nvimage) + TARGET_LINK_LIBRARIES(driverapitest nvcore nvmath nvimage nvtt) ENDIF (CUDA_FOUND) ADD_EXECUTABLE(imperativeapi imperativeapi.cpp) diff --git a/trunk/src/nvtt/tools/CMakeLists.txt b/trunk/src/nvtt/tools/CMakeLists.txt index 20f80ee..02c6d46 100644 --- a/trunk/src/nvtt/tools/CMakeLists.txt +++ b/trunk/src/nvtt/tools/CMakeLists.txt @@ -3,19 +3,19 @@ ADD_EXECUTABLE(nvcompress compress.cpp cmdline.h) TARGET_LINK_LIBRARIES(nvcompress nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvdecompress decompress.cpp cmdline.h) -TARGET_LINK_LIBRARIES(nvdecompress nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(nvdecompress nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvddsinfo ddsinfo.cpp cmdline.h) -TARGET_LINK_LIBRARIES(nvddsinfo nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(nvddsinfo nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvimgdiff imgdiff.cpp cmdline.h) -TARGET_LINK_LIBRARIES(nvimgdiff nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(nvimgdiff nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvassemble assemble.cpp cmdline.h) -TARGET_LINK_LIBRARIES(nvassemble nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(nvassemble nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvzoom resize.cpp cmdline.h) -TARGET_LINK_LIBRARIES(nvzoom nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(nvzoom nvcore nvmath nvimage nvtt) SET(TOOLS nvcompress nvdecompress nvddsinfo nvassemble nvzoom) @@ -28,7 +28,7 @@ ENDIF(GLEW_FOUND AND GLUT_FOUND AND OPENGL_FOUND) ADD_EXECUTABLE(nv-gnome-thumbnailer thumbnailer.cpp cmdline.h) -TARGET_LINK_LIBRARIES(nv-gnome-thumbnailer nvcore nvmath nvimage) +TARGET_LINK_LIBRARIES(nv-gnome-thumbnailer nvcore nvmath nvimage nvtt) SET(TOOLS ${TOOLS} nv-gnome-thumbnailer)