Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
624c5bd316 |
@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0)
|
||||||
PROJECT(NV)
|
PROJECT(NV)
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
|
|
||||||
@ -16,13 +16,6 @@ MESSAGE(STATUS "Setting optimal options")
|
|||||||
MESSAGE(STATUS " Processor: ${NV_SYSTEM_PROCESSOR}")
|
MESSAGE(STATUS " Processor: ${NV_SYSTEM_PROCESSOR}")
|
||||||
MESSAGE(STATUS " Compiler Flags: ${CMAKE_CXX_FLAGS}")
|
MESSAGE(STATUS " Compiler Flags: ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
IF(NVTT_SHARED)
|
|
||||||
SET(NVCORE_SHARED TRUE)
|
|
||||||
SET(NVMATH_SHARED TRUE)
|
|
||||||
SET(NVIMAGE_SHARED TRUE)
|
|
||||||
ENDIF(NVTT_SHARED)
|
|
||||||
|
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(src)
|
ADD_SUBDIRECTORY(src)
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
NVIDIA Texture Tools version 2.0.5
|
|
||||||
* Fix error in single color compressor. Fixes issue 66.
|
|
||||||
* Detect mismatch between CUDA runtime and driver, and disable CUDA in that case.
|
|
||||||
* Fix cmake files when compiling NVTT as a shared library.
|
|
||||||
* When linking nvtt dynamically on unix, link all libraries dynamically.
|
|
||||||
* Select fastest CUDA device.
|
|
||||||
|
|
||||||
NVIDIA Texture Tools version 2.0.4
|
NVIDIA Texture Tools version 2.0.4
|
||||||
* Fix error in RGB format output; reported by jonsoh. See issue 49.
|
* Fix error in RGB format output; reported by jonsoh. See issue 49.
|
||||||
* Added support RGB format dithering by jonsoh. Fixes issue 50 and 51.
|
* Added support RGB format dithering by jonsoh. Fixes issue 50 and 51.
|
||||||
|
@ -57,7 +57,7 @@ MARK_AS_ADVANCED (CUDA_FOUND CUDA_COMPILER CUDA_RUNTIME_LIBRARY)
|
|||||||
|
|
||||||
|
|
||||||
#SET(CUDA_OPTIONS "-ncfe")
|
#SET(CUDA_OPTIONS "-ncfe")
|
||||||
SET(CUDA_OPTIONS "--host-compilation=C")
|
SET(CUDA_OPTIONS "")
|
||||||
|
|
||||||
IF (CUDA_EMULATION)
|
IF (CUDA_EMULATION)
|
||||||
SET (CUDA_OPTIONS "${CUDA_OPTIONS} -deviceemu")
|
SET (CUDA_OPTIONS "${CUDA_OPTIONS} -deviceemu")
|
||||||
|
2
configure
vendored
2
configure
vendored
@ -53,7 +53,7 @@ echo "-- Configuring nvidia-texture-tools "`cat VERSION`
|
|||||||
|
|
||||||
mkdir -p ./build
|
mkdir -p ./build
|
||||||
cd ./build
|
cd ./build
|
||||||
$CMAKE .. -DNVTT_SHARED=1 -DCMAKE_BUILD_TYPE=$build -DCMAKE_INSTALL_PREFIX=$prefix -G "Unix Makefiles" || exit 1
|
$CMAKE .. -DCMAKE_BUILD_TYPE=$build -DCMAKE_INSTALL_PREFIX=$prefix -G "Unix Makefiles" || exit 1
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -281,10 +281,6 @@
|
|||||||
RelativePath="..\..\..\src\nvcore\Debug.cpp"
|
RelativePath="..\..\..\src\nvcore\Debug.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\..\src\nvcore\Library.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\src\nvcore\Memory.cpp"
|
RelativePath="..\..\..\src\nvcore\Memory.cpp"
|
||||||
>
|
>
|
||||||
@ -319,10 +315,6 @@
|
|||||||
RelativePath="..\..\..\src\nvcore\DefsVcWin32.h"
|
RelativePath="..\..\..\src\nvcore\DefsVcWin32.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\..\src\nvcore\Library.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\src\nvcore\Memory.h"
|
RelativePath="..\..\..\src\nvcore\Memory.h"
|
||||||
>
|
>
|
||||||
|
@ -53,8 +53,8 @@ END
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 2,0,5,0
|
FILEVERSION 2,0,4,0
|
||||||
PRODUCTVERSION 2,0,5,0
|
PRODUCTVERSION 2,0,4,0
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -71,12 +71,12 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "NVIDIA Corporation"
|
VALUE "CompanyName", "NVIDIA Corporation"
|
||||||
VALUE "FileDescription", "NVIDIA Texture Tools Dynamic Link Library"
|
VALUE "FileDescription", "NVIDIA Texture Tools Dynamic Link Library"
|
||||||
VALUE "FileVersion", "2, 0, 5, 0"
|
VALUE "FileVersion", "2, 0, 4, 0"
|
||||||
VALUE "InternalName", "nvtt"
|
VALUE "InternalName", "nvtt"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2007"
|
VALUE "LegalCopyright", "Copyright (C) 2007"
|
||||||
VALUE "OriginalFilename", "nvtt.dll"
|
VALUE "OriginalFilename", "nvtt.dll"
|
||||||
VALUE "ProductName", "NVIDIA Texture Tools Dynamic Link Library"
|
VALUE "ProductName", "NVIDIA Texture Tools Dynamic Link Library"
|
||||||
VALUE "ProductVersion", "2, 0, 5, 0"
|
VALUE "ProductVersion", "2, 0, 4, 0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
@ -19,19 +19,13 @@ SET(CORE_SRCS
|
|||||||
TextWriter.h
|
TextWriter.h
|
||||||
TextWriter.cpp
|
TextWriter.cpp
|
||||||
Radix.h
|
Radix.h
|
||||||
Radix.cpp
|
Radix.cpp)
|
||||||
Library.h
|
|
||||||
Library.cpp)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
# targets
|
# targets
|
||||||
ADD_DEFINITIONS(-DNVCORE_EXPORTS)
|
ADD_DEFINITIONS(-DNVCORE_EXPORTS)
|
||||||
|
|
||||||
IF(UNIX)
|
|
||||||
SET(LIBS ${LIBS} ${CMAKE_DL_LIBS})
|
|
||||||
ENDIF(UNIX)
|
|
||||||
|
|
||||||
IF(NVCORE_SHARED)
|
IF(NVCORE_SHARED)
|
||||||
ADD_LIBRARY(nvcore SHARED ${CORE_SRCS})
|
ADD_LIBRARY(nvcore SHARED ${CORE_SRCS})
|
||||||
ELSE(NVCORE_SHARED)
|
ELSE(NVCORE_SHARED)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NV_OS_LINUX && defined(HAVE_EXECINFO_H)
|
#if NV_OS_LINUX && defined(HAVE_EXECINFO_H)
|
||||||
# include <execinfo.h> // backtrace
|
# include <execinfo.h>
|
||||||
# if NV_CC_GNUC // defined(HAVE_CXXABI_H)
|
# if NV_CC_GNUC // defined(HAVE_CXXABI_H)
|
||||||
# include <cxxabi.h>
|
# include <cxxabi.h>
|
||||||
# endif
|
# endif
|
||||||
@ -39,13 +39,6 @@
|
|||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/sysctl.h> // sysctl
|
# include <sys/sysctl.h> // sysctl
|
||||||
# include <ucontext.h>
|
# include <ucontext.h>
|
||||||
# undef HAVE_EXECINFO_H
|
|
||||||
# if defined(HAVE_EXECINFO_H) // only after OSX 10.5
|
|
||||||
# include <execinfo.h> // backtrace
|
|
||||||
# if NV_CC_GNUC // defined(HAVE_CXXABI_H)
|
|
||||||
# include <cxxabi.h>
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdexcept> // std::runtime_error
|
#include <stdexcept> // std::runtime_error
|
||||||
@ -135,10 +128,6 @@ namespace
|
|||||||
|
|
||||||
#if defined(HAVE_EXECINFO_H) // NV_OS_LINUX
|
#if defined(HAVE_EXECINFO_H) // NV_OS_LINUX
|
||||||
|
|
||||||
static bool nvHasStackTrace() {
|
|
||||||
return backtrace != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nvPrintStackTrace(void * trace[], int size, int start=0) {
|
static void nvPrintStackTrace(void * trace[], int size, int start=0) {
|
||||||
char ** string_array = backtrace_symbols(trace, size);
|
char ** string_array = backtrace_symbols(trace, size);
|
||||||
|
|
||||||
@ -177,36 +166,24 @@ namespace
|
|||||||
|
|
||||||
static void * callerAddress(void * secret)
|
static void * callerAddress(void * secret)
|
||||||
{
|
{
|
||||||
# if NV_OS_DARWIN
|
# if NV_OS_DARWIN && NV_CPU_PPC
|
||||||
# if defined(_STRUCT_MCONTEXT)
|
ucontext_t * ucp = (ucontext_t *)secret;
|
||||||
# if NV_CPU_PPC
|
return (void *) ucp->uc_mcontext->ss.srr0;
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
# elif NV_OS_DARWIN && NV_CPU_X86
|
||||||
return (void *) ucp->uc_mcontext->__ss.__srr0;
|
ucontext_t * ucp = (ucontext_t *)secret;
|
||||||
# elif NV_CPU_X86
|
return (void *) ucp->uc_mcontext->ss.eip;
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
# elif NV_CPU_X86_64
|
||||||
return (void *) ucp->uc_mcontext->__ss.__eip;
|
// #define REG_RIP REG_INDEX(rip) // seems to be 16
|
||||||
# endif
|
ucontext_t * ucp = (ucontext_t *)secret;
|
||||||
# else
|
return (void *)ucp->uc_mcontext.gregs[REG_RIP];
|
||||||
# if NV_CPU_PPC
|
# elif NV_CPU_X86
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
ucontext_t * ucp = (ucontext_t *)secret;
|
||||||
return (void *) ucp->uc_mcontext->ss.srr0;
|
return (void *)ucp->uc_mcontext.gregs[14/*REG_EIP*/];
|
||||||
# elif NV_CPU_X86
|
# elif NV_CPU_PPC
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
ucontext_t * ucp = (ucontext_t *)secret;
|
||||||
return (void *) ucp->uc_mcontext->ss.eip;
|
return (void *) ucp->uc_mcontext.regs->nip;
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# if NV_CPU_X86_64
|
return NULL;
|
||||||
// #define REG_RIP REG_INDEX(rip) // seems to be 16
|
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
|
||||||
return (void *)ucp->uc_mcontext.gregs[REG_RIP];
|
|
||||||
# elif NV_CPU_X86
|
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
|
||||||
return (void *)ucp->uc_mcontext.gregs[14/*REG_EIP*/];
|
|
||||||
# elif NV_CPU_PPC
|
|
||||||
ucontext_t * ucp = (ucontext_t *)secret;
|
|
||||||
return (void *) ucp->uc_mcontext.regs->nip;
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// How to obtain the instruction pointers in different platforms, from mlton's source code.
|
// How to obtain the instruction pointers in different platforms, from mlton's source code.
|
||||||
@ -251,18 +228,17 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if defined(HAVE_EXECINFO_H)
|
# if defined(HAVE_EXECINFO_H)
|
||||||
if (nvHasStackTrace()) // in case of weak linking
|
|
||||||
{
|
|
||||||
void * trace[64];
|
|
||||||
int size = backtrace(trace, 64);
|
|
||||||
|
|
||||||
if (pnt != NULL) {
|
void * trace[64];
|
||||||
// Overwrite sigaction with caller's address.
|
int size = backtrace(trace, 64);
|
||||||
trace[1] = pnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
nvPrintStackTrace(trace, size, 1);
|
if (pnt != NULL) {
|
||||||
|
// Overwrite sigaction with caller's address.
|
||||||
|
trace[1] = pnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvPrintStackTrace(trace, size, 1);
|
||||||
|
|
||||||
# endif // defined(HAVE_EXECINFO_H)
|
# endif // defined(HAVE_EXECINFO_H)
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -397,12 +373,9 @@ namespace
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(HAVE_EXECINFO_H)
|
# if defined(HAVE_EXECINFO_H)
|
||||||
if (nvHasStackTrace())
|
void * trace[64];
|
||||||
{
|
int size = backtrace(trace, 64);
|
||||||
void * trace[64];
|
nvPrintStackTrace(trace, size, 3);
|
||||||
int size = backtrace(trace, 64);
|
|
||||||
nvPrintStackTrace(trace, size, 3);
|
|
||||||
}
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Exit cleanly.
|
// Exit cleanly.
|
||||||
@ -449,12 +422,9 @@ void NV_CDECL nvDebug(const char *msg, ...)
|
|||||||
void debug::dumpInfo()
|
void debug::dumpInfo()
|
||||||
{
|
{
|
||||||
#if !NV_OS_WIN32 && defined(HAVE_SIGNAL_H) && defined(HAVE_EXECINFO_H)
|
#if !NV_OS_WIN32 && defined(HAVE_SIGNAL_H) && defined(HAVE_EXECINFO_H)
|
||||||
if (nvHasStackTrace())
|
void * trace[64];
|
||||||
{
|
int size = backtrace(trace, 64);
|
||||||
void * trace[64];
|
nvPrintStackTrace(trace, size, 1);
|
||||||
int size = backtrace(trace, 64);
|
|
||||||
nvPrintStackTrace(trace, size, 1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
#error "Do not include this file directly."
|
#error "Do not include this file directly."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h> // uint8_t, int8_t, ...
|
#include <stdlib.h> // uint8_t, int8_t, ...
|
||||||
|
|
||||||
|
|
||||||
// Function linkage
|
// Function linkage
|
||||||
#define DLL_IMPORT
|
#define DLL_IMPORT
|
||||||
|
@ -19,9 +19,7 @@
|
|||||||
|
|
||||||
// Set standard function names.
|
// Set standard function names.
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#if _MSC_VER < 1500
|
#define vsnprintf _vsnprintf
|
||||||
# define vsnprintf _vsnprintf
|
|
||||||
#endif
|
|
||||||
#define vsscanf _vsscanf
|
#define vsscanf _vsscanf
|
||||||
#define chdir _chdir
|
#define chdir _chdir
|
||||||
#define getcwd _getcwd
|
#define getcwd _getcwd
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
#include "Library.h"
|
|
||||||
#include "Debug.h"
|
|
||||||
|
|
||||||
#if NV_OS_WIN32
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#define VC_EXTRALEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void * nvLoadLibrary(const char * name)
|
|
||||||
{
|
|
||||||
#if NV_OS_WIN32
|
|
||||||
return (void *)LoadLibraryExA( name, NULL, 0 );
|
|
||||||
#else
|
|
||||||
return dlopen(name, RTLD_LAZY);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void nvUnloadLibrary(void * handle)
|
|
||||||
{
|
|
||||||
nvDebugCheck(handle != NULL);
|
|
||||||
#if NV_OS_WIN32
|
|
||||||
FreeLibrary((HMODULE)handle);
|
|
||||||
#else
|
|
||||||
dlclose(handle);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void * nvBindSymbol(void * handle, const char * symbol)
|
|
||||||
{
|
|
||||||
#if NV_OS_WIN32
|
|
||||||
return (void *)GetProcAddress((HMODULE)handle, symbol);
|
|
||||||
#else
|
|
||||||
return (void *)dlsym(handle, symbol);
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
// This code is in the public domain -- castano@gmail.com
|
|
||||||
|
|
||||||
#ifndef NV_CORE_LIBRARY_H
|
|
||||||
#define NV_CORE_LIBRARY_H
|
|
||||||
|
|
||||||
#include <nvcore/nvcore.h>
|
|
||||||
|
|
||||||
#if NV_OS_WIN32
|
|
||||||
#define LIBRARY_NAME(name) #name ".dll"
|
|
||||||
#elif NV_OS_DARWIN
|
|
||||||
#define NV_LIBRARY_NAME(name) "lib" #name ".dylib"
|
|
||||||
#else
|
|
||||||
#define NV_LIBRARY_NAME(name) "lib" #name ".so"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NVCORE_API void * nvLoadLibrary(const char * name);
|
|
||||||
NVCORE_API void nvUnloadLibrary(void * lib);
|
|
||||||
NVCORE_API void * nvBindSymbol(void * lib, const char * symbol);
|
|
||||||
|
|
||||||
class NVCORE_CLASS Library
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Library(const char * name)
|
|
||||||
{
|
|
||||||
handle = nvLoadLibrary(name);
|
|
||||||
}
|
|
||||||
~Library()
|
|
||||||
{
|
|
||||||
if (isValid())
|
|
||||||
{
|
|
||||||
nvUnloadLibrary(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isValid() const
|
|
||||||
{
|
|
||||||
return handle != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * bindSymbol(const char * symbol)
|
|
||||||
{
|
|
||||||
return nvBindSymbol(handle, symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void * handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NV_CORE_LIBRARY_H
|
|
@ -24,7 +24,7 @@ __forceinline void nvPrefetch(const void * mem)
|
|||||||
#else // NV_CC_MSVC
|
#else // NV_CC_MSVC
|
||||||
|
|
||||||
// do nothing in other case.
|
// do nothing in other case.
|
||||||
#define nvPrefetch(ptr)
|
#define piPrefetch(ptr)
|
||||||
|
|
||||||
#endif // NV_CC_MSVC
|
#endif // NV_CC_MSVC
|
||||||
|
|
||||||
|
@ -43,11 +43,8 @@ public:
|
|||||||
|
|
||||||
/** Delete owned pointer and assign new one. */
|
/** Delete owned pointer and assign new one. */
|
||||||
void operator=( T * p ) {
|
void operator=( T * p ) {
|
||||||
if (p != m_ptr)
|
delete m_ptr;
|
||||||
{
|
m_ptr = p;
|
||||||
delete m_ptr;
|
|
||||||
m_ptr = p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Member access. */
|
/** Member access. */
|
||||||
@ -252,14 +249,14 @@ public:
|
|||||||
/** -> operator. */
|
/** -> operator. */
|
||||||
BaseClass * operator -> () const
|
BaseClass * operator -> () const
|
||||||
{
|
{
|
||||||
nvCheck( m_ptr != NULL );
|
piCheck( m_ptr != NULL );
|
||||||
return m_ptr;
|
return m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** * operator. */
|
/** * operator. */
|
||||||
BaseClass & operator*() const
|
BaseClass & operator*() const
|
||||||
{
|
{
|
||||||
nvCheck( m_ptr != NULL );
|
piCheck( m_ptr != NULL );
|
||||||
return *m_ptr;
|
return *m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace nv
|
|||||||
|
|
||||||
uint strHash(const char * str, uint h) NV_PURE;
|
uint strHash(const char * str, uint h) NV_PURE;
|
||||||
|
|
||||||
/// String hash based on Bernstein's hash.
|
/// String hash vased on Bernstein's hash.
|
||||||
inline uint strHash(const char * data, uint h = 5381)
|
inline uint strHash(const char * data, uint h = 5381)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
@ -213,12 +213,9 @@ namespace nv
|
|||||||
/// Implement value semantics.
|
/// Implement value semantics.
|
||||||
String & operator=( const String & str )
|
String & operator=( const String & str )
|
||||||
{
|
{
|
||||||
if (str.data != data)
|
release();
|
||||||
{
|
data = str.data;
|
||||||
release();
|
addRef();
|
||||||
data = str.data;
|
|
||||||
addRef();
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ DDSHeader::DDSHeader()
|
|||||||
|
|
||||||
// Store version information on the reserved header attributes.
|
// Store version information on the reserved header attributes.
|
||||||
this->reserved[9] = MAKEFOURCC('N', 'V', 'T', 'T');
|
this->reserved[9] = MAKEFOURCC('N', 'V', 'T', 'T');
|
||||||
this->reserved[10] = (2 << 16) | (0 << 8) | (5); // major.minor.revision
|
this->reserved[10] = (2 << 16) | (0 << 8) | (4); // major.minor.revision
|
||||||
|
|
||||||
this->pf.size = 32;
|
this->pf.size = 32;
|
||||||
this->pf.flags = 0;
|
this->pf.flags = 0;
|
||||||
|
@ -108,7 +108,7 @@ public:
|
|||||||
float area() const
|
float area() const
|
||||||
{
|
{
|
||||||
const Vector3 d = extents();
|
const Vector3 d = extents();
|
||||||
return 8.0f * (d.x()*d.y() + d.x()*d.z() + d.y()*d.z());
|
return 4.0f * (d.x()*d.y() + d.x()*d.z() + d.y()*d.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the volume of the box.
|
/// Get the volume of the box.
|
||||||
@ -118,14 +118,6 @@ public:
|
|||||||
return 8.0f * (d.x() * d.y() * d.z());
|
return 8.0f * (d.x() * d.y() * d.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if the box contains the given point.
|
|
||||||
bool contains(Vector3::Arg p) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
m_mins.x() < p.x() && m_mins.y() < p.y() && m_mins.z() < p.z() &&
|
|
||||||
m_maxs.x() > p.x() && m_maxs.y() > p.y() && m_maxs.z() > p.z();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Vector3 m_mins;
|
Vector3 m_mins;
|
||||||
@ -133,6 +125,15 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
/// Point inside box test.
|
||||||
|
inline bool pointInsideBox(const Box & b, Vector3::Arg p) const
|
||||||
|
{
|
||||||
|
return (m_mins.x() < p.x() && m_mins.y() < p.y() && m_mins.z() < p.z() &&
|
||||||
|
m_maxs.x() > p.x() && m_maxs.y() > p.y() && m_maxs.z() > p.z());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
} // nv namespace
|
} // nv namespace
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
|||||||
ADD_DEFINITIONS(-DNVTT_EXPORTS)
|
ADD_DEFINITIONS(-DNVTT_EXPORTS)
|
||||||
|
|
||||||
IF(NVTT_SHARED)
|
IF(NVTT_SHARED)
|
||||||
ADD_DEFINITIONS(-DNVTT_SHARED=1)
|
ADD_LIBRARY(nvtt SHARED ${DXT_SRCS})
|
||||||
ADD_LIBRARY(nvtt SHARED ${NVTT_SRCS})
|
|
||||||
ELSE(NVTT_SHARED)
|
ELSE(NVTT_SHARED)
|
||||||
ADD_LIBRARY(nvtt ${NVTT_SRCS})
|
ADD_LIBRARY(nvtt ${NVTT_SRCS})
|
||||||
ENDIF(NVTT_SHARED)
|
ENDIF(NVTT_SHARED)
|
||||||
|
@ -211,10 +211,6 @@ Compressor::Compressor() : m(*new Compressor::Private())
|
|||||||
|
|
||||||
if (m.cudaEnabled)
|
if (m.cudaEnabled)
|
||||||
{
|
{
|
||||||
// Select fastest CUDA device.
|
|
||||||
int device = cuda::getFastestDevice();
|
|
||||||
cuda::setDevice(device);
|
|
||||||
|
|
||||||
m.cuda = new CudaCompressor();
|
m.cuda = new CudaCompressor();
|
||||||
|
|
||||||
if (!m.cuda->isValid())
|
if (!m.cuda->isValid())
|
||||||
@ -241,10 +237,6 @@ void Compressor::enableCudaAcceleration(bool enable)
|
|||||||
|
|
||||||
if (m.cudaEnabled && m.cuda == NULL)
|
if (m.cudaEnabled && m.cuda == NULL)
|
||||||
{
|
{
|
||||||
// Select fastest CUDA device.
|
|
||||||
int device = cuda::getFastestDevice();
|
|
||||||
cuda::setDevice(device);
|
|
||||||
|
|
||||||
m.cuda = new CudaCompressor();
|
m.cuda = new CudaCompressor();
|
||||||
|
|
||||||
if (!m.cuda->isValid())
|
if (!m.cuda->isValid())
|
||||||
|
@ -191,9 +191,6 @@ __device__ void loadColorBlock(const uint * image, float3 colors[16], float3 sum
|
|||||||
|
|
||||||
*sameColor = (axis == make_float3(0, 0, 0));
|
*sameColor = (axis == make_float3(0, 0, 0));
|
||||||
|
|
||||||
// Single color compressor needs unweighted colors.
|
|
||||||
if (*sameColor) colors[idx] = rawColors[idx];
|
|
||||||
|
|
||||||
dps[idx] = dot(rawColors[idx], axis);
|
dps[idx] = dot(rawColors[idx], axis);
|
||||||
|
|
||||||
#if __DEVICE_EMULATION__
|
#if __DEVICE_EMULATION__
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <nvcore/Debug.h>
|
#include <nvcore/Debug.h>
|
||||||
#include <nvcore/Library.h>
|
|
||||||
#include "CudaUtils.h"
|
#include "CudaUtils.h"
|
||||||
|
|
||||||
#if defined HAVE_CUDA
|
#if defined HAVE_CUDA
|
||||||
@ -53,52 +52,23 @@ static bool isWow32()
|
|||||||
{
|
{
|
||||||
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
|
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
|
||||||
|
|
||||||
BOOL bIsWow64 = FALSE;
|
BOOL bIsWow64 = FALSE;
|
||||||
|
|
||||||
if (NULL != fnIsWow64Process)
|
if (NULL != fnIsWow64Process)
|
||||||
{
|
{
|
||||||
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
|
if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
|
||||||
{
|
{
|
||||||
// Assume 32 bits.
|
// Assume 32 bits.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !bIsWow64;
|
return !bIsWow64;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static bool isCudaDriverAvailable(uint version)
|
|
||||||
{
|
|
||||||
#if NV_OS_WIN32
|
|
||||||
Library nvcuda("nvcuda.dll");
|
|
||||||
#else
|
|
||||||
Library nvcuda(NV_LIBRARY_NAME(cuda));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!nvcuda.isValid())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version > 2000)
|
|
||||||
{
|
|
||||||
void * address = nvcuda.bindSymbol("cuStreamCreate");
|
|
||||||
if (address == NULL) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version > 2010)
|
|
||||||
{
|
|
||||||
void * address = nvcuda.bindSymbol("cuLoadDataEx");
|
|
||||||
if (address == NULL) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Determine if CUDA is available.
|
/// Determine if CUDA is available.
|
||||||
bool nv::cuda::isHardwarePresent()
|
bool nv::cuda::isHardwarePresent()
|
||||||
{
|
{
|
||||||
@ -120,12 +90,6 @@ bool nv::cuda::isHardwarePresent()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that CUDA driver matches CUDA runtime.
|
|
||||||
if (!isCudaDriverAvailable(CUDART_VERSION))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @@ Make sure that warp size == 32
|
// @@ Make sure that warp size == 32
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,35 +115,6 @@ int nv::cuda::deviceCount()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nv::cuda::getFastestDevice()
|
|
||||||
{
|
|
||||||
int max_gflops_device = 0;
|
|
||||||
#if defined HAVE_CUDA
|
|
||||||
int max_gflops = 0;
|
|
||||||
|
|
||||||
const int device_count = deviceCount();
|
|
||||||
int current_device = 0;
|
|
||||||
while (current_device < device_count)
|
|
||||||
{
|
|
||||||
cudaDeviceProp device_properties;
|
|
||||||
cudaGetDeviceProperties(&device_properties, current_device);
|
|
||||||
int gflops = device_properties.multiProcessorCount * device_properties.clockRate;
|
|
||||||
|
|
||||||
if (device_properties.major != -1 && device_properties.minor != -1)
|
|
||||||
{
|
|
||||||
if( gflops > max_gflops )
|
|
||||||
{
|
|
||||||
max_gflops = gflops;
|
|
||||||
max_gflops_device = current_device;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_device++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return max_gflops_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Activate the given devices.
|
/// Activate the given devices.
|
||||||
bool nv::cuda::setDevice(int i)
|
bool nv::cuda::setDevice(int i)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,6 @@ namespace nv
|
|||||||
{
|
{
|
||||||
bool isHardwarePresent();
|
bool isHardwarePresent();
|
||||||
int deviceCount();
|
int deviceCount();
|
||||||
int getFastestDevice();
|
|
||||||
bool setDevice(int i);
|
bool setDevice(int i);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user