Merge changes from the-witness.
This commit is contained in:
parent
5d498d6824
commit
bd74a9ffc6
@ -120,46 +120,46 @@ namespace nv
|
|||||||
|
|
||||||
|
|
||||||
/// Const element access.
|
/// Const element access.
|
||||||
const T & operator[]( uint index ) const
|
NV_FORCEINLINE const T & operator[]( uint index ) const
|
||||||
{
|
{
|
||||||
nvDebugCheck(index < m_size);
|
nvDebugCheck(index < m_size);
|
||||||
return m_buffer[index];
|
return m_buffer[index];
|
||||||
}
|
}
|
||||||
const T & at( uint index ) const
|
NV_FORCEINLINE const T & at( uint index ) const
|
||||||
{
|
{
|
||||||
nvDebugCheck(index < m_size);
|
nvDebugCheck(index < m_size);
|
||||||
return m_buffer[index];
|
return m_buffer[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Element access.
|
/// Element access.
|
||||||
T & operator[] ( uint index )
|
NV_FORCEINLINE T & operator[] ( uint index )
|
||||||
{
|
{
|
||||||
nvDebugCheck(index < m_size);
|
nvDebugCheck(index < m_size);
|
||||||
return m_buffer[index];
|
return m_buffer[index];
|
||||||
}
|
}
|
||||||
T & at( uint index )
|
NV_FORCEINLINE T & at( uint index )
|
||||||
{
|
{
|
||||||
nvDebugCheck(index < m_size);
|
nvDebugCheck(index < m_size);
|
||||||
return m_buffer[index];
|
return m_buffer[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get vector size.
|
/// Get vector size.
|
||||||
uint size() const { return m_size; }
|
NV_FORCEINLINE uint size() const { return m_size; }
|
||||||
|
|
||||||
/// Get vector size.
|
/// Get vector size.
|
||||||
uint count() const { return m_size; }
|
NV_FORCEINLINE uint count() const { return m_size; }
|
||||||
|
|
||||||
/// Get const vector pointer.
|
/// Get const vector pointer.
|
||||||
const T * buffer() const { return m_buffer; }
|
NV_FORCEINLINE const T * buffer() const { return m_buffer; }
|
||||||
|
|
||||||
/// Get vector pointer.
|
/// Get vector pointer.
|
||||||
T * mutableBuffer() { return m_buffer; }
|
NV_FORCEINLINE T * mutableBuffer() { return m_buffer; }
|
||||||
|
|
||||||
/// Is vector empty.
|
/// Is vector empty.
|
||||||
bool isEmpty() const { return m_size == 0; }
|
NV_FORCEINLINE bool isEmpty() const { return m_size == 0; }
|
||||||
|
|
||||||
/// Is a null vector.
|
/// Is a null vector.
|
||||||
bool isNull() const { return m_buffer == NULL; }
|
NV_FORCEINLINE bool isNull() const { return m_buffer == NULL; }
|
||||||
|
|
||||||
|
|
||||||
/// Push an element at the end of the vector.
|
/// Push an element at the end of the vector.
|
||||||
@ -179,17 +179,17 @@ namespace nv
|
|||||||
new(m_buffer+new_size-1) T(val);
|
new(m_buffer+new_size-1) T(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void pushBack( const T & val )
|
NV_FORCEINLINE void pushBack( const T & val )
|
||||||
{
|
{
|
||||||
push_back(val);
|
push_back(val);
|
||||||
}
|
}
|
||||||
void append( const T & val )
|
NV_FORCEINLINE void append( const T & val )
|
||||||
{
|
{
|
||||||
push_back(val);
|
push_back(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Qt like push operator.
|
/// Qt like push operator.
|
||||||
Array<T> & operator<< ( T & t )
|
NV_FORCEINLINE Array<T> & operator<< ( T & t )
|
||||||
{
|
{
|
||||||
push_back(t);
|
push_back(t);
|
||||||
return *this;
|
return *this;
|
||||||
@ -201,41 +201,41 @@ namespace nv
|
|||||||
nvDebugCheck( m_size > 0 );
|
nvDebugCheck( m_size > 0 );
|
||||||
resize( m_size - 1 );
|
resize( m_size - 1 );
|
||||||
}
|
}
|
||||||
void popBack()
|
NV_FORCEINLINE void popBack()
|
||||||
{
|
{
|
||||||
pop_back();
|
pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get back element.
|
/// Get back element.
|
||||||
const T & back() const
|
NV_FORCEINLINE const T & back() const
|
||||||
{
|
{
|
||||||
nvDebugCheck( m_size > 0 );
|
nvDebugCheck( m_size > 0 );
|
||||||
return m_buffer[m_size-1];
|
return m_buffer[m_size-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get back element.
|
/// Get back element.
|
||||||
T & back()
|
NV_FORCEINLINE T & back()
|
||||||
{
|
{
|
||||||
nvDebugCheck( m_size > 0 );
|
nvDebugCheck( m_size > 0 );
|
||||||
return m_buffer[m_size-1];
|
return m_buffer[m_size-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get front element.
|
/// Get front element.
|
||||||
const T & front() const
|
NV_FORCEINLINE const T & front() const
|
||||||
{
|
{
|
||||||
nvDebugCheck( m_size > 0 );
|
nvDebugCheck( m_size > 0 );
|
||||||
return m_buffer[0];
|
return m_buffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get front element.
|
/// Get front element.
|
||||||
T & front()
|
NV_FORCEINLINE T & front()
|
||||||
{
|
{
|
||||||
nvDebugCheck( m_size > 0 );
|
nvDebugCheck( m_size > 0 );
|
||||||
return m_buffer[0];
|
return m_buffer[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if element found.
|
/// Return true if element found.
|
||||||
bool find(const T & element, uint * index) const
|
NV_FORCEINLINE bool find(const T & element, uint * index) const
|
||||||
{
|
{
|
||||||
return find(element, 0, m_size, index);
|
return find(element, 0, m_size, index);
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ namespace nv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the given element is contained in the array.
|
/// Check if the given element is contained in the array.
|
||||||
bool contains(const T & e) const
|
NV_FORCEINLINE bool contains(const T & e) const
|
||||||
{
|
{
|
||||||
return find(e, NULL);
|
return find(e, NULL);
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ namespace nv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Append the given data to our vector.
|
/// Append the given data to our vector.
|
||||||
void append(const Array<T> & other)
|
NV_FORCEINLINE void append(const Array<T> & other)
|
||||||
{
|
{
|
||||||
append(other.m_buffer, other.m_size);
|
append(other.m_buffer, other.m_size);
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ namespace nv
|
|||||||
void replaceWithLast(uint index)
|
void replaceWithLast(uint index)
|
||||||
{
|
{
|
||||||
nvDebugCheck( index < m_size );
|
nvDebugCheck( index < m_size );
|
||||||
swap(m_buffer[index], back());
|
nv::swap(m_buffer[index], back());
|
||||||
//m_buffer[index] = back();
|
//m_buffer[index] = back();
|
||||||
(m_buffer+m_size-1)->~T();
|
(m_buffer+m_size-1)->~T();
|
||||||
m_size--;
|
m_size--;
|
||||||
@ -409,13 +409,13 @@ namespace nv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clear the buffer.
|
/// Clear the buffer.
|
||||||
void clear()
|
NV_FORCEINLINE void clear()
|
||||||
{
|
{
|
||||||
resize(0);
|
resize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shrink the allocated vector.
|
/// Shrink the allocated vector.
|
||||||
void shrink()
|
NV_FORCEINLINE void shrink()
|
||||||
{
|
{
|
||||||
if (m_size < m_buffer_size) {
|
if (m_size < m_buffer_size) {
|
||||||
allocate(m_size);
|
allocate(m_size);
|
||||||
@ -423,7 +423,7 @@ namespace nv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Preallocate space.
|
/// Preallocate space.
|
||||||
void reserve(uint desired_size)
|
NV_FORCEINLINE void reserve(uint desired_size)
|
||||||
{
|
{
|
||||||
if (desired_size > m_buffer_size) {
|
if (desired_size > m_buffer_size) {
|
||||||
allocate( desired_size );
|
allocate( desired_size );
|
||||||
@ -440,7 +440,7 @@ namespace nv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
Array<T> & operator=( const Array<T> & a )
|
NV_FORCEINLINE Array<T> & operator=( const Array<T> & a )
|
||||||
{
|
{
|
||||||
copy(a.m_buffer, a.m_size);
|
copy(a.m_buffer, a.m_size);
|
||||||
return *this;
|
return *this;
|
||||||
@ -470,15 +470,15 @@ namespace nv
|
|||||||
// Array enumerator.
|
// Array enumerator.
|
||||||
typedef uint PseudoIndex;
|
typedef uint PseudoIndex;
|
||||||
|
|
||||||
PseudoIndex start() const { return 0; }
|
NV_FORCEINLINE PseudoIndex start() const { return 0; }
|
||||||
bool isDone(const PseudoIndex & i) const { nvDebugCheck(i <= this->m_size); return i == this->m_size; };
|
NV_FORCEINLINE bool isDone(const PseudoIndex & i) const { nvDebugCheck(i <= this->m_size); return i == this->m_size; };
|
||||||
void advance(PseudoIndex & i) const { nvDebugCheck(i <= this->m_size); i++; }
|
NV_FORCEINLINE void advance(PseudoIndex & i) const { nvDebugCheck(i <= this->m_size); i++; }
|
||||||
|
|
||||||
#if NV_CC_MSVC
|
#if NV_CC_MSVC
|
||||||
T & operator[]( const PseudoIndexWrapper & i ) {
|
NV_FORCEINLINE T & operator[]( const PseudoIndexWrapper & i ) {
|
||||||
return m_buffer[i(this)];
|
return m_buffer[i(this)];
|
||||||
}
|
}
|
||||||
const T & operator[]( const PseudoIndexWrapper & i ) const {
|
NV_FORCEINLINE const T & operator[]( const PseudoIndexWrapper & i ) const {
|
||||||
return m_buffer[i(this)];
|
return m_buffer[i(this)];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -510,7 +510,7 @@ namespace nv
|
|||||||
|
|
||||||
// realloc the buffer
|
// realloc the buffer
|
||||||
else {
|
else {
|
||||||
m_buffer = (T *) realloc( m_buffer, sizeof(T) * m_buffer_size );
|
m_buffer = realloc<T>(m_buffer, m_buffer_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,13 @@
|
|||||||
# pragma comment(lib,"dbghelp.lib")
|
# pragma comment(lib,"dbghelp.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if NV_OS_XBOX
|
||||||
|
# include <Xtl.h>
|
||||||
|
# ifdef _DEBUG
|
||||||
|
# include <xbdm.h>
|
||||||
|
# endif //_DEBUG
|
||||||
|
#endif //NV_OS_XBOX
|
||||||
|
|
||||||
#if !NV_OS_WIN32 && defined(HAVE_SIGNAL_H)
|
#if !NV_OS_WIN32 && defined(HAVE_SIGNAL_H)
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
@ -419,7 +426,7 @@ namespace
|
|||||||
|
|
||||||
#if NV_OS_WIN32 //&& NV_CC_MSVC
|
#if NV_OS_WIN32 //&& NV_CC_MSVC
|
||||||
|
|
||||||
/** Win32 asset handler. */
|
/** Win32 assert handler. */
|
||||||
struct Win32AssertHandler : public AssertHandler
|
struct Win32AssertHandler : public AssertHandler
|
||||||
{
|
{
|
||||||
// Code from Daniel Vogel.
|
// Code from Daniel Vogel.
|
||||||
@ -491,10 +498,50 @@ namespace
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
|
||||||
|
/** Xbox360 assert handler. */
|
||||||
|
struct Xbox360AssertHandler : public AssertHandler
|
||||||
|
{
|
||||||
|
static bool isDebuggerPresent()
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
return DmIsDebuggerPresent() == TRUE;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert handler method.
|
||||||
|
virtual int assertion( const char * exp, const char * file, int line, const char * func/*=NULL*/ )
|
||||||
|
{
|
||||||
|
int ret = NV_ABORT_EXIT;
|
||||||
|
|
||||||
|
StringBuilder error_string;
|
||||||
|
if( func != NULL ) {
|
||||||
|
error_string.format( "*** Assertion failed: %s\n On file: %s\n On function: %s\n On line: %d\n ", exp, file, func, line );
|
||||||
|
nvDebug( error_string.str() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error_string.format( "*** Assertion failed: %s\n On file: %s\n On line: %d\n ", exp, file, line );
|
||||||
|
nvDebug( error_string.str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDebuggerPresent()) {
|
||||||
|
return NV_ABORT_DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ret == NV_ABORT_EXIT ) {
|
||||||
|
// Exit cleanly.
|
||||||
|
throw "Assertion failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/** Unix asset handler. */
|
/** Unix assert handler. */
|
||||||
struct UnixAssertHandler : public AssertHandler
|
struct UnixAssertHandler : public AssertHandler
|
||||||
{
|
{
|
||||||
bool isDebuggerPresent()
|
bool isDebuggerPresent()
|
||||||
@ -552,11 +599,13 @@ namespace
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
/// Handle assertion through the asset handler.
|
/// Handle assertion through the assert handler.
|
||||||
int nvAbort(const char * exp, const char * file, int line, const char * func/*=NULL*/)
|
int nvAbort(const char * exp, const char * file, int line, const char * func/*=NULL*/)
|
||||||
{
|
{
|
||||||
#if NV_OS_WIN32 //&& NV_CC_MSVC
|
#if NV_OS_WIN32 //&& NV_CC_MSVC
|
||||||
static Win32AssertHandler s_default_assert_handler;
|
static Win32AssertHandler s_default_assert_handler;
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
static Xbox360AssertHandler s_default_assert_handler;
|
||||||
#else
|
#else
|
||||||
static UnixAssertHandler s_default_assert_handler;
|
static UnixAssertHandler s_default_assert_handler;
|
||||||
#endif
|
#endif
|
||||||
@ -585,7 +634,7 @@ void NV_CDECL nvDebugPrint(const char *msg, ...)
|
|||||||
/// Dump debug info.
|
/// Dump debug info.
|
||||||
void debug::dumpInfo()
|
void debug::dumpInfo()
|
||||||
{
|
{
|
||||||
#if NV_OS_WIN32 || (defined(HAVE_SIGNAL_H) && defined(HAVE_EXECINFO_H))
|
#if (NV_OS_WIN32 && NV_CC_MSVC) || (defined(HAVE_SIGNAL_H) && defined(HAVE_EXECINFO_H))
|
||||||
if (hasStackTrace())
|
if (hasStackTrace())
|
||||||
{
|
{
|
||||||
void * trace[64];
|
void * trace[64];
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#define NV_CDECL __cdecl
|
#define NV_CDECL __cdecl
|
||||||
#define NV_STDCALL __stdcall
|
#define NV_STDCALL __stdcall
|
||||||
#define NV_FASTCALL __fastcall
|
#define NV_FASTCALL __fastcall
|
||||||
#define NV_FORCEINLINE __forceinline
|
|
||||||
#define NV_DEPRECATED
|
#define NV_DEPRECATED
|
||||||
|
|
||||||
#define NV_PURE
|
#define NV_PURE
|
||||||
@ -43,6 +42,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NV_NOINLINE __declspec(noinline)
|
#define NV_NOINLINE __declspec(noinline)
|
||||||
|
#define NV_FORCEINLINE __forceinline
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Type definitions
|
// Type definitions
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
//#include <shlwapi.h> // PathFileExists
|
//#include <shlwapi.h> // PathFileExists
|
||||||
#include <windows.h> // GetFileAttributes
|
#include <windows.h> // GetFileAttributes
|
||||||
#include <direct.h> // _mkdir
|
#include <direct.h> // _mkdir
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
#include <Xtl.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -23,7 +25,7 @@ bool FileSystem::exists(const char * path)
|
|||||||
return access(path, F_OK|R_OK) == 0;
|
return access(path, F_OK|R_OK) == 0;
|
||||||
//struct stat buf;
|
//struct stat buf;
|
||||||
//return stat(path, &buf) == 0;
|
//return stat(path, &buf) == 0;
|
||||||
#elif NV_OS_WIN32
|
#elif NV_OS_WIN32 || NV_OS_XBOX
|
||||||
// PathFileExists requires linking to shlwapi.lib
|
// PathFileExists requires linking to shlwapi.lib
|
||||||
//return PathFileExists(path) != 0;
|
//return PathFileExists(path) != 0;
|
||||||
return GetFileAttributesA(path) != 0xFFFFFFFF;
|
return GetFileAttributesA(path) != 0xFFFFFFFF;
|
||||||
@ -39,8 +41,8 @@ bool FileSystem::exists(const char * path)
|
|||||||
|
|
||||||
bool FileSystem::createDirectory(const char * path)
|
bool FileSystem::createDirectory(const char * path)
|
||||||
{
|
{
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32 || NV_OS_XBOX
|
||||||
return _mkdir(path) != -1;
|
return CreateDirectory(path, NULL) != 0;
|
||||||
#else
|
#else
|
||||||
return mkdir(path, 0777) != -1;
|
return mkdir(path, 0777) != -1;
|
||||||
#endif
|
#endif
|
||||||
@ -50,6 +52,9 @@ bool FileSystem::changeDirectory(const char * path)
|
|||||||
{
|
{
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32
|
||||||
return _chdir(path) != -1;
|
return _chdir(path) != -1;
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
// Xbox doesn't support Current Working Directory!
|
||||||
|
return false;
|
||||||
#else
|
#else
|
||||||
return chdir(path) != -1;
|
return chdir(path) != -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define VC_EXTRALEAN
|
#define VC_EXTRALEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
#include <Xtl.h>
|
||||||
#else
|
#else
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
@ -16,6 +18,8 @@ void * nvLoadLibrary(const char * name)
|
|||||||
{
|
{
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32
|
||||||
return (void *)LoadLibraryExA( name, NULL, 0 );
|
return (void *)LoadLibraryExA( name, NULL, 0 );
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
return (void *)LoadLibraryA( name );
|
||||||
#else
|
#else
|
||||||
return dlopen(name, RTLD_LAZY);
|
return dlopen(name, RTLD_LAZY);
|
||||||
#endif
|
#endif
|
||||||
@ -24,7 +28,7 @@ void * nvLoadLibrary(const char * name)
|
|||||||
void nvUnloadLibrary(void * handle)
|
void nvUnloadLibrary(void * handle)
|
||||||
{
|
{
|
||||||
nvDebugCheck(handle != NULL);
|
nvDebugCheck(handle != NULL);
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32 || NV_OS_XBOX
|
||||||
FreeLibrary((HMODULE)handle);
|
FreeLibrary((HMODULE)handle);
|
||||||
#else
|
#else
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
@ -33,7 +37,7 @@ void nvUnloadLibrary(void * handle)
|
|||||||
|
|
||||||
void * nvBindSymbol(void * handle, const char * symbol)
|
void * nvBindSymbol(void * handle, const char * symbol)
|
||||||
{
|
{
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32 || NV_OS_XBOX
|
||||||
return (void *)GetProcAddress((HMODULE)handle, symbol);
|
return (void *)GetProcAddress((HMODULE)handle, symbol);
|
||||||
#else
|
#else
|
||||||
return (void *)dlsym(handle, symbol);
|
return (void *)dlsym(handle, symbol);
|
||||||
|
@ -44,7 +44,7 @@ namespace nv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void free(const T * ptr) {
|
template <typename T> void free(const T * ptr) {
|
||||||
::free((T *)ptr);
|
::free((void *)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // nv namespace
|
} // nv namespace
|
||||||
|
@ -15,17 +15,17 @@ namespace
|
|||||||
{
|
{
|
||||||
static char * strAlloc(uint size)
|
static char * strAlloc(uint size)
|
||||||
{
|
{
|
||||||
return static_cast<char *>(malloc(size));
|
return malloc<char>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * strReAlloc(char * str, uint size)
|
static char * strReAlloc(char * str, uint size)
|
||||||
{
|
{
|
||||||
return static_cast<char *>(realloc(str, size));
|
return realloc<char>(str, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void strFree(const char * str)
|
static void strFree(const char * str)
|
||||||
{
|
{
|
||||||
return free(const_cast<char *>(str));
|
return free<char>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static char * strDup( const char * str )
|
/*static char * strDup( const char * str )
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
// NV_OS_LINUX
|
// NV_OS_LINUX
|
||||||
// NV_OS_UNIX
|
// NV_OS_UNIX
|
||||||
// NV_OS_DARWIN
|
// NV_OS_DARWIN
|
||||||
|
// NV_OS_XBOX
|
||||||
|
|
||||||
#define NV_OS_STRING POSH_OS_STRING
|
#define NV_OS_STRING POSH_OS_STRING
|
||||||
|
|
||||||
@ -56,6 +57,8 @@
|
|||||||
# define NV_OS_WIN32 1
|
# define NV_OS_WIN32 1
|
||||||
#elif defined POSH_OS_WIN64
|
#elif defined POSH_OS_WIN64
|
||||||
# define NV_OS_WIN64 1
|
# define NV_OS_WIN64 1
|
||||||
|
#elif defined POSH_OS_XBOX
|
||||||
|
# define NV_OS_XBOX 1
|
||||||
#else
|
#else
|
||||||
# error "Unsupported OS"
|
# error "Unsupported OS"
|
||||||
#endif
|
#endif
|
||||||
@ -148,12 +151,17 @@ typedef uint32 uint;
|
|||||||
#define NV_DO_STRING_JOIN3(arg1, arg2, arg3) arg1 ## arg2 ## arg3
|
#define NV_DO_STRING_JOIN3(arg1, arg2, arg3) arg1 ## arg2 ## arg3
|
||||||
#define NV_STRING2(x) #x
|
#define NV_STRING2(x) #x
|
||||||
#define NV_STRING(x) NV_STRING2(x)
|
#define NV_STRING(x) NV_STRING2(x)
|
||||||
#if NV_CC_GNUC
|
|
||||||
//#define NV_FILE_LINE __FILE__ ":" NV_STRING(__LINE__) ": "
|
#if 1
|
||||||
#define NV_FILE_LINE
|
#if NV_CC_MSVC
|
||||||
|
#define NV_MESSAGE(x) message(__FILE__ "(" NV_STRING(__LINE__) ") : " x)
|
||||||
#else
|
#else
|
||||||
#define NV_FILE_LINE __FILE__ "(" NV_STRING(__LINE__) ") : "
|
#define NV_MESSAGE(x) message(x)
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#define NV_MESSAGE(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Startup initialization macro.
|
// Startup initialization macro.
|
||||||
#define NV_AT_STARTUP(some_code) \
|
#define NV_AT_STARTUP(some_code) \
|
||||||
@ -180,6 +188,8 @@ typedef uint32 uint;
|
|||||||
#if NV_CC_MSVC
|
#if NV_CC_MSVC
|
||||||
# if NV_OS_WIN32
|
# if NV_OS_WIN32
|
||||||
# include "DefsVcWin32.h"
|
# include "DefsVcWin32.h"
|
||||||
|
# elif NV_OS_XBOX
|
||||||
|
# include "DefsVcXBox.h"
|
||||||
# else
|
# else
|
||||||
# error "MSVC: Platform not supported"
|
# error "MSVC: Platform not supported"
|
||||||
# endif
|
# endif
|
||||||
|
@ -96,35 +96,37 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
|
|||||||
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
|
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
|
||||||
{
|
{
|
||||||
// Does bit expansion before interpolation.
|
// Does bit expansion before interpolation.
|
||||||
color_array[0].b = col0.b * 22 / 8;
|
color_array[0].b = (3 * col0.b * 22) / 8;
|
||||||
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
|
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
|
||||||
color_array[0].r = col0.r * 22 / 8;
|
color_array[0].r = (3 * col0.r * 22) / 8;
|
||||||
color_array[0].a = 0xFF;
|
color_array[0].a = 0xFF;
|
||||||
|
|
||||||
color_array[1].r = col1.r * 22 / 8;
|
color_array[1].r = (3 * col1.r * 22) / 8;
|
||||||
color_array[1].g = (col1.g << 2) | (col1.g >> 4);
|
color_array[1].g = (col1.g << 2) | (col1.g >> 4);
|
||||||
color_array[1].b = col1.b * 22 / 8;
|
color_array[1].b = (3 * col1.b * 22) / 8;
|
||||||
color_array[1].a = 0xFF;
|
color_array[1].a = 0xFF;
|
||||||
|
|
||||||
|
int gdiff = color_array[1].g - color_array[0].g;
|
||||||
|
|
||||||
if( col0.u > col1.u ) {
|
if( col0.u > col1.u ) {
|
||||||
// Four-color block: derive the other two colors.
|
// Four-color block: derive the other two colors.
|
||||||
color_array[2].r = (2 * col0.r + col1.r) * 22 / 8;
|
color_array[2].r = ((2 * col0.r + col1.r) * 22) / 8;
|
||||||
color_array[2].g = (256 * color_array[0].g + (color_array[1].g - color_array[0].g)/4 + 128 + (color_array[1].g - color_array[0].g) * 80) / 256;
|
color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 80) / 256;
|
||||||
color_array[2].b = (2 * col0.b + col1.b) * 22 / 8;
|
color_array[2].b = ((2 * col0.b + col1.b) * 22) / 8;
|
||||||
color_array[2].a = 0xFF;
|
color_array[2].a = 0xFF;
|
||||||
|
|
||||||
color_array[3].r = (2 * col1.r + col0.r) * 22 / 8;
|
color_array[3].r = ((2 * col1.r + col0.r) * 22) / 8;
|
||||||
color_array[3].g = (256 * color_array[1].g + (color_array[0].g - color_array[1].g)/4 + 128 + (color_array[0].g - color_array[1].g) * 80) / 256;
|
color_array[3].g = (256 * color_array[1].g - gdiff / 4 + 128 - gdiff * 80) / 256;
|
||||||
color_array[3].b = (2 * col1.b + col0.b) * 22 / 8;
|
color_array[3].b = ((2 * col1.b + col0.b) * 22) / 8;
|
||||||
color_array[3].a = 0xFF;
|
color_array[3].a = 0xFF;
|
||||||
|
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Three-color block: derive the other color.
|
// Three-color block: derive the other color.
|
||||||
color_array[2].r = (col0.r + col1.r) * 33 / 8;
|
color_array[2].r = ((col0.r + col1.r) * 33) / 8;
|
||||||
color_array[2].g = (256 * color_array[0].g + (color_array[1].g - color_array[0].g)/4 + 128 + (color_array[1].g - color_array[0].g) * 128) / 256;
|
color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256;
|
||||||
color_array[2].b = (col0.b + col1.b) * 33 / 8;
|
color_array[2].b = ((col0.b + col1.b) * 33) / 8;
|
||||||
color_array[2].a = 0xFF;
|
color_array[2].a = 0xFF;
|
||||||
|
|
||||||
// Set all components to 0 to match DXT specs.
|
// Set all components to 0 to match DXT specs.
|
||||||
|
@ -977,7 +977,7 @@ bool DirectDrawSurface::hasAlpha() const
|
|||||||
{
|
{
|
||||||
if (header.hasDX10Header())
|
if (header.hasDX10Header())
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "TODO: Update hasAlpha to handle all DX10 formats.")
|
#pragma NV_MESSAGE("TODO: Update hasAlpha to handle all DX10 formats.")
|
||||||
return
|
return
|
||||||
header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM ||
|
header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM ||
|
||||||
header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM ||
|
header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM ||
|
||||||
@ -1187,7 +1187,7 @@ void DirectDrawSurface::readLinearImage(Image * img)
|
|||||||
|
|
||||||
uint byteCount = (header.pf.bitcount + 7) / 8;
|
uint byteCount = (header.pf.bitcount + 7) / 8;
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: Support floating point linear images and other FOURCC codes.")
|
#pragma NV_MESSAGE("TODO: Support floating point linear images and other FOURCC codes.")
|
||||||
|
|
||||||
// Read linear RGB images.
|
// Read linear RGB images.
|
||||||
for (uint y = 0; y < h; y++)
|
for (uint y = 0; y < h; y++)
|
||||||
|
@ -152,7 +152,7 @@ void FloatImage::resizeChannelCount(uint c)
|
|||||||
{
|
{
|
||||||
if (m_componentNum != c) {
|
if (m_componentNum != c) {
|
||||||
uint count = m_width * m_height * c;
|
uint count = m_width * m_height * c;
|
||||||
realloc(m_mem, count * sizeof(float));
|
realloc<float>(m_mem, count);
|
||||||
|
|
||||||
if (c > m_componentNum) {
|
if (c > m_componentNum) {
|
||||||
memset(m_mem + m_count, 0, (count - m_count) * sizeof(float));
|
memset(m_mem + m_count, 0, (count - m_count) * sizeof(float));
|
||||||
|
@ -42,7 +42,7 @@ void Image::allocate(uint w, uint h)
|
|||||||
free();
|
free();
|
||||||
m_width = w;
|
m_width = w;
|
||||||
m_height = h;
|
m_height = h;
|
||||||
m_data = (Color32 *)realloc(m_data, w * h * sizeof(Color32));
|
m_data = realloc<Color32>(m_data, w * h);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::load(const char * name)
|
bool Image::load(const char * name)
|
||||||
|
@ -224,7 +224,7 @@ FloatImage * nv::ImageIO::loadFloat(const char * fileName, Stream & s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else // defined(HAVE_FREEIMAGE)
|
#else // defined(HAVE_FREEIMAGE)
|
||||||
#pragma message(NV_FILE_LINE "TODO: Load TIFF and EXR files from stream.")
|
#pragma NV_MESSAGE("TODO: Load TIFF and EXR files from stream.")
|
||||||
#if defined(HAVE_TIFF)
|
#if defined(HAVE_TIFF)
|
||||||
if (strCaseCmp(extension, ".tif") == 0 || strCaseCmp(extension, ".tiff") == 0) {
|
if (strCaseCmp(extension, ".tif") == 0 || strCaseCmp(extension, ".tiff") == 0) {
|
||||||
return loadFloatTIFF(fileName, s);
|
return loadFloatTIFF(fileName, s);
|
||||||
|
@ -82,7 +82,7 @@ static FloatImage * createNormalMap(const FloatImage * img, FloatImage::WrapMode
|
|||||||
nvDebugCheck(kdv != NULL);
|
nvDebugCheck(kdv != NULL);
|
||||||
nvDebugCheck(img != NULL);
|
nvDebugCheck(img != NULL);
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "FIXME: Height scale parameter should go away. It should be a sensible value that produces good results when the heightmap is in the [0, 1] range.")
|
#pragma NV_MESSAGE("FIXME: Height scale parameter should go away. It should be a sensible value that produces good results when the heightmap is in the [0, 1] range.")
|
||||||
const float heightScale = 1.0f / 16.0f;
|
const float heightScale = 1.0f / 16.0f;
|
||||||
|
|
||||||
const uint w = img->width();
|
const uint w = img->width();
|
||||||
@ -198,7 +198,7 @@ void nv::normalizeNormalMap(FloatImage * img)
|
|||||||
{
|
{
|
||||||
nvDebugCheck(img != NULL);
|
nvDebugCheck(img != NULL);
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: Pack and expand normals explicitly?")
|
#pragma NV_MESSAGE("TODO: Pack and expand normals explicitly?")
|
||||||
|
|
||||||
img->expandNormals(0);
|
img->expandNormals(0);
|
||||||
img->normalize(0);
|
img->normalize(0);
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
// This code is in the public domain -- castanyo@yahoo.es
|
// This code is in the public domain -- castanyo@yahoo.es
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef NV_IMAGE_H
|
#ifndef NV_IMAGE_H
|
||||||
#define NV_IMAGE_H
|
#define NV_IMAGE_H
|
||||||
|
|
||||||
#include <nvcore/nvcore.h>
|
#include <nvcore/nvcore.h>
|
||||||
|
|
||||||
// Function linkage
|
// Function linkage
|
||||||
#if NVIMAGE_SHARED
|
#if NVIMAGE_SHARED
|
||||||
#ifdef NVIMAGE_EXPORTS
|
#ifdef NVIMAGE_EXPORTS
|
||||||
#define NVIMAGE_API DLL_EXPORT
|
#define NVIMAGE_API DLL_EXPORT
|
||||||
#define NVIMAGE_CLASS DLL_EXPORT_CLASS
|
#define NVIMAGE_CLASS DLL_EXPORT_CLASS
|
||||||
#else
|
#else
|
||||||
#define NVIMAGE_API DLL_IMPORT
|
#define NVIMAGE_API DLL_IMPORT
|
||||||
#define NVIMAGE_CLASS DLL_IMPORT
|
#define NVIMAGE_CLASS DLL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define NVIMAGE_API
|
#define NVIMAGE_API
|
||||||
#define NVIMAGE_CLASS
|
#define NVIMAGE_CLASS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Some utility functions:
|
// Some utility functions:
|
||||||
|
|
||||||
inline uint computePitch(uint w, uint bitsize, uint alignment)
|
inline uint computePitch(uint w, uint bitsize, uint alignment)
|
||||||
{
|
{
|
||||||
return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment;
|
return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NV_IMAGE_H
|
#endif // NV_IMAGE_H
|
||||||
|
@ -162,7 +162,7 @@ Plane nv::Fit::bestPlane(int n, const Vector3 *__restrict points)
|
|||||||
return Plane(Vector3(0, 0, 1), centroid);
|
return Plane(Vector3(0, 0, 1), centroid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: need to write an eigensolver!")
|
#pragma NV_MESSAGE("TODO: need to write an eigensolver!")
|
||||||
|
|
||||||
// - Numerical Recipes in C is a good reference. Householder transforms followed by QL decomposition seems to be the best approach.
|
// - Numerical Recipes in C is a good reference. Householder transforms followed by QL decomposition seems to be the best approach.
|
||||||
// - The one from magic-tools is now LGPL. For the 3D case it uses a cubic root solver, which is not very accurate.
|
// - The one from magic-tools is now LGPL. For the 3D case it uses a cubic root solver, which is not very accurate.
|
||||||
|
@ -275,7 +275,10 @@ static inline uint16 _uint16_sels( uint16 test, uint16 a, uint16 b )
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NV_CC_MSVC
|
#if NV_OS_XBOX
|
||||||
|
#include <PPCIntrinsics.h>
|
||||||
|
#elif NV_CC_MSVC
|
||||||
|
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#pragma intrinsic(_BitScanReverse)
|
#pragma intrinsic(_BitScanReverse)
|
||||||
|
|
||||||
@ -297,6 +300,9 @@ static inline uint32 _uint32_cntlz( uint32 x )
|
|||||||
uint32 nlz = __builtin_clz( x );
|
uint32 nlz = __builtin_clz( x );
|
||||||
uint32 result = _uint32_sels( is_x_nez_msb, nlz, 0x00000020 );
|
uint32 result = _uint32_sels( is_x_nez_msb, nlz, 0x00000020 );
|
||||||
return (result);
|
return (result);
|
||||||
|
#elif NV_OS_XBOX
|
||||||
|
// Xbox PPC has this as an intrinsic.
|
||||||
|
return _CountLeadingZeros(x);
|
||||||
#elif NV_CC_MSVC
|
#elif NV_CC_MSVC
|
||||||
uint32 is_x_nez_msb = _uint32_neg( x );
|
uint32 is_x_nez_msb = _uint32_neg( x );
|
||||||
uint32 nlz = _uint32_nlz( x );
|
uint32 nlz = _uint32_nlz( x );
|
||||||
@ -342,6 +348,9 @@ static inline uint16 _uint16_cntlz( uint16 x )
|
|||||||
uint16 nlz32 = (uint16)_uint32_cntlz( (uint32)x );
|
uint16 nlz32 = (uint16)_uint32_cntlz( (uint32)x );
|
||||||
uint32 nlz = _uint32_sub( nlz32, 16 );
|
uint32 nlz = _uint32_sub( nlz32, 16 );
|
||||||
return (nlz);
|
return (nlz);
|
||||||
|
#elif _NV_OS_XBOX_
|
||||||
|
uint16 nlz32 = (uint16)_CountLeadingZeros( (uint32)x );
|
||||||
|
return _uint32_sub( nlz32, 16);
|
||||||
#else
|
#else
|
||||||
const uint16 x0 = _uint16_srl( x, 1 );
|
const uint16 x0 = _uint16_srl( x, 1 );
|
||||||
const uint16 x1 = _uint16_or( x, x0 );
|
const uint16 x1 = _uint16_or( x, x0 );
|
||||||
|
@ -88,6 +88,10 @@ namespace nv
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helpers to convert vector types. Assume T has x,y,z members and 3 argument constructor.
|
||||||
|
template <typename T> Vector3 from(const T & v) { return Vector3(v.x, v.y, v.z); }
|
||||||
|
template <typename T> T to(Vector3::Arg v) { return T(v.x, v.y, v.z); }
|
||||||
|
|
||||||
|
|
||||||
class NVMATH_CLASS Vector4
|
class NVMATH_CLASS Vector4
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <limits.h> // INT_MAX
|
#include <limits.h> // INT_MAX
|
||||||
|
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32 || NV_OS_XBOX
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ namespace nv
|
|||||||
|
|
||||||
inline bool isFinite(const float f)
|
inline bool isFinite(const float f)
|
||||||
{
|
{
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32 || NV_OS_XBOX
|
||||||
return _finite(f) != 0;
|
return _finite(f) != 0;
|
||||||
#elif NV_OS_DARWIN || NV_OS_FREEBSD
|
#elif NV_OS_DARWIN || NV_OS_FREEBSD
|
||||||
return isfinite(f);
|
return isfinite(f);
|
||||||
@ -131,7 +131,7 @@ namespace nv
|
|||||||
|
|
||||||
inline bool isNan(const float f)
|
inline bool isNan(const float f)
|
||||||
{
|
{
|
||||||
#if NV_OS_WIN32
|
#if NV_OS_WIN32 || NV_OS_XBOX
|
||||||
return _isnan(f) != 0;
|
return _isnan(f) != 0;
|
||||||
#elif NV_OS_DARWIN || NV_OS_FREEBSD
|
#elif NV_OS_DARWIN || NV_OS_FREEBSD
|
||||||
return isnan(f);
|
return isnan(f);
|
||||||
|
@ -224,7 +224,7 @@ Compressor::Compressor() : m(*new Compressor::Private())
|
|||||||
|
|
||||||
if (m.cudaEnabled)
|
if (m.cudaEnabled)
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "FIXME: This code is duplicated below.")
|
#pragma NV_MESSAGE("FIXME: This code is duplicated below.")
|
||||||
// Select fastest CUDA device.
|
// Select fastest CUDA device.
|
||||||
int device = cuda::getFastestDevice();
|
int device = cuda::getFastestDevice();
|
||||||
if (!cuda::setDevice(device))
|
if (!cuda::setDevice(device))
|
||||||
@ -944,7 +944,7 @@ bool Compressor::Private::compressMipmaps(uint f, const InputOptions::Private &
|
|||||||
premultiplyAlphaMipmap(mipmap, inputOptions);
|
premultiplyAlphaMipmap(mipmap, inputOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: All color transforms should be done here!")
|
#pragma NV_MESSAGE("TODO: All color transforms should be done here!")
|
||||||
|
|
||||||
// Apply gamma space color transforms:
|
// Apply gamma space color transforms:
|
||||||
if (inputOptions.colorTransform == ColorTransform_YCoCg)
|
if (inputOptions.colorTransform == ColorTransform_YCoCg)
|
||||||
@ -1231,7 +1231,7 @@ void Compressor::Private::processInputImage(Mipmap & mipmap, const InputOptions:
|
|||||||
mipmap.toFloatImage(inputOptions);
|
mipmap.toFloatImage(inputOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "FIXME: Do not perform color transforms here!")
|
#pragma NV_MESSAGE("FIXME: Do not perform color transforms here!")
|
||||||
|
|
||||||
/*// Apply linear transforms in linear space.
|
/*// Apply linear transforms in linear space.
|
||||||
if (inputOptions.colorTransform == ColorTransform_Linear)
|
if (inputOptions.colorTransform == ColorTransform_Linear)
|
||||||
|
@ -61,7 +61,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: Move these functions to a common location.")
|
#pragma NV_MESSAGE("TODO: Move these functions to a common location.")
|
||||||
|
|
||||||
static int blockSize(Format format)
|
static int blockSize(Format format)
|
||||||
{
|
{
|
||||||
@ -288,7 +288,7 @@ bool TexImage::load(const char * fileName)
|
|||||||
|
|
||||||
bool TexImage::save(const char * fileName) const
|
bool TexImage::save(const char * fileName) const
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "TODO: Add support for DDS textures in TexImage::save")
|
#pragma NV_MESSAGE("TODO: Add support for DDS textures in TexImage::save")
|
||||||
|
|
||||||
if (m->imageArray.count() == 0)
|
if (m->imageArray.count() == 0)
|
||||||
{
|
{
|
||||||
@ -433,7 +433,7 @@ bool TexImage::setImage2D(Format format, Decoder decoder, int w, int h, int idx,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: Add support for all compressed formats in TexImage::setImage2D.")
|
#pragma NV_MESSAGE("TODO: Add support for all compressed formats in TexImage::setImage2D.")
|
||||||
|
|
||||||
if (format != nvtt::Format_BC1 && format != nvtt::Format_BC2 && format != nvtt::Format_BC3)
|
if (format != nvtt::Format_BC1 && format != nvtt::Format_BC2 && format != nvtt::Format_BC3)
|
||||||
{
|
{
|
||||||
@ -526,7 +526,7 @@ bool TexImage::setImage2D(Format format, Decoder decoder, int w, int h, int idx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: provide a TexImage::resize that can override filter width and parameters.")
|
#pragma NV_MESSAGE("TODO: provide a TexImage::resize that can override filter width and parameters.")
|
||||||
|
|
||||||
void TexImage::resize(int w, int h, ResizeFilter filter)
|
void TexImage::resize(int w, int h, ResizeFilter filter)
|
||||||
{
|
{
|
||||||
@ -537,7 +537,7 @@ void TexImage::resize(int w, int h, ResizeFilter filter)
|
|||||||
|
|
||||||
if (m->type == TextureType_Cube)
|
if (m->type == TextureType_Cube)
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "TODO: Output error when image is cubemap and w != h.")
|
#pragma NV_MESSAGE("TODO: Output error when image is cubemap and w != h.")
|
||||||
h = w;
|
h = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1014,7 +1014,7 @@ void TexImage::toNormalMap(float sm, float medium, float big, float large)
|
|||||||
const FloatImage * img = m->imageArray[i];
|
const FloatImage * img = m->imageArray[i];
|
||||||
m->imageArray[i] = nv::createNormalMap(img, (FloatImage::WrapMode)m->wrapMode, filterWeights);
|
m->imageArray[i] = nv::createNormalMap(img, (FloatImage::WrapMode)m->wrapMode, filterWeights);
|
||||||
|
|
||||||
#pragma message(NV_FILE_LINE "TODO: Pack and expand normals explicitly?")
|
#pragma NV_MESSAGE("TODO: Pack and expand normals explicitly?")
|
||||||
m->imageArray[i]->packNormals(0);
|
m->imageArray[i]->packNormals(0);
|
||||||
|
|
||||||
delete img;
|
delete img;
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined HAVE_CUDA
|
#if defined HAVE_CUDA
|
||||||
#include <cuda_runtime_api.h>
|
#include <cuda_runtime_api.h>
|
||||||
|
|
||||||
@ -129,6 +128,8 @@ void CudaCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alp
|
|||||||
{
|
{
|
||||||
nvDebugCheck(cuda::isHardwarePresent());
|
nvDebugCheck(cuda::isHardwarePresent());
|
||||||
|
|
||||||
|
#if defined HAVE_CUDA
|
||||||
|
|
||||||
// Allocate image as a cuda array.
|
// Allocate image as a cuda array.
|
||||||
cudaArray * d_image;
|
cudaArray * d_image;
|
||||||
if (inputFormat == nvtt::InputFormat_BGRA_8UB)
|
if (inputFormat == nvtt::InputFormat_BGRA_8UB)
|
||||||
@ -141,7 +142,7 @@ void CudaCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alp
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "FIXME: Floating point textures not really supported by CUDA compressors.") // @@ What's missing???
|
#pragma NV_MESSAGE("FIXME: Floating point textures not really supported by CUDA compressors.") // @@ What's missing???
|
||||||
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 32, 32, 32, cudaChannelFormatKindFloat);
|
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 32, 32, 32, cudaChannelFormatKindFloat);
|
||||||
cudaMallocArray(&d_image, &channelDesc, w, h);
|
cudaMallocArray(&d_image, &channelDesc, w, h);
|
||||||
|
|
||||||
@ -189,8 +190,14 @@ void CudaCompressor::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alp
|
|||||||
|
|
||||||
free(h_result);
|
free(h_result);
|
||||||
cudaFreeArray(d_image);
|
cudaFreeArray(d_image);
|
||||||
|
|
||||||
|
#else
|
||||||
|
outputOptions.error(Error_CudaError);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined HAVE_CUDA
|
||||||
|
|
||||||
void CudaCompressorDXT1::setup(cudaArray * image, const nvtt::CompressionOptions::Private & compressionOptions)
|
void CudaCompressorDXT1::setup(cudaArray * image, const nvtt::CompressionOptions::Private & compressionOptions)
|
||||||
{
|
{
|
||||||
@ -589,3 +596,5 @@ void CudaCompressor::compressDXT5n(const nvtt::CompressionOptions::Private & com
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
|
#endif // defined HAVE_CUDA
|
||||||
|
@ -55,6 +55,3 @@ void nvttCompressImage(NvttImage * img, NvttFormat format)
|
|||||||
// @@ Invoke appropriate compressor.
|
// @@ Invoke appropriate compressor.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NVTT_EXPERIMENTAL_H
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#ifndef SQUISH_ALPHA_H
|
#ifndef SQUISH_ALPHA_H
|
||||||
#define SQUISH_ALPHA_H
|
#define SQUISH_ALPHA_H
|
||||||
|
|
||||||
#include <squish.h>
|
#include "squish.h"
|
||||||
|
|
||||||
namespace squish {
|
namespace squish {
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------- */
|
-------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include <squish.h>
|
#include "squish.h"
|
||||||
#include "colourset.h"
|
#include "colourset.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include "rangefit.h"
|
#include "rangefit.h"
|
||||||
|
@ -373,6 +373,8 @@ int main(int argc, char *argv[])
|
|||||||
printf(" 1: \tWaterloo.\n");
|
printf(" 1: \tWaterloo.\n");
|
||||||
printf(" 2: \tEpic.\n");
|
printf(" 2: \tEpic.\n");
|
||||||
printf(" 3: \tFarbrausch.\n");
|
printf(" 3: \tFarbrausch.\n");
|
||||||
|
printf(" 4: \Lugaru.\n");
|
||||||
|
printf(" 5: \Quake 3.\n");
|
||||||
printf(" -dec x \tDecompressor.\n");
|
printf(" -dec x \tDecompressor.\n");
|
||||||
printf(" 0: \tReference.\n");
|
printf(" 0: \tReference.\n");
|
||||||
printf(" 1: \tNVIDIA.\n");
|
printf(" 1: \tNVIDIA.\n");
|
||||||
@ -422,7 +424,7 @@ int main(int argc, char *argv[])
|
|||||||
FileSystem::createDirectory(outPath);
|
FileSystem::createDirectory(outPath);
|
||||||
|
|
||||||
Path csvFileName;
|
Path csvFileName;
|
||||||
csvFileName.format("%s/result.csv", outPath);
|
csvFileName.format("%s/result-%d.csv", outPath, set);
|
||||||
StdOutputStream csvStream(csvFileName.str());
|
StdOutputStream csvStream(csvFileName.str());
|
||||||
TextWriter csvWriter(&csvStream);
|
TextWriter csvWriter(&csvStream);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
nv::Image image;
|
nv::Image image;
|
||||||
if (!loadImage(image, input.str())) return 1;
|
if (!loadImage(image, input.str())) return 1;
|
||||||
|
|
||||||
nv::ImageIO::ImageMetaData metaData;
|
nv::ImageIO::ImageMetaData metaData;
|
||||||
metaData.tagMap.add("Thumb::Image::Width", nv::StringBuilder().number (image.width()));
|
metaData.tagMap.add("Thumb::Image::Width", nv::StringBuilder().number (image.width()));
|
||||||
@ -143,13 +143,13 @@ int main(int argc, char *argv[])
|
|||||||
nv::AutoPtr<nv::Image> result(fresult->createImageGammaCorrect(gamma));
|
nv::AutoPtr<nv::Image> result(fresult->createImageGammaCorrect(gamma));
|
||||||
result->setFormat(nv::Image::Format_ARGB);
|
result->setFormat(nv::Image::Format_ARGB);
|
||||||
|
|
||||||
nv::StdOutputStream stream(output.str());
|
nv::StdOutputStream stream(output.str());
|
||||||
nv::ImageIO::save(output.str(), stream, result.ptr(), &metaData);
|
nv::ImageIO::save(output.str(), stream, result.ptr(), &metaData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nv::StdOutputStream stream(output.str());
|
nv::StdOutputStream stream(output.str());
|
||||||
nv::ImageIO::save(output.str(), stream, &image, &metaData);
|
nv::ImageIO::save(output.str(), stream, &image, &metaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user