From 5943e8f42f958fe160646e25e90e4742c5575880 Mon Sep 17 00:00:00 2001 From: castano Date: Wed, 4 Mar 2009 07:04:32 +0000 Subject: [PATCH] Fix errors on ibook G4. --- src/nvcore/Containers.h | 29 +++++++++++++++++++++++++++-- src/nvtt/squish/simd_ve.h | 2 +- src/nvtt/tests/CMakeLists.txt | 8 +++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/nvcore/Containers.h b/src/nvcore/Containers.h index 69d3c4d..08c60e9 100644 --- a/src/nvcore/Containers.h +++ b/src/nvcore/Containers.h @@ -595,18 +595,43 @@ namespace nv template > class NVCORE_CLASS HashMap { - NV_FORBID_COPY(HashMap) public: /// Default ctor. HashMap() : entry_count(0), size_mask(-1), table(NULL) { } + // Copy ctor. + HashMap(const HashMap & map) : entry_count(0), size_mask(-1), table(NULL) + { + operator = (map); + } + /// Ctor with size hint. explicit HashMap(int size_hint) : entry_count(0), size_mask(-1), table(NULL) { setCapacity(size_hint); } /// Dtor. ~HashMap() { clear(); } - + + // Assignment operator. + void operator= (const HashMap & map) + { + clear(); + + if (entry_count > 0) + { + entry_count = map.entry_count; + size_mask = map.size_mask; + + const uint size = uint(size_mask + 1); + table = (Entry *)nv::mem::malloc(sizeof(Entry) * size); + + // Copy elements using copy ctor. + for (uint i = 0; i < size; i++) + { + new (table + i) Entry(map.table[i]); + } + } + } /// Set a new or existing value under the key, to the value. void set(const T& key, const U& value) diff --git a/src/nvtt/squish/simd_ve.h b/src/nvtt/squish/simd_ve.h index 0f90a44..2be08fa 100644 --- a/src/nvtt/squish/simd_ve.h +++ b/src/nvtt/squish/simd_ve.h @@ -31,7 +31,7 @@ #undef bool #endif -namespace squish { +namespace nvsquish { #define VEC4_CONST( X ) Vec4( ( vector float )( X ) ) diff --git a/src/nvtt/tests/CMakeLists.txt b/src/nvtt/tests/CMakeLists.txt index c8c5017..3cbb717 100644 --- a/src/nvtt/tests/CMakeLists.txt +++ b/src/nvtt/tests/CMakeLists.txt @@ -5,13 +5,15 @@ TARGET_LINK_LIBRARIES(filtertest nvcore nvmath nvimage) ADD_EXECUTABLE(nvtestsuite stress.cpp) TARGET_LINK_LIBRARIES(nvtestsuite nvcore nvmath nvimage nvtt) -ADD_EXECUTABLE(driverapitest driverapi.cpp) -TARGET_LINK_LIBRARIES(driverapitest nvcore nvmath nvimage) +IF (CUDA_FOUND) + ADD_EXECUTABLE(driverapitest driverapi.cpp) + TARGET_LINK_LIBRARIES(driverapitest nvcore nvmath nvimage) +ENDIF (CUDA_FOUND) ADD_EXECUTABLE(imperativeapi imperativeapi.cpp) TARGET_LINK_LIBRARIES(imperativeapi nvcore nvmath nvimage nvtt) -INSTALL(TARGETS nvtestsuite driverapitest DESTINATION bin) +INSTALL(TARGETS nvtestsuite DESTINATION bin) #include_directories("/usr/include/ffmpeg/") #ADD_EXECUTABLE(nvmpegenc tools/mpegenc.cpp tools/cmdline.h)