From 4ed37ac68ee31641fd9e6fbb919953b0d3ea0c13 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 19:00:24 +0200 Subject: [PATCH 02/37] SSE2: Add CMake options --HG-- branch : sse2 --- code/CMakeLists.txt | 7 +++++++ code/CMakeModules/nel.cmake | 3 +++ 2 files changed, 10 insertions(+) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 4f0439dfd..3fae8488c 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -131,6 +131,13 @@ IF(FINAL_VERSION) ADD_DEFINITIONS(-DFINAL_VERSION=1) ENDIF(FINAL_VERSION) +IF(WITH_SSE2) + ADD_DEFINITIONS(-DNL_HAS_SSE2) + IF(WITH_SSE3) + ADD_DEFINITIONS(-DNL_HAS_SSE3) + ENDIF(WITH_SSE3) +ENDIF(WITH_SSE2) + IF(WITH_QT) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED) ENDIF(WITH_QT) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index b194b5ff9..6e55545d6 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -324,6 +324,9 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) OPTION(WITH_LIBOVR "With LibOVR support" OFF) OPTION(WITH_LIBVR "With LibVR support" OFF) OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF) + + OPTION(WITH_SSE2 "With SSE2" ON ) + OPTION(WITH_SSE3 "With SSE3" ON ) ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) From eee9ba0caeed52ba380ba8d9931db57714725455 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 19:12:31 +0200 Subject: [PATCH 03/37] SSE2: Add aligned allocators --HG-- branch : sse2 --- code/nel/include/nel/misc/types_nl.h | 34 ++++++++++++++++++++++++++++ code/nel/src/misc/common.cpp | 29 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 5c3b80475..f4001fd94 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -328,6 +328,40 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #endif // NL_OS_UNIX + +#ifdef NL_COMP_VC +#define NL_ALIGN(nb) __declspec(align(nb)) +#else +#define NL_ALIGN(nb) __attribute__((aligned(nb))) +#endif + +#ifdef NL_COMP_VC +inline void *aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); } +inline void aligned_free(void *ptr) { _aligned_free(ptr); } +#else +inline void *aligned_malloc(size_t size, size_t alignment) { return memalign(alignment, size); } +inline void aligned_free(void *ptr) { free(ptr); } +#endif /* NL_COMP_ */ + + +#ifdef NL_HAS_SSE2 + +#define NL_DEFAULT_MEMORY_ALIGNMENT 16 +#define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) + +extern void *operator new(size_t size) throw(std::bad_alloc); +extern void *operator new[](size_t size) throw(std::bad_alloc); +extern void operator delete(void *p) throw(); +extern void operator delete[](void *p) throw(); + +#else /* NL_HAS_SSE2 */ + +#define NL_DEFAULT_MEMORY_ALIGNMENT 4 +#define NL_ALIGN_SSE2(nb) + +#endif /* NL_HAS_SSE2 */ + + // CHashMap, CHashSet and CHashMultiMap definitions #if defined(_STLPORT_VERSION) // STLport detected # include diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 36e167260..3c72b6ca4 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -71,6 +71,35 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #endif // NL_OS_WINDOWS +#ifdef NL_HAS_SSE2 + +void *operator new(size_t size) throw(std::bad_alloc) +{ + void *p = aligned_malloc(size, NL_DEFAULT_MEMORY_ALIGNMENT); + if (p == NULL) throw std::bad_alloc(); + return p; +} + +void *operator new[](size_t size) throw(std::bad_alloc) +{ + void *p = aligned_malloc(size, NL_DEFAULT_MEMORY_ALIGNMENT); + if (p == NULL) throw std::bad_alloc(); + return p; +} + +void operator delete(void *p) throw() +{ + aligned_free(p); +} + +void operator delete[](void *p) throw() +{ + aligned_free(p); +} + +#endif /* NL_HAS_SSE2 */ + + #ifdef DEBUG_NEW #define new DEBUG_NEW #endif From 556a41afeef5bb4d01f81a33e6f264f9be24757f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 19:26:22 +0200 Subject: [PATCH 04/37] SSE2: Implement alignment for arena allocator --HG-- branch : sse2 --- .../nel/include/nel/misc/fixed_size_allocator.h | 1 + code/nel/src/misc/fixed_size_allocator.cpp | 17 ++++++++++++----- code/nel/src/misc/object_arena_allocator.cpp | 14 ++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/code/nel/include/nel/misc/fixed_size_allocator.h b/code/nel/include/nel/misc/fixed_size_allocator.h index 9eb1d8a10..80b9ed491 100644 --- a/code/nel/include/nel/misc/fixed_size_allocator.h +++ b/code/nel/include/nel/misc/fixed_size_allocator.h @@ -53,6 +53,7 @@ public: uint getNumAllocatedBlocks() const { return _NumAlloc; } private: class CChunk; + NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) class CNode { public: diff --git a/code/nel/src/misc/fixed_size_allocator.cpp b/code/nel/src/misc/fixed_size_allocator.cpp index 790275ec6..30693ddfd 100644 --- a/code/nel/src/misc/fixed_size_allocator.cpp +++ b/code/nel/src/misc/fixed_size_allocator.cpp @@ -33,6 +33,9 @@ CFixedSizeAllocator::CFixedSizeAllocator(uint numBytesPerBlock, uint numBlockPer _NumChunks = 0; nlassert(numBytesPerBlock > 1); _NumBytesPerBlock = numBytesPerBlock; + const uint mask = NL_DEFAULT_MEMORY_ALIGNMENT - 1; + _NumBytesPerBlock = (_NumBytesPerBlock + mask) & ~mask; + nlassert(_NumBytesPerBlock >= numBytesPerBlock); _NumBlockPerChunk = std::max(numBlockPerChunk, (uint) 3); _NumAlloc = 0; } @@ -67,12 +70,14 @@ void *CFixedSizeAllocator::alloc() return _FreeSpace->unlink(); } +#define aligned_offsetof(s, m) ((offsetof(s, m) + (NL_DEFAULT_MEMORY_ALIGNMENT - 1)) & ~(NL_DEFAULT_MEMORY_ALIGNMENT - 1)) + // ***************************************************************************************************************** void CFixedSizeAllocator::free(void *block) { if (!block) return; /// get the node from the object - CNode *node = (CNode *) ((uint8 *) block - offsetof(CNode, Next)); + CNode *node = (CNode *) ((uint8 *) block - aligned_offsetof(CNode, Next)); // nlassert(node->Chunk != NULL); nlassert(node->Chunk->Allocator == this); @@ -84,7 +89,9 @@ void CFixedSizeAllocator::free(void *block) // ***************************************************************************************************************** uint CFixedSizeAllocator::CChunk::getBlockSizeWithOverhead() const { - return std::max((uint)(sizeof(CNode) - offsetof(CNode, Next)),(uint)(Allocator->getNumBytesPerBlock())) + offsetof(CNode, Next); + nlctassert((sizeof(CNode) % NL_DEFAULT_MEMORY_ALIGNMENT) == 0); + return std::max((uint)(sizeof(CNode) - aligned_offsetof(CNode, Next)), + (uint)(Allocator->getNumBytesPerBlock())) + aligned_offsetof(CNode, Next); } // ***************************************************************************************************************** @@ -105,7 +112,7 @@ CFixedSizeAllocator::CChunk::~CChunk() nlassert(NumFreeObjs == 0); nlassert(Allocator->_NumChunks > 0); -- (Allocator->_NumChunks); - delete[] Mem; + aligned_free(Mem); //delete[] Mem; } // ***************************************************************************************************************** @@ -115,7 +122,7 @@ void CFixedSizeAllocator::CChunk::init(CFixedSizeAllocator *alloc) nlassert(alloc != NULL); Allocator = alloc; // - Mem = new uint8[getBlockSizeWithOverhead() * alloc->getNumBlockPerChunk()]; + Mem = (uint8 *)aligned_malloc(getBlockSizeWithOverhead() * alloc->getNumBlockPerChunk(), NL_DEFAULT_MEMORY_ALIGNMENT); // new uint8[getBlockSizeWithOverhead() * alloc->getNumBlockPerChunk()]; // getNode(0).Chunk = this; getNode(0).Next = &getNode(1); @@ -179,7 +186,7 @@ void *CFixedSizeAllocator::CNode::unlink() *Prev = Next; nlassert(Chunk->NumFreeObjs > 0); Chunk->grab(); // tells the containing chunk that a node has been allocated - return (void *) &Next; + return (void *)((uintptr_t)(this) + aligned_offsetof(CNode, Next)); //(void *) &Next; } // ***************************************************************************************************************** diff --git a/code/nel/src/misc/object_arena_allocator.cpp b/code/nel/src/misc/object_arena_allocator.cpp index 9c73f5059..8084b4ac9 100644 --- a/code/nel/src/misc/object_arena_allocator.cpp +++ b/code/nel/src/misc/object_arena_allocator.cpp @@ -68,21 +68,23 @@ void *CObjectArenaAllocator::alloc(uint size) if (size >= _MaxAllocSize) { // use standard allocator - uint8 *block = new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block + nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT > sizeof(uint)); + uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block if (!block) return NULL; #ifdef NL_DEBUG _MemBlockToAllocID[block] = _AllocID; #endif *(uint *) block = size; - return block + sizeof(uint); + return block + NL_DEFAULT_MEMORY_ALIGNMENT; } uint entry = ((size + (_Granularity - 1)) / _Granularity) ; nlassert(entry < _ObjectSizeToAllocator.size()); if (!_ObjectSizeToAllocator[entry]) { - _ObjectSizeToAllocator[entry] = new CFixedSizeAllocator(entry * _Granularity + sizeof(uint), _MaxAllocSize / size); // an additionnal uint is needed to store size of block + _ObjectSizeToAllocator[entry] = new CFixedSizeAllocator(entry * _Granularity + NL_DEFAULT_MEMORY_ALIGNMENT, _MaxAllocSize / size); // an additionnal uint is needed to store size of block } void *block = _ObjectSizeToAllocator[entry]->alloc(); + nlassert(((uintptr_t)block % NL_DEFAULT_MEMORY_ALIGNMENT) == 0); #ifdef NL_DEBUG if (block) { @@ -91,14 +93,14 @@ void *CObjectArenaAllocator::alloc(uint size) ++_AllocID; #endif *(uint *) block = size; - return (void *) ((uint8 *) block + sizeof(uint)); + return (void *) ((uint8 *) block + NL_DEFAULT_MEMORY_ALIGNMENT); } // ***************************************************************************************************************** void CObjectArenaAllocator::free(void *block) { if (!block) return; - uint8 *realBlock = (uint8 *) block - sizeof(uint); // a uint is used at start of block to give its size + uint8 *realBlock = (uint8 *) block - NL_DEFAULT_MEMORY_ALIGNMENT; // sizeof(uint); // a uint is used at start of block to give its size uint size = *(uint *) realBlock; if (size >= _MaxAllocSize) { @@ -107,7 +109,7 @@ void CObjectArenaAllocator::free(void *block) nlassert(it != _MemBlockToAllocID.end()); _MemBlockToAllocID.erase(it); #endif - delete realBlock; + aligned_free(realBlock); return; } uint entry = ((size + (_Granularity - 1)) / _Granularity); From d3fb390cf321fbe79ba0a4b1afdb988b8931d5aa Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 19:33:09 +0200 Subject: [PATCH 05/37] SSE2: Align CMatrix --HG-- branch : sse2 --- code/nel/include/nel/3d/computed_string.h | 2 +- code/nel/include/nel/misc/matrix.h | 1 + code/nel/src/3d/computed_string.cpp | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/3d/computed_string.h b/code/nel/include/nel/3d/computed_string.h index fcb758da4..517200383 100644 --- a/code/nel/include/nel/3d/computed_string.h +++ b/code/nel/include/nel/3d/computed_string.h @@ -290,7 +290,7 @@ public: * \param matrix transformation matrix * \param hotspot position of string origine */ - void render3D (IDriver& driver,CMatrix matrix,THotSpot hotspot = MiddleMiddle); + void render3D (IDriver& driver, const CMatrix &matrix, THotSpot hotspot = MiddleMiddle); }; diff --git a/code/nel/include/nel/misc/matrix.h b/code/nel/include/nel/misc/matrix.h index 700eb4a14..37a19b655 100644 --- a/code/nel/include/nel/misc/matrix.h +++ b/code/nel/include/nel/misc/matrix.h @@ -53,6 +53,7 @@ class CPlane; * \author Nevrax France * \date 2000 */ +NL_ALIGN_SSE2 class CMatrix { public: diff --git a/code/nel/src/3d/computed_string.cpp b/code/nel/src/3d/computed_string.cpp index a57191cc0..1a9fefba5 100644 --- a/code/nel/src/3d/computed_string.cpp +++ b/code/nel/src/3d/computed_string.cpp @@ -143,11 +143,13 @@ void CComputedString::render2D (IDriver& driver, /*------------------------------------------------------------------*\ render3D() \*------------------------------------------------------------------*/ -void CComputedString::render3D (IDriver& driver,CMatrix matrix,THotSpot hotspot) +void CComputedString::render3D (IDriver& driver, const CMatrix &matrixp, THotSpot hotspot) { if (Vertices.getNumVertices() == 0) return; + CMatrix matrix = matrixp; + // get window size uint32 wndWidth, wndHeight; driver.getWindowSize(wndWidth, wndHeight); From f6ad306a57374b79c9a1f056d0a724ebb85809e4 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 20:25:45 +0200 Subject: [PATCH 06/37] SSE2: Add macro for force inline --HG-- branch : sse2 --- code/nel/include/nel/misc/types_nl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index f4001fd94..a9c6c6cfb 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -329,6 +329,19 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #endif // NL_OS_UNIX +// #ifdef NL_ENABLE_FORCE_INLINE +# ifdef NL_COMP_VC +# define NL_FORCE_INLINE __forceinline +# elif NL_COMP_GCC +# define NL_FORCE_INLINE inline __attribute__((always_inline)) +# else +# define NL_FORCE_INLINE inline +# endif +// #else +// # define NL_FORCE_INLINE inline +// #endif + + #ifdef NL_COMP_VC #define NL_ALIGN(nb) __declspec(align(nb)) #else From 848932f93aa8316a38782f1f477c5520672d0b7b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 00:05:43 +0200 Subject: [PATCH 07/37] SSE2: Fix for MinGW --HG-- branch : sse2 --- code/nel/include/nel/misc/fixed_size_allocator.h | 4 ++-- code/nel/include/nel/misc/matrix.h | 4 ++-- code/nel/include/nel/misc/types_nl.h | 7 +++++-- code/nel/src/misc/matrix.cpp | 9 +++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/code/nel/include/nel/misc/fixed_size_allocator.h b/code/nel/include/nel/misc/fixed_size_allocator.h index 80b9ed491..079c54bc0 100644 --- a/code/nel/include/nel/misc/fixed_size_allocator.h +++ b/code/nel/include/nel/misc/fixed_size_allocator.h @@ -53,8 +53,8 @@ public: uint getNumAllocatedBlocks() const { return _NumAlloc; } private: class CChunk; - NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) - class CNode + + class NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) CNode { public: CChunk *Chunk; // the Chunk this node belongs to. diff --git a/code/nel/include/nel/misc/matrix.h b/code/nel/include/nel/misc/matrix.h index 37a19b655..649d53324 100644 --- a/code/nel/include/nel/misc/matrix.h +++ b/code/nel/include/nel/misc/matrix.h @@ -53,8 +53,8 @@ class CPlane; * \author Nevrax France * \date 2000 */ -NL_ALIGN_SSE2 -class CMatrix + +class NL_ALIGN_SSE2 CMatrix { public: /// Rotation Order. diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 8eaa77930..6f41deff1 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -342,7 +342,7 @@ typedef unsigned int uint; // at least 32bits (depend of processor) // #ifdef NL_ENABLE_FORCE_INLINE # ifdef NL_COMP_VC # define NL_FORCE_INLINE __forceinline -# elif NL_COMP_GCC +# elif defined(NL_COMP_GCC) # define NL_FORCE_INLINE inline __attribute__((always_inline)) # else # define NL_FORCE_INLINE inline @@ -358,7 +358,10 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #define NL_ALIGN(nb) __attribute__((aligned(nb))) #endif -#ifdef NL_COMP_VC +#ifdef NL_OS_WINDOWS +#include +#include +#include inline void *aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); } inline void aligned_free(void *ptr) { _aligned_free(ptr); } #else diff --git a/code/nel/src/misc/matrix.cpp b/code/nel/src/misc/matrix.cpp index dd884f4d5..acfe7ee96 100644 --- a/code/nel/src/misc/matrix.cpp +++ b/code/nel/src/misc/matrix.cpp @@ -140,6 +140,11 @@ inline void CMatrix::testExpandRot() const self->Scale33= 1; } } +void CMatrix::testExpandRotEx() const +{ + testExpandRot(); +} + inline void CMatrix::testExpandProj() const { if(hasProj()) @@ -151,6 +156,10 @@ inline void CMatrix::testExpandProj() const self->a41=0; self->a42=0; self->a43=0; self->a44=1; } } +void CMatrix::testExpandProjEx() const +{ + testExpandProj(); +} // ====================================================================================================== From 71a598db7eb77c3e3cca2bc23c03bbd4335ad26f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 22:21:07 +0200 Subject: [PATCH 08/37] SSE2: Remove dead code --HG-- branch : sse2 --- code/nel/include/nel/3d/matrix_3x4.h | 275 --------------------------- code/nel/src/3d/mesh_mrm_skin.cpp | 118 ------------ code/nel/src/3d/mesh_mrm_skinned.cpp | 117 ------------ 3 files changed, 510 deletions(-) diff --git a/code/nel/include/nel/3d/matrix_3x4.h b/code/nel/include/nel/3d/matrix_3x4.h index d7ed660fc..45901c20e 100644 --- a/code/nel/include/nel/3d/matrix_3x4.h +++ b/code/nel/include/nel/3d/matrix_3x4.h @@ -108,281 +108,6 @@ public: }; -// *************************************************************************** -// *************************************************************************** -// SSE Matrix -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -#if defined(NL_OS_WINDOWS) && !defined(NL_NO_ASM) - - -/** For fast vector/point multiplication. Special usage for Skinning. - * NB: SSE is no more used (no speed gain, some memory problem), but keep it for possible future usage. - */ -class CMatrix3x4SSE -{ -public: - // Order them in memory column first, for SSE column multiplication. - float a11, a21, a31, a41; - float a12, a22, a32, a42; - float a13, a23, a33, a43; - float a14, a24, a34, a44; - - // Copy from a matrix. - void set(const CMatrix &mat) - { - const float *m =mat.get(); - a11= m[0]; a12= m[4]; a13= m[8] ; a14= m[12]; - a21= m[1]; a22= m[5]; a23= m[9] ; a24= m[13]; - a31= m[2]; a32= m[6]; a33= m[10]; a34= m[14]; - // not used. - a41= 0 ; a42= 0 ; a43= 0 ; a44= 1; - } - - - // mulSetvector. NB: in should be different as v!! (else don't work). - void mulSetVector(const CVector &vin, CVector &vout) - { - __asm - { - mov eax, vin - mov ebx, this - mov edi, vout - // Load in vector in op[0] - movss xmm0, [eax]vin.x - movss xmm1, [eax]vin.y - movss xmm2, [eax]vin.z - // Expand op[0] to op[1], op[2], op[3] - shufps xmm0, xmm0, 0 - shufps xmm1, xmm1, 0 - shufps xmm2, xmm2, 0 - // Mul each vector with 3 Matrix column - mulps xmm0, [ebx]this.a11 - mulps xmm1, [ebx]this.a12 - mulps xmm2, [ebx]this.a13 - // Add each column vector. - addps xmm0, xmm1 - addps xmm0, xmm2 - - // write the result. - movss [edi]vout.x, xmm0 - shufps xmm0, xmm0, 33 - movss [edi]vout.y, xmm0 - movhlps xmm0, xmm0 - movss [edi]vout.z, xmm0 - } - } - // mulSetpoint. NB: in should be different as v!! (else don't work). - void mulSetPoint(const CVector &vin, CVector &vout) - { - __asm - { - mov eax, vin - mov ebx, this - mov edi, vout - // Load in vector in op[0] - movss xmm0, [eax]vin.x - movss xmm1, [eax]vin.y - movss xmm2, [eax]vin.z - // Expand op[0] to op[1], op[2], op[3] - shufps xmm0, xmm0, 0 - shufps xmm1, xmm1, 0 - shufps xmm2, xmm2, 0 - // Mul each vector with 3 Matrix column - mulps xmm0, [ebx]this.a11 - mulps xmm1, [ebx]this.a12 - mulps xmm2, [ebx]this.a13 - // Add each column vector. - addps xmm0, xmm1 - addps xmm0, xmm2 - // Add Matrix translate column vector - addps xmm0, [ebx]this.a14 - - // write the result. - movss [edi]vout.x, xmm0 - shufps xmm0, xmm0, 33 - movss [edi]vout.y, xmm0 - movhlps xmm0, xmm0 - movss [edi]vout.z, xmm0 - } - } - - - // mulSetvector. NB: vin should be different as v!! (else don't work). - void mulSetVector(const CVector &vin, float scale, CVector &vout) - { - __asm - { - mov eax, vin - mov ebx, this - mov edi, vout - // Load in vector in op[0] - movss xmm0, [eax]vin.x - movss xmm1, [eax]vin.y - movss xmm2, [eax]vin.z - // Load scale in op[0] - movss xmm3, scale - // Expand op[0] to op[1], op[2], op[3] - shufps xmm0, xmm0, 0 - shufps xmm1, xmm1, 0 - shufps xmm2, xmm2, 0 - shufps xmm3, xmm3, 0 - // Store vertex column in other regs. - movaps xmm5, xmm0 - movaps xmm6, xmm1 - movaps xmm7, xmm2 - // Mul each vector with 3 Matrix column - mulps xmm0, [ebx]this.a11 - mulps xmm1, [ebx]this.a12 - mulps xmm2, [ebx]this.a13 - // Add each column vector. - addps xmm0, xmm1 - addps xmm0, xmm2 - - // mul final result with scale - mulps xmm0, xmm3 - - // store it in xmm4 for future use. - movaps xmm4, xmm0 - } - } - // mulSetpoint. NB: vin should be different as v!! (else don't work). - void mulSetPoint(const CVector &vin, float scale, CVector &vout) - { - __asm - { - mov eax, vin - mov ebx, this - mov edi, vout - // Load in vector in op[0] - movss xmm0, [eax]vin.x - movss xmm1, [eax]vin.y - movss xmm2, [eax]vin.z - // Load scale in op[0] - movss xmm3, scale - // Expand op[0] to op[1], op[2], op[3] - shufps xmm0, xmm0, 0 - shufps xmm1, xmm1, 0 - shufps xmm2, xmm2, 0 - shufps xmm3, xmm3, 0 - // Store vertex column in other regs. - movaps xmm5, xmm0 - movaps xmm6, xmm1 - movaps xmm7, xmm2 - // Mul each vector with 3 Matrix column - mulps xmm0, [ebx]this.a11 - mulps xmm1, [ebx]this.a12 - mulps xmm2, [ebx]this.a13 - // Add each column vector. - addps xmm0, xmm1 - addps xmm0, xmm2 - // Add Matrix translate column vector - addps xmm0, [ebx]this.a14 - - // mul final result with scale - mulps xmm0, xmm3 - - // store it in xmm4 for future use. - movaps xmm4, xmm0 - } - } - - - // mulAddvector. NB: vin should be different as v!! (else don't work). - void mulAddVector(const CVector &/* vin */, float scale, CVector &vout) - { - __asm - { - mov ebx, this - mov edi, vout - // Load vin vector loaded in mulSetVector - movaps xmm0, xmm5 - movaps xmm1, xmm6 - movaps xmm2, xmm7 - // Load scale in op[0] - movss xmm3, scale - // Expand op[0] to op[1], op[2], op[3] - shufps xmm3, xmm3, 0 - // Mul each vector with 3 Matrix column - mulps xmm0, [ebx]this.a11 - mulps xmm1, [ebx]this.a12 - mulps xmm2, [ebx]this.a13 - // Add each column vector. - addps xmm0, xmm1 - addps xmm0, xmm2 - - // mul final result with scale - mulps xmm0, xmm3 - - // Add result, with prec sum. - addps xmm0, xmm4 - - // store it in xmm4 for future use. - movaps xmm4, xmm0 - - // write the result. - movss [edi]vout.x, xmm0 - shufps xmm0, xmm0, 33 - movss [edi]vout.y, xmm0 - movhlps xmm0, xmm0 - movss [edi]vout.z, xmm0 - } - } - // mulAddpoint. NB: vin should be different as v!! (else don't work). - void mulAddPoint(const CVector &/* vin */, float scale, CVector &vout) - { - __asm - { - mov ebx, this - mov edi, vout - // Load vin vector loaded in mulSetPoint - movaps xmm0, xmm5 - movaps xmm1, xmm6 - movaps xmm2, xmm7 - // Load scale in op[0] - movss xmm3, scale - // Expand op[0] to op[1], op[2], op[3] - shufps xmm3, xmm3, 0 - // Mul each vector with 3 Matrix column - mulps xmm0, [ebx]this.a11 - mulps xmm1, [ebx]this.a12 - mulps xmm2, [ebx]this.a13 - // Add each column vector. - addps xmm0, xmm1 - addps xmm0, xmm2 - // Add Matrix translate column vector - addps xmm0, [ebx]this.a14 - - // mul final result with scale - mulps xmm0, xmm3 - - // Add result, with prec sum. - addps xmm0, xmm4 - - // store it in xmm4 for future use. - movaps xmm4, xmm0 - - // write the result. - movss [edi]vout.x, xmm0 - shufps xmm0, xmm0, 33 - movss [edi]vout.y, xmm0 - movhlps xmm0, xmm0 - movss [edi]vout.z, xmm0 - } - } - -}; - -#else // NL_OS_WINDOWS -/// dummy CMatrix3x4SSE for non windows platform -class CMatrix3x4SSE : public CMatrix3x4 { }; -#endif - - - } // NL3D diff --git a/code/nel/src/3d/mesh_mrm_skin.cpp b/code/nel/src/3d/mesh_mrm_skin.cpp index 13e8bdd21..a34eeb766 100644 --- a/code/nel/src/3d/mesh_mrm_skin.cpp +++ b/code/nel/src/3d/mesh_mrm_skin.cpp @@ -39,124 +39,6 @@ namespace NL3D { -// *************************************************************************** -// *************************************************************************** -// CMatrix3x4SSE array correctly aligned -// *************************************************************************** -// *************************************************************************** - - - -// *************************************************************************** -#define NL3D_SSE_ALIGNEMENT 16 -/** - * A CMatrix3x4SSE array correctly aligned - * NB: SSE is no more used (no speed gain, some memory problem), but keep it for possible future usage. - */ -class CMatrix3x4SSEArray -{ -private: - void *_AllocData; - void *_Data; - uint _Size; - uint _Capacity; - -public: - CMatrix3x4SSEArray() - { - _AllocData= NULL; - _Data= NULL; - _Size= 0; - _Capacity= 0; - } - ~CMatrix3x4SSEArray() - { - clear(); - } - CMatrix3x4SSEArray(const CMatrix3x4SSEArray &other) - { - _AllocData= NULL; - _Data= NULL; - _Size= 0; - _Capacity= 0; - *this= other; - } - CMatrix3x4SSEArray &operator=(const CMatrix3x4SSEArray &other) - { - if( this == &other) - return *this; - resize(other.size()); - // copy data from aligned pointers to aligned pointers. - memcpy(_Data, other._Data, size() * sizeof(CMatrix3x4SSE) ); - - return *this; - } - - - CMatrix3x4SSE *getPtr() - { - return (CMatrix3x4SSE*)_Data; - } - - void clear() - { - delete [] ((uint8 *)_AllocData); - _AllocData= NULL; - _Data= NULL; - _Size= 0; - _Capacity= 0; - } - - void resize(uint n) - { - // reserve ?? - if(n>_Capacity) - reserve( max(2*_Capacity, n)); - _Size= n; - } - - void reserve(uint n) - { - if(n==0) - clear(); - else if(n>_Capacity) - { - // Alloc new data. - void *newAllocData; - void *newData; - - // Alloc for alignement. - newAllocData= new uint8 [n * sizeof(CMatrix3x4SSE) + NL3D_SSE_ALIGNEMENT-1]; - if(newAllocData==NULL) - throw Exception("SSE Allocation Failed"); - - // Align ptr - newData= (void*) ( ((ptrdiff_t)newAllocData+NL3D_SSE_ALIGNEMENT-1) & (~(NL3D_SSE_ALIGNEMENT-1)) ); - - // copy valid data from old to new. - memcpy(newData, _Data, size() * sizeof(CMatrix3x4SSE) ); - - // release old. - if(_AllocData) - delete [] ((uint8*)_AllocData); - - // change ptrs and capacity. - _Data= newData; - _AllocData= newAllocData; - _Capacity= n; - - // TestYoyo - //nlwarning("YOYO Tst SSE P4: %X, %d", _Data, n); - } - } - - uint size() const {return _Size;} - - - CMatrix3x4SSE &operator[](uint i) {return ((CMatrix3x4SSE*)_Data)[i];} -}; - - // *************************************************************************** // *************************************************************************** diff --git a/code/nel/src/3d/mesh_mrm_skinned.cpp b/code/nel/src/3d/mesh_mrm_skinned.cpp index 2b1c3beb6..6af29bf73 100644 --- a/code/nel/src/3d/mesh_mrm_skinned.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned.cpp @@ -2247,123 +2247,6 @@ void CMeshMRMSkinnedGeom::getSkinWeights (std::vector &skinW } } -// *************************************************************************** -// *************************************************************************** -// CMatrix3x4SSE array correctly aligned -// *************************************************************************** -// *************************************************************************** - - - -// *************************************************************************** -#define NL3D_SSE_ALIGNEMENT 16 -/** - * A CMatrix3x4SSEArray array correctly aligned - * NB: SSE is no more used (no speed gain, some memory problem), but keep it for possible future usage. - */ -class CMatrix3x4SSEArray -{ -private: - void *_AllocData; - void *_Data; - uint _Size; - uint _Capacity; - -public: - CMatrix3x4SSEArray() - { - _AllocData= NULL; - _Data= NULL; - _Size= 0; - _Capacity= 0; - } - ~CMatrix3x4SSEArray() - { - clear(); - } - CMatrix3x4SSEArray(const CMatrix3x4SSEArray &other) - { - _AllocData= NULL; - _Data= NULL; - _Size= 0; - _Capacity= 0; - *this= other; - } - CMatrix3x4SSEArray &operator=(const CMatrix3x4SSEArray &other) - { - if( this == &other) - return *this; - resize(other.size()); - // copy data from aligned pointers to aligned pointers. - memcpy(_Data, other._Data, size() * sizeof(CMatrix3x4SSE) ); - - return *this; - } - - - CMatrix3x4SSE *getPtr() - { - return (CMatrix3x4SSE*)_Data; - } - - void clear() - { - delete [] ((uint8 *) _AllocData); - _AllocData= NULL; - _Data= NULL; - _Size= 0; - _Capacity= 0; - } - - void resize(uint n) - { - // reserve ?? - if(n>_Capacity) - reserve( max(2*_Capacity, n)); - _Size= n; - } - - void reserve(uint n) - { - if(n==0) - clear(); - else if(n>_Capacity) - { - // Alloc new data. - void *newAllocData; - void *newData; - - // Alloc for alignement. - newAllocData= new uint8 [n * sizeof(CMatrix3x4SSE) + NL3D_SSE_ALIGNEMENT-1]; - if(newAllocData==NULL) - throw Exception("SSE Allocation Failed"); - - // Align ptr - newData= (void*) ( ((ptrdiff_t)newAllocData+NL3D_SSE_ALIGNEMENT-1) & (~(NL3D_SSE_ALIGNEMENT-1)) ); - - // copy valid data from old to new. - memcpy(newData, _Data, size() * sizeof(CMatrix3x4SSE) ); - - // release old. - if(_AllocData) - delete [] ((uint8*)_AllocData); - - // change ptrs and capacity. - _Data= newData; - _AllocData= newAllocData; - _Capacity= n; - - // TestYoyo - //nlwarning("YOYO Tst SSE P4: %X, %d", _Data, n); - } - } - - uint size() const {return _Size;} - - - CMatrix3x4SSE &operator[](uint i) {return ((CMatrix3x4SSE*)_Data)[i];} -}; - // *************************************************************************** // *************************************************************************** From 6734852fa350ee096c249d0a88d5ac3df1b7a84f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 14 Jun 2014 00:38:35 +0200 Subject: [PATCH 09/37] SSE2: Ensure correct allocator is used --HG-- branch : sse2 --- code/nel/include/nel/misc/object_vector.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/nel/include/nel/misc/object_vector.h b/code/nel/include/nel/misc/object_vector.h index a544a62b5..ea9be81e2 100644 --- a/code/nel/include/nel/misc/object_vector.h +++ b/code/nel/include/nel/misc/object_vector.h @@ -29,6 +29,12 @@ # endif // NLMISC_HEAP_ALLOCATION_NDEBUG #endif // NL_USE_DEFAULT_MEMORY_MANAGER +#ifndef NL_OV_USE_NEW_ALLOCATOR +# ifdef NL_HAS_SSE2 +# define NL_OV_USE_NEW_ALLOCATOR +# endif // NL_HAS_SSE2 +#endif // NL_OV_USE_NEW_ALLOCATOR + namespace NLMISC { From cec2970169fabb98b9f73bfd756ebf256f940c69 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 14 Jun 2014 01:09:05 +0200 Subject: [PATCH 10/37] SSE2: Replace prefetch --HG-- branch : sse2 --- code/nel/src/3d/mesh_mrm_skin_template.cpp | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/code/nel/src/3d/mesh_mrm_skin_template.cpp b/code/nel/src/3d/mesh_mrm_skin_template.cpp index 1958cae90..4a9e11106 100644 --- a/code/nel/src/3d/mesh_mrm_skin_template.cpp +++ b/code/nel/src/3d/mesh_mrm_skin_template.cpp @@ -39,7 +39,23 @@ static void applyArraySkinNormalT(uint numMatrixes, uint32 *infPtr, CMesh::CSkin { /* Prefetch all vertex/normal before, it is to be faster. */ -#if defined(NL_OS_WINDOWS) && !defined(NL_NO_ASM) +#ifdef NL_HAS_SSE2 + { + uint nInfTmp= nInf; + uint32 *infTmpPtr= infPtr; + for(;nInfTmp>0;nInfTmp--, infTmpPtr++) + { + uint index= *infTmpPtr; + CMesh::CSkinWeight *srcSkin= srcSkinPtr + index; + CVector *srcVertex= srcVertexPtr + index; + CVector *srcNormal= srcNormalPtr + index; + + _mm_prefetch((const char *)(void *)srcSkin, _MM_HINT_T1); + _mm_prefetch((const char *)(void *)srcVertex, _MM_HINT_T1); + _mm_prefetch((const char *)(void *)srcNormal, _MM_HINT_T1); + } + } +#elif defined(NL_OS_WINDOWS) && !defined(NL_NO_ASM) { uint nInfTmp= nInf; uint32 *infTmpPtr= infPtr; @@ -176,7 +192,25 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh: { /* Prefetch all vertex/normal/tgSpace before, it is faster. */ -#if defined(NL_OS_WINDOWS) && !defined(NL_NO_ASM) +#ifdef NL_HAS_SSE2 + { + uint nInfTmp= nInf; + uint32 *infTmpPtr= infPtr; + for(;nInfTmp>0;nInfTmp--, infTmpPtr++) + { + uint index= *infTmpPtr; + CMesh::CSkinWeight *srcSkin= srcSkinPtr + index; + CVector *srcVertex= srcVertexPtr + index; + CVector *srcNormal= srcNormalPtr + index; + CVector *srcTgSpace= tgSpacePtr + index; + + _mm_prefetch((const char *)(void *)srcSkin, _MM_HINT_T1); + _mm_prefetch((const char *)(void *)srcVertex, _MM_HINT_T1); + _mm_prefetch((const char *)(void *)srcNormal, _MM_HINT_T1); + _mm_prefetch((const char *)(void *)srcTgSpace, _MM_HINT_T1); + } + } +#elif defined(NL_OS_WINDOWS) && !defined(NL_NO_ASM) { uint nInfTmp= nInf; uint32 *infTmpPtr= infPtr; From 3dd11fe157d305cfa785f4e849a7733933f0d964 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 17 Jun 2014 21:48:25 +0200 Subject: [PATCH 11/37] Fix compilation of NLMISC under MinGW --- code/CMakeModules/nel.cmake | 4 +- code/nel/include/nel/misc/di_event_emitter.h | 6 ++- .../include/nel/misc/inter_window_msg_queue.h | 2 +- code/nel/include/nel/misc/types_nl.h | 16 +++++-- code/nel/include/nel/misc/win_displayer.h | 4 +- code/nel/src/misc/bitmap_jpeg.cpp | 3 ++ code/nel/src/misc/co_task.cpp | 4 +- code/nel/src/misc/common.cpp | 8 +++- code/nel/src/misc/debug.cpp | 28 ++++++------ code/nel/src/misc/di_game_device.cpp | 2 +- code/nel/src/misc/di_keyboard_device.cpp | 6 +-- code/nel/src/misc/di_mouse_device.cpp | 8 +++- code/nel/src/misc/displayer.cpp | 6 ++- code/nel/src/misc/dynloadlib.cpp | 2 +- code/nel/src/misc/log.cpp | 4 +- code/nel/src/misc/mem_displayer.cpp | 43 +++++++++++-------- code/nel/src/misc/mutex.cpp | 6 ++- code/nel/src/misc/path.cpp | 4 +- code/nel/src/misc/report.cpp | 18 ++++---- code/nel/src/misc/shared_memory.cpp | 4 +- code/nel/src/misc/stdmisc.h | 8 ++-- code/nel/src/misc/system_info.cpp | 7 ++- code/nel/src/misc/system_utils.cpp | 9 ++-- code/nel/src/misc/tds.cpp | 4 +- code/nel/src/misc/time_nl.cpp | 4 +- code/nel/src/misc/win_displayer.cpp | 23 +++++----- code/nel/src/misc/win_event_emitter.cpp | 2 + code/nel/src/misc/win_thread.cpp | 2 + code/nel/src/sound/driver/sound_driver.cpp | 4 +- 29 files changed, 157 insertions(+), 84 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index b194b5ff9..7cf518ddf 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -875,9 +875,9 @@ MACRO(NL_SETUP_BUILD) ENDIF(APPLE) # Fix "relocation R_X86_64_32 against.." error on x64 platforms - IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS) + IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS AND NOT MINGW) ADD_PLATFORM_FLAGS("-fPIC") - ENDIF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS) + ENDIF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS AND NOT MINGW) SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") diff --git a/code/nel/include/nel/misc/di_event_emitter.h b/code/nel/include/nel/misc/di_event_emitter.h index a2592e565..41c7bbf47 100644 --- a/code/nel/include/nel/misc/di_event_emitter.h +++ b/code/nel/include/nel/misc/di_event_emitter.h @@ -34,7 +34,9 @@ #include "events.h" #include "rect.h" #include "game_device.h" -#define NOMINMAX +#ifndef NL_COMP_MINGW +# define NOMINMAX +#endif #include #include @@ -101,7 +103,7 @@ public: * \param we A windows eventsemitter. Can be NULL. Needed if you want to mix WIN32 events and Direct Input events * (for example, a Direct Input Mouse and a Win32 Keyboard) */ - static CDIEventEmitter *create(HINSTANCE hinst, HWND hwnd, CWinEventEmitter *we); + static CDIEventEmitter *create(HINSTANCE hinst, HWND hwnd, CWinEventEmitter *we) throw(EDirectInput); ~CDIEventEmitter(); public: diff --git a/code/nel/include/nel/misc/inter_window_msg_queue.h b/code/nel/include/nel/misc/inter_window_msg_queue.h index f65767bce..02867f8b4 100644 --- a/code/nel/include/nel/misc/inter_window_msg_queue.h +++ b/code/nel/include/nel/misc/inter_window_msg_queue.h @@ -220,7 +220,7 @@ private: static TOldWinProcMap _OldWinProcMap; - bool initInternal(HINSTANCE hInstance, HWND ownerWindow, uint32 localId, uint32 foreignId = NULL); + bool initInternal(HINSTANCE hInstance, HWND ownerWindow, uint32 localId, uint32 foreignId = 0); private: static LRESULT CALLBACK listenerProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 5c3b80475..388505bd9 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -86,6 +86,10 @@ # define NL_COMP_VC_VERSION 60 # define NL_COMP_NEED_PARAM_ON_METHOD # endif +# elif defined(__MINGW32__) +# define NL_COMP_MINGW +# define NL_COMP_GCC +# define NL_NO_ASM # endif # if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack or later # define NL_ISO_STDTR1_AVAILABLE @@ -93,9 +97,13 @@ # define NL_ISO_STDTR1_NAMESPACE std::tr1 # endif # ifdef _DEBUG -# define NL_DEBUG +# ifndef NL_DEBUG +# define NL_DEBUG +# endif # elif defined (NDEBUG) -# define NL_RELEASE +# ifndef NL_RELEASE +# define NL_RELEASE +# endif # else # error "Don't know the compilation mode" # endif @@ -109,7 +117,9 @@ # define _WIN32_WINNT 0x0600 // force VISTA minimal version in 64 bits # endif // define NOMINMAX to be sure that windows includes will not define min max macros, but instead, use the stl template -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif #else # ifdef __APPLE__ # define NL_OS_MAC diff --git a/code/nel/include/nel/misc/win_displayer.h b/code/nel/include/nel/misc/win_displayer.h index 0bd16fa40..934a6e990 100644 --- a/code/nel/include/nel/misc/win_displayer.h +++ b/code/nel/include/nel/misc/win_displayer.h @@ -22,7 +22,9 @@ #ifdef NL_OS_WINDOWS #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#define NOMINMAX +#ifndef NL_COMP_MINGW +# define NOMINMAX +#endif #include #include "displayer.h" diff --git a/code/nel/src/misc/bitmap_jpeg.cpp b/code/nel/src/misc/bitmap_jpeg.cpp index 799d659d6..a43c707e7 100644 --- a/code/nel/src/misc/bitmap_jpeg.cpp +++ b/code/nel/src/misc/bitmap_jpeg.cpp @@ -26,6 +26,9 @@ #include extern "C" { + #ifdef NL_COMP_MINGW + # define HAVE_BOOLEAN + #endif #include } #endif diff --git a/code/nel/src/misc/co_task.cpp b/code/nel/src/misc/co_task.cpp index 91b0132a9..d238b4853 100644 --- a/code/nel/src/misc/co_task.cpp +++ b/code/nel/src/misc/co_task.cpp @@ -53,7 +53,9 @@ # define _WIN32_WINNT 0x0400 # endif -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined (NL_OS_UNIX) # define NL_WIN_CALLBACK diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 36e167260..2303944e3 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -20,7 +20,9 @@ #include "nel/misc/common.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include # include @@ -37,6 +39,7 @@ using namespace std; +#ifndef NL_COMP_MINGW #ifdef NL_OS_WINDOWS # pragma message( " " ) @@ -69,6 +72,7 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #endif // NL_OS_WINDOWS +#endif // !NL_COMP_MINGW #ifdef DEBUG_NEW @@ -1040,7 +1044,7 @@ bool openDoc (const char *document) HINSTANCE result = ShellExecuteA(NULL, "open", document, NULL,NULL, SW_SHOWDEFAULT); // If it failed, get the .htm regkey and lookup the program - if ((UINT)result <= HINSTANCE_ERROR) + if ((uintptr_t)result <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, ext.c_str(), key) == ERROR_SUCCESS) { diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 28f40f641..c7667acc2 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -34,8 +34,10 @@ #ifdef NL_OS_WINDOWS # define _WIN32_WINDOWS 0x0410 +# ifndef NL_COMP_MINGW # define WINVER 0x0400 -# define NOMINMAX +# define NOMINMAX +# endif # include # include # include @@ -445,7 +447,7 @@ public: EDebug() { _Reason = "Nothing about EDebug"; } - ~EDebug () { } + virtual ~EDebug() throw() {} EDebug(EXCEPTION_POINTERS * pexp) : m_pexp(pexp) { nlassert(pexp != 0); createWhat(); } EDebug(const EDebug& se) : m_pexp(se.m_pexp) { createWhat(); } @@ -755,7 +757,7 @@ public: HANDLE getProcessHandle() { - return CSystemInfo::isNT()?GetCurrentProcess():(HANDLE)GetCurrentProcessId(); + return CSystemInfo::isNT()?GetCurrentProcess():(HANDLE)(uintptr_t)GetCurrentProcessId(); } // return true if found @@ -797,7 +799,7 @@ public: while (findAndErase(rawType, "classvector,class allocator >", "string")) ; } - string getFuncInfo (DWORD funcAddr, DWORD stackAddr) + string getFuncInfo (uintptr_t funcAddr, uintptr_t stackAddr) { string str ("NoSymbol"); @@ -853,7 +855,7 @@ public: if (stop==0 && (parse[i] == ',' || parse[i] == ')')) { - ULONG *addr = (ULONG*)(stackAddr) + 2 + pos2++; + uintptr_t *addr = (uintptr_t*)(stackAddr) + 2 + pos2++; string displayType = type; cleanType (type, displayType); @@ -882,7 +884,7 @@ public: } else if (type == "char*") { - if (!IsBadReadPtr(addr,sizeof(char*)) && *addr != NULL) + if (!IsBadReadPtr(addr,sizeof(char*)) && *addr != 0) { if (!IsBadStringPtrA((char*)*addr,32)) { @@ -920,7 +922,7 @@ public: { if (!IsBadReadPtr(addr,sizeof(string*))) { - if (*addr != NULL) + if (*addr != 0) { if (!IsBadReadPtr((void*)*addr,sizeof(string))) sprintf (tmp, "\"%s\"", ((string*)*addr)->c_str()); @@ -929,9 +931,9 @@ public: } else { - if (!IsBadReadPtr(addr,sizeof(ULONG*))) + if (!IsBadReadPtr(addr,sizeof(uintptr_t*))) { - if(*addr == NULL) + if(*addr == 0) sprintf (tmp, ""); else sprintf (tmp, "0x%p", *addr); @@ -956,7 +958,7 @@ public: if (disp != 0) { str += " + "; - str += toString ((uint32)disp); + str += toString ((uintptr_t)disp); str += " bytes"; } } @@ -1166,7 +1168,8 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) initAcquireTimeMap(); #endif -#ifdef NL_OS_WINDOWS +#ifndef NL_COMP_MINGW +# ifdef NL_OS_WINDOWS // if (!IsDebuggerPresent ()) { // Use an environment variable to share the value among the EXE and its child DLLs @@ -1180,7 +1183,8 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, _T("1") ); } } -#endif // NL_OS_WINDOWS +# endif // NL_OS_WINDOWS +#endif //!NL_COMP_MINGW INelContext::getInstance().setErrorLog(new CLog (CLog::LOG_ERROR)); INelContext::getInstance().setWarningLog(new CLog (CLog::LOG_WARNING)); diff --git a/code/nel/src/misc/di_game_device.cpp b/code/nel/src/misc/di_game_device.cpp index 6574b5cde..5adfb4b9b 100644 --- a/code/nel/src/misc/di_game_device.cpp +++ b/code/nel/src/misc/di_game_device.cpp @@ -217,7 +217,7 @@ static void BuildCtrlName(LPCDIDEVICEOBJECTINSTANCE lpddoi, //============================================================================ // A callback to enumerate the controls of a device -static BOOL CALLBACK DIEnumDeviceObjectsCallback +BOOL CALLBACK DIEnumDeviceObjectsCallback ( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef diff --git a/code/nel/src/misc/di_keyboard_device.cpp b/code/nel/src/misc/di_keyboard_device.cpp index 0802019a4..8b5d9c6e1 100644 --- a/code/nel/src/misc/di_keyboard_device.cpp +++ b/code/nel/src/misc/di_keyboard_device.cpp @@ -113,8 +113,8 @@ static const CKeyConv DIToNel[] = {DIK_CONVERT, KeyCONVERT, "CONVERT", false}, {DIK_NOCONVERT, KeyNONCONVERT, "NOCONVERT", true}, // - {DIK_KANA, KeyKANA, false}, - {DIK_KANJI, KeyKANJI, false}, + {DIK_KANA, KeyKANA, "KANA", false}, + {DIK_KANJI, KeyKANJI, "KANJI", false}, }; @@ -164,7 +164,7 @@ CDIKeyboard::CDIKeyboard(CWinEventEmitter *we, HWND hwnd) _RepeatPeriod = (uint) (1000.f / (keybSpeed * (27.5f / 31.f) + 2.5f)); } // get keyboard layout - _KBLayout = ::GetKeyboardLayout(NULL); + _KBLayout = ::GetKeyboardLayout(0); _RepetitionDisabled.resize(NumKeys); _RepetitionDisabled.clearAll(); diff --git a/code/nel/src/misc/di_mouse_device.cpp b/code/nel/src/misc/di_mouse_device.cpp index 2dfcf95f0..273725c5c 100644 --- a/code/nel/src/misc/di_mouse_device.cpp +++ b/code/nel/src/misc/di_mouse_device.cpp @@ -27,6 +27,12 @@ #define new DEBUG_NEW #endif +#ifdef NL_COMP_MINGW +# undef FIELD_OFFSET +# define FIELD_OFFSET(t,f) offsetof(t,f) +#endif + + namespace NLMISC { @@ -78,7 +84,7 @@ void CDIMouse::setMouseMode(TAxis axis, TAxisMode axisMode) //====================================================== CDIMouse::TAxisMode CDIMouse::getMouseMode(TAxis axis) const { - nlassert(axis < NumMouseAxis); + nlassert((int)axis < (int)NumMouseAxis); return _MouseAxisMode[axis]; } diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index a1b1c7de8..d48c44d02 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -39,8 +39,10 @@ // these defines is for IsDebuggerPresent(). it'll not compile on windows 95 // just comment this and the IsDebuggerPresent to compile on windows 95 # define _WIN32_WINDOWS 0x0410 -# define WINVER 0x0400 -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define WINVER 0x0400 +# define NOMINMAX +# endif # include #else # define IsDebuggerPresent() false diff --git a/code/nel/src/misc/dynloadlib.cpp b/code/nel/src/misc/dynloadlib.cpp index 6dcb7e4cf..25f28286e 100644 --- a/code/nel/src/misc/dynloadlib.cpp +++ b/code/nel/src/misc/dynloadlib.cpp @@ -57,7 +57,7 @@ void *nlGetSymbolAddress(NL_LIB_HANDLE libHandle, const std::string &procName) { void *res = 0; #ifdef NL_OS_WINDOWS - res = GetProcAddress(libHandle, procName.c_str()); + res = (void *)GetProcAddress(libHandle, procName.c_str()); #elif defined(NL_OS_UNIX) res = dlsym(libHandle, procName.c_str()); #else diff --git a/code/nel/src/misc/log.cpp b/code/nel/src/misc/log.cpp index 85ec59e04..478a5e338 100644 --- a/code/nel/src/misc/log.cpp +++ b/code/nel/src/misc/log.cpp @@ -19,7 +19,9 @@ #include "nel/misc/log.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include #else diff --git a/code/nel/src/misc/mem_displayer.cpp b/code/nel/src/misc/mem_displayer.cpp index 52d399350..6c6d51d43 100644 --- a/code/nel/src/misc/mem_displayer.cpp +++ b/code/nel/src/misc/mem_displayer.cpp @@ -24,7 +24,9 @@ #include "nel/misc/debug.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include # pragma comment(lib, "imagehlp.lib") @@ -148,7 +150,7 @@ static string getSourceInfo (DWORD_TYPE addr) return str; } -static DWORD_TYPE __stdcall GetModuleBase(HANDLE hProcess, DWORD_TYPE dwReturnAddress) +static uintptr_t __stdcall GetModuleBase(HANDLE hProcess, uintptr_t dwReturnAddress) { IMAGEHLP_MODULE moduleInfo; @@ -169,9 +171,15 @@ static DWORD_TYPE __stdcall GetModuleBase(HANDLE hProcess, DWORD_TYPE dwReturnAd if (cch && (lstrcmp(szFile, "DBFN")== 0)) { - if (!SymLoadModule(hProcess, - NULL, "MN", - NULL, (DWORD) memoryBasicInfo.AllocationBase, 0)) + char mn[] = { 'M', 'N', 0x00 }; +#ifdef NL_OS_WIN64 + if (!SymLoadModule64( +#else + if (!SymLoadModule( +#endif + hProcess, + NULL, mn, + NULL, (uintptr_t)memoryBasicInfo.AllocationBase, 0)) { // DWORD dwError = GetLastError(); // nlinfo("Error: %d", dwError); @@ -179,17 +187,23 @@ static DWORD_TYPE __stdcall GetModuleBase(HANDLE hProcess, DWORD_TYPE dwReturnAd } else { - if (!SymLoadModule(hProcess, - NULL, ((cch) ? szFile : NULL), - NULL, (DWORD) memoryBasicInfo.AllocationBase, 0)) +#ifdef NL_OS_WIN64 + if (!SymLoadModule64( +#else + if (!SymLoadModule( +#endif + hProcess, + NULL, ((cch) ? szFile : NULL), + NULL, (uintptr_t)memoryBasicInfo.AllocationBase, 0)) { // DWORD dwError = GetLastError(); // nlinfo("Error: %d", dwError); } + } - return (DWORD) memoryBasicInfo.AllocationBase; + return (uintptr_t)memoryBasicInfo.AllocationBase; } // else // nlinfo("Error is %d", GetLastError()); @@ -250,19 +264,13 @@ static void displayCallStack (CLog *log) return; } -#ifdef NL_OS_WIN64 - WOW64_CONTEXT context; -#else + // FIXME: Implement this for MinGW +#ifndef NL_COMP_MINGW CONTEXT context; -#endif ::ZeroMemory (&context, sizeof(context)); context.ContextFlags = CONTEXT_FULL; -#ifdef NL_OS_WIN64 - if (Wow64GetThreadContext (GetCurrentThread(), &context) == FALSE) -#else if (GetThreadContext (GetCurrentThread(), &context) == FALSE) -#endif { nlwarning ("DISP: GetThreadContext(%p) failed", GetCurrentThread()); return; @@ -309,6 +317,7 @@ static void displayCallStack (CLog *log) log->displayNL (" %s : %s", srcInfo.c_str(), symInfo.c_str()); } +#endif } #else // NL_OS_WINDOWS diff --git a/code/nel/src/misc/mutex.cpp b/code/nel/src/misc/mutex.cpp index f8a75d2ea..3c86e2b29 100644 --- a/code/nel/src/misc/mutex.cpp +++ b/code/nel/src/misc/mutex.cpp @@ -44,8 +44,10 @@ using namespace std; // these defines are for IsDebuggerPresent(). It'll not compile on windows 95 // just comment this and the IsDebuggerPresent to compile on windows 95 #define _WIN32_WINDOWS 0x0410 -#define WINVER 0x0400 -#define NOMINMAX +#ifndef NL_COMP_MINGW +# define WINVER 0x0400 +# define NOMINMAX +#endif #include #ifdef DEBUG_NEW diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index f92b0bda7..743f8f514 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -25,7 +25,9 @@ #include "nel/misc/xml_pack.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include # include diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 64871e6a3..f440b8d46 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -23,7 +23,9 @@ #include "nel/misc/path.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include # include @@ -232,7 +234,7 @@ TReportResult report (const std::string &title, const std::string &header, const // create the edit control HWND edit = CreateWindowW (L"EDIT", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_LEFT | ES_MULTILINE, 7, 70, 429, 212, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (edit, WM_SETFONT, (LONG) font, TRUE); + SendMessage (edit, WM_SETFONT, (WPARAM) font, TRUE); // set the edit text limit to lot of :) SendMessage (edit, EM_LIMITTEXT, ~0U, 0); @@ -246,7 +248,7 @@ TReportResult report (const std::string &title, const std::string &header, const { // create the combo box control checkIgnore = CreateWindowW (L"BUTTON", L"Don't display this report again", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKBOX, 7, 290, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (checkIgnore, WM_SETFONT, (LONG) font, TRUE); + SendMessage (checkIgnore, WM_SETFONT, (WPARAM) font, TRUE); if(ignoreNextTime) { @@ -256,28 +258,28 @@ TReportResult report (const std::string &title, const std::string &header, const // create the debug button control debug = CreateWindowW (L"BUTTON", L"Debug", WS_CHILD | WS_VISIBLE, 7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (debug, WM_SETFONT, (LONG) font, TRUE); + SendMessage (debug, WM_SETFONT, (WPARAM) font, TRUE); if (debugButton == 0) EnableWindow(debug, FALSE); // create the ignore button control ignore = CreateWindowW (L"BUTTON", L"Ignore", WS_CHILD | WS_VISIBLE, 75+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (ignore, WM_SETFONT, (LONG) font, TRUE); + SendMessage (ignore, WM_SETFONT, (WPARAM) font, TRUE); if (ignoreButton == 0) EnableWindow(ignore, FALSE); // create the quit button control quit = CreateWindowW (L"BUTTON", L"Quit", WS_CHILD | WS_VISIBLE, 75+75+7+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (quit, WM_SETFONT, (LONG) font, TRUE); + SendMessage (quit, WM_SETFONT, (WPARAM) font, TRUE); if (quitButton == 0) EnableWindow(quit, FALSE); // create the debug button control sendReport = CreateWindowW (L"BUTTON", L"Don't send the report", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 7, 315+32, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (sendReport, WM_SETFONT, (LONG) font, TRUE); + SendMessage (sendReport, WM_SETFONT, (WPARAM) font, TRUE); string formatedHeader; if (header.empty()) @@ -302,7 +304,7 @@ TReportResult report (const std::string &title, const std::string &header, const // create the label control HWND label = CreateWindowW (L"STATIC", (LPCWSTR)uc.c_str(), WS_CHILD | WS_VISIBLE /*| SS_WHITERECT*/, 7, 7, 429, 51, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); - SendMessage (label, WM_SETFONT, (LONG) font, TRUE); + SendMessage (label, WM_SETFONT, (WPARAM) font, TRUE); DebugDefaultBehavior = debugButton==1; diff --git a/code/nel/src/misc/shared_memory.cpp b/code/nel/src/misc/shared_memory.cpp index 2a7f85a8b..7b11fea52 100644 --- a/code/nel/src/misc/shared_memory.cpp +++ b/code/nel/src/misc/shared_memory.cpp @@ -20,7 +20,9 @@ #include "nel/misc/debug.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #else # include diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 432ec02b0..b98d92d2a 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -43,9 +43,11 @@ #include #ifdef _WIN32 - #define NOMINMAX - #include - #include +# ifndef __MINGW32__ + #define NOMINMAX +# endif +# include +# include #endif #endif // NL_STDMISC_H diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index 1fa91db6c..31cde5283 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -19,7 +19,9 @@ #include "nel/misc/system_info.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include # include @@ -1484,7 +1486,8 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion) { VS_FIXEDFILEINFO *info; UINT len; - if (_VerQueryValue(&buffer[0], "\\", (VOID**)&info, &len)) + char bslash[] = { '\\', 0x00 }; + if (_VerQueryValue(&buffer[0], bslash, (VOID**)&info, &len)) { driverVersion = (((uint64)info->dwFileVersionMS)<<32)|info->dwFileVersionLS; return true; diff --git a/code/nel/src/misc/system_utils.cpp b/code/nel/src/misc/system_utils.cpp index c60364741..a66eed02f 100644 --- a/code/nel/src/misc/system_utils.cpp +++ b/code/nel/src/misc/system_utils.cpp @@ -18,7 +18,9 @@ #include "nel/misc/system_utils.h" #ifdef NL_OS_WINDOWS - #define NOMINMAX + #ifndef NL_COMP_MINGW + #define NOMINMAX + #endif #include #ifdef _WIN32_WINNT_WIN7 @@ -222,7 +224,7 @@ bool CSystemUtils::supportUnicode() bool CSystemUtils::isAzertyKeyboard() { #ifdef NL_OS_WINDOWS - uint16 klId = uint16((uint32)GetKeyboardLayout(0) & 0xFFFF); + uint16 klId = uint16((uintptr_t)GetKeyboardLayout(0) & 0xFFFF); // 0x040c is French, 0x080c is Belgian if (klId == 0x040c || klId == 0x080c) return true; @@ -312,7 +314,8 @@ bool CSystemUtils::setRegKey(const string &ValueName, const string &Value) HKEY hkey; DWORD dwDisp; - if (RegCreateKeyExA(HKEY_CURRENT_USER, RootKey.c_str(), 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS) + char nstr[] = { 0x00 }; + if (RegCreateKeyExA(HKEY_CURRENT_USER, RootKey.c_str(), 0, nstr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS) { if (RegSetValueExA(hkey, ValueName.c_str(), 0L, REG_SZ, (const BYTE *)Value.c_str(), (DWORD)(Value.size())+1) == ERROR_SUCCESS) res = true; diff --git a/code/nel/src/misc/tds.cpp b/code/nel/src/misc/tds.cpp index 13105f98d..170cda97d 100644 --- a/code/nel/src/misc/tds.cpp +++ b/code/nel/src/misc/tds.cpp @@ -20,7 +20,9 @@ #include "nel/misc/debug.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 0ba60c8e2..8aacbd002 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -21,7 +21,9 @@ #include "nel/misc/thread.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined (NL_OS_UNIX) # include diff --git a/code/nel/src/misc/win_displayer.cpp b/code/nel/src/misc/win_displayer.cpp index f5c0d9545..95b6b34cf 100644 --- a/code/nel/src/misc/win_displayer.cpp +++ b/code/nel/src/misc/win_displayer.cpp @@ -18,8 +18,9 @@ #include "nel/misc/win_displayer.h" #ifdef NL_OS_WINDOWS - -#define NOMINMAX +#ifndef NL_COMP_MINGW +# define NOMINMAX +#endif #include #include #include @@ -263,7 +264,7 @@ void CWinDisplayer::updateLabels () { access.value()[i].Hwnd = CreateWindowW (L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_SIMPLE, 0, 0, 0, 0, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL); } - SendMessage ((HWND)access.value()[i].Hwnd, WM_SETFONT, (LONG) _HFont, TRUE); + SendMessage ((HWND)access.value()[i].Hwnd, WM_SETFONT, (WPARAM)_HFont, TRUE); needResize = true; } @@ -285,7 +286,7 @@ void CWinDisplayer::updateLabels () } } - SendMessage ((HWND)access.value()[i].Hwnd, WM_SETTEXT, 0, (LONG) n.c_str()); + SendMessage ((HWND)access.value()[i].Hwnd, WM_SETTEXT, 0, (LPARAM) n.c_str()); access.value()[i].NeedUpdate = false; } } @@ -422,7 +423,7 @@ void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint dwStyle |= WS_HSCROLL; _HEdit = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, RICHEDIT_CLASSW, L"", dwStyle, 0, _ToolBarHeight, w, h-_ToolBarHeight-_InputEditHeight, _HWnd, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL); - SendMessage (_HEdit, WM_SETFONT, (LONG) _HFont, TRUE); + SendMessage (_HEdit, WM_SETFONT, (WPARAM)_HFont, TRUE); // set the edit text limit to lot of :) SendMessage (_HEdit, EM_LIMITTEXT, -1, 0); @@ -436,7 +437,7 @@ void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint _HInputEdit = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW, RICHEDIT_CLASSW, L"", WS_CHILD | WS_VISIBLE /*| ES_MULTILINE*/ | ES_WANTRETURN | ES_NOHIDESEL | ES_AUTOHSCROLL, 0, h-_InputEditHeight, w, _InputEditHeight, _HWnd, NULL, (HINSTANCE) GetWindowLongPtr(_HWnd, GWLP_HINSTANCE), NULL); - SendMessageW (_HInputEdit, WM_SETFONT, (LONG) _HFont, TRUE); + SendMessageW (_HInputEdit, WM_SETFONT, (WPARAM)_HFont, TRUE); LRESULT dwEvent = SendMessageW(_HInputEdit, EM_GETEVENTMASK, (WPARAM)0, (LPARAM)0); dwEvent |= ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE; @@ -486,7 +487,7 @@ void CWinDisplayer::clear () SendMessageW (_HEdit, EM_SETSEL, 0, nIndex); // clear all the text - SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LONG) ""); + SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) ""); SendMessageW(_HEdit,EM_SETMODIFY,(WPARAM)TRUE,(LPARAM)0); @@ -535,7 +536,7 @@ void CWinDisplayer::display_main () // store old selection DWORD startSel, endSel; - SendMessage (_HEdit, EM_GETSEL, (LONG)&startSel, (LONG)&endSel); + SendMessage (_HEdit, EM_GETSEL, (WPARAM)&startSel, (LPARAM)&endSel); // find how many lines we have to remove in the current output to add new lines @@ -549,7 +550,7 @@ void CWinDisplayer::display_main () if (nblineremove == _HistorySize) { - SendMessage (_HEdit, WM_SETTEXT, 0, (LONG) ""); + SendMessage (_HEdit, WM_SETTEXT, 0, (LPARAM) ""); startSel = endSel = -1; } else @@ -559,7 +560,7 @@ void CWinDisplayer::display_main () LRESULT oldIndex2 = SendMessageW (_HEdit, EM_LINEINDEX, nblineremove, 0); //nlassert (oldIndex2 != -1); SendMessageW (_HEdit, EM_SETSEL, oldIndex1, oldIndex2); - SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LONG) ""); + SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) ""); // update the selection due to the erasing sint dt = (sint)(oldIndex2 - oldIndex1); @@ -599,7 +600,7 @@ void CWinDisplayer::display_main () } // add the string to the edit control - SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LONG) str.c_str()); + SendMessageW (_HEdit, EM_REPLACESEL, FALSE, (LPARAM) str.c_str()); } // restore old selection diff --git a/code/nel/src/misc/win_event_emitter.cpp b/code/nel/src/misc/win_event_emitter.cpp index bb43e290b..3c74d9241 100644 --- a/code/nel/src/misc/win_event_emitter.cpp +++ b/code/nel/src/misc/win_event_emitter.cpp @@ -22,7 +22,9 @@ #include "nel/misc/event_server.h" #ifdef NL_OS_WINDOWS +#ifndef NL_COMP_MINGW #define NOMINMAX +#endif #include #include diff --git a/code/nel/src/misc/win_thread.cpp b/code/nel/src/misc/win_thread.cpp index d90d081ff..f556779ba 100644 --- a/code/nel/src/misc/win_thread.cpp +++ b/code/nel/src/misc/win_thread.cpp @@ -20,7 +20,9 @@ #ifdef NL_OS_WINDOWS #include "nel/misc/path.h" +#ifndef NL_COMP_MINGW #define NOMINMAX +#endif #include #include diff --git a/code/nel/src/sound/driver/sound_driver.cpp b/code/nel/src/sound/driver/sound_driver.cpp index 145344b8a..a1c0a94fd 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -34,7 +34,9 @@ #endif // HAVE_CONFIG_H #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS From 1df9bec5638f0ce4c828d9a276a34335e618d769 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 17 Jun 2014 21:56:53 +0200 Subject: [PATCH 12/37] Fix compilation of NLNET under MinGW --- code/nel/src/ligo/stdligo.h | 4 +++- code/nel/src/ligo/zone_bank.cpp | 2 ++ code/nel/src/net/buf_client.cpp | 4 +++- code/nel/src/net/buf_server.cpp | 4 +++- code/nel/src/net/buf_sock.cpp | 4 +++- code/nel/src/net/listen_sock.cpp | 4 +++- code/nel/src/net/service.cpp | 6 ++++-- code/nel/src/net/sock.cpp | 4 +++- code/nel/src/net/stdnet.h | 4 +++- code/nel/src/net/tcp_sock.cpp | 4 +++- code/nel/src/net/udp_sock.cpp | 4 +++- 11 files changed, 33 insertions(+), 11 deletions(-) diff --git a/code/nel/src/ligo/stdligo.h b/code/nel/src/ligo/stdligo.h index 3c86f25e6..c8f4e2a9a 100644 --- a/code/nel/src/ligo/stdligo.h +++ b/code/nel/src/ligo/stdligo.h @@ -63,6 +63,8 @@ #include "nel/misc/file.h" #ifdef NL_OS_WINDOWS - #define NOMINMAX + #ifndef NL_COMP_MINGW + #define NOMINMAX + #endif #include #endif diff --git a/code/nel/src/ligo/zone_bank.cpp b/code/nel/src/ligo/zone_bank.cpp index ff24821af..a099168f8 100644 --- a/code/nel/src/ligo/zone_bank.cpp +++ b/code/nel/src/ligo/zone_bank.cpp @@ -25,7 +25,9 @@ #include "nel/misc/o_xml.h" #ifdef NL_OS_WINDOWS +#ifndef NL_COMP_MINGW #define NOMINMAX +#endif #include #endif // NL_OS_WINDOWS diff --git a/code/nel/src/net/buf_client.cpp b/code/nel/src/net/buf_client.cpp index 939dbc89a..350b2d6db 100644 --- a/code/nel/src/net/buf_client.cpp +++ b/code/nel/src/net/buf_client.cpp @@ -24,7 +24,9 @@ #include "nel/net/net_log.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined NL_OS_UNIX # include diff --git a/code/nel/src/net/buf_server.cpp b/code/nel/src/net/buf_server.cpp index 44c966e11..09b061fd4 100644 --- a/code/nel/src/net/buf_server.cpp +++ b/code/nel/src/net/buf_server.cpp @@ -22,7 +22,9 @@ #include "nel/net/net_log.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined NL_OS_UNIX # include diff --git a/code/nel/src/net/buf_sock.cpp b/code/nel/src/net/buf_sock.cpp index e7f07085d..8535435b0 100644 --- a/code/nel/src/net/buf_sock.cpp +++ b/code/nel/src/net/buf_sock.cpp @@ -25,7 +25,9 @@ #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined NL_OS_UNIX # include diff --git a/code/nel/src/net/listen_sock.cpp b/code/nel/src/net/listen_sock.cpp index 8c9802076..7dedd6b97 100644 --- a/code/nel/src/net/listen_sock.cpp +++ b/code/nel/src/net/listen_sock.cpp @@ -22,7 +22,9 @@ #ifdef NL_OS_WINDOWS -#define NOMINMAX +#ifndef NL_COMP_MINGW +# define NOMINMAX +#endif #include typedef sint socklen_t; diff --git a/code/nel/src/net/service.cpp b/code/nel/src/net/service.cpp index 3a6991485..f42806245 100644 --- a/code/nel/src/net/service.cpp +++ b/code/nel/src/net/service.cpp @@ -24,8 +24,10 @@ // these defines is for IsDebuggerPresent(). it'll not compile on windows 95 // just comment this and the IsDebuggerPresent to compile on windows 95 # define _WIN32_WINDOWS 0x0410 -# define WINVER 0x0400 -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define WINVER 0x0400 +# define NOMINMAX +# endif # include # include #elif defined NL_OS_UNIX diff --git a/code/nel/src/net/sock.cpp b/code/nel/src/net/sock.cpp index 2a88ca967..0e2329733 100644 --- a/code/nel/src/net/sock.cpp +++ b/code/nel/src/net/sock.cpp @@ -22,7 +22,9 @@ #include "nel/misc/hierarchical_timer.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include # define socklen_t int diff --git a/code/nel/src/net/stdnet.h b/code/nel/src/net/stdnet.h index 3a67ea783..d18db3222 100644 --- a/code/nel/src/net/stdnet.h +++ b/code/nel/src/net/stdnet.h @@ -17,7 +17,9 @@ #include "nel/misc/types_nl.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include #endif // NL_OS_WINDOWS diff --git a/code/nel/src/net/tcp_sock.cpp b/code/nel/src/net/tcp_sock.cpp index 12948e033..ed04b21b4 100644 --- a/code/nel/src/net/tcp_sock.cpp +++ b/code/nel/src/net/tcp_sock.cpp @@ -21,7 +21,9 @@ #ifdef NL_OS_WINDOWS # include -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # define socklen_t int # define ERROR_NUM WSAGetLastError() diff --git a/code/nel/src/net/udp_sock.cpp b/code/nel/src/net/udp_sock.cpp index a7dcd4483..16b75d929 100644 --- a/code/nel/src/net/udp_sock.cpp +++ b/code/nel/src/net/udp_sock.cpp @@ -21,7 +21,9 @@ #ifdef NL_OS_WINDOWS # include -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # define socklen_t int # define ERROR_NUM WSAGetLastError() From 5bd6c5e06bf2d1e5cf92a7c3dac2a7df0f6952c3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 17 Jun 2014 22:33:56 +0200 Subject: [PATCH 13/37] Fix compilation of NL3D under MinGW --- code/nel/src/3d/dru.cpp | 4 +++- code/nel/src/3d/zone_lighter.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index 503ebdc0f..22d207682 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -35,7 +35,9 @@ #endif // HAVE_CONFIG_H #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #else // NL_OS_WINDOWS # include diff --git a/code/nel/src/3d/zone_lighter.cpp b/code/nel/src/3d/zone_lighter.cpp index 1d7ec5a66..f5549e66a 100644 --- a/code/nel/src/3d/zone_lighter.cpp +++ b/code/nel/src/3d/zone_lighter.cpp @@ -37,7 +37,9 @@ #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include #endif // NL_OS_WINDOWS From 2f3f12e03486f018a1bab7c1ad0b9935b286fd1f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 00:28:08 +0200 Subject: [PATCH 14/37] Fix linking of OpenAL driver under MinGW --- code/nel/src/misc/CMakeLists.txt | 2 +- code/nel/src/misc/report.cpp | 2 ++ .../src/sound/driver/openal/driver_openal.def | 10 ++++++---- .../sound/driver/openal/sound_driver_al.cpp | 13 ++++++++++-- code/nel/src/sound/driver/sound_driver.cpp | 20 ++++++++++++++----- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index dc5b87e2c..0f61fd850 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -27,7 +27,7 @@ ENDIF(WITH_STATIC OR WIN32) # For DirectInput (di_event_emitter) IF(WIN32) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(nelmisc ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) + TARGET_LINK_LIBRARIES(nelmisc ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY} winmm dbghelp) ENDIF(WIN32) IF(UNIX) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index f440b8d46..20b2b1c11 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -159,8 +159,10 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM // if the dtor call order is not good. //exit(EXIT_SUCCESS); #ifdef NL_OS_WINDOWS +#ifndef NL_COMP_MINGW // disable the Windows popup telling that the application aborted and disable the dr watson report. _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); +#endif #endif // quit without calling atexit or static object dtors. abort(); diff --git a/code/nel/src/sound/driver/openal/driver_openal.def b/code/nel/src/sound/driver/openal/driver_openal.def index 41e42cf9d..a8b0c2781 100644 --- a/code/nel/src/sound/driver/openal/driver_openal.def +++ b/code/nel/src/sound/driver/openal/driver_openal.def @@ -1,4 +1,6 @@ -EXPORTS NLSOUND_createISoundDriverInstance -EXPORTS NLSOUND_interfaceVersion -EXPORTS NLSOUND_outputProfile -EXPORTS NLSOUND_getDriverType +LIBRARY nel_drv_openal_win_r +EXPORTS + NLSOUND_createISoundDriverInstance + NLSOUND_interfaceVersion + NLSOUND_outputProfile + NLSOUND_getDriverType \ No newline at end of file diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.cpp b/code/nel/src/sound/driver/openal/sound_driver_al.cpp index 40ea39d0b..82f52b782 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.cpp +++ b/code/nel/src/sound/driver/openal/sound_driver_al.cpp @@ -92,7 +92,12 @@ NLMISC_DECL_PURE_LIB(CSoundDriverALNelLibrary) * Sound driver instance creation */ #ifdef NL_OS_WINDOWS - +#ifdef NL_COMP_MINGW +#ifndef NL_STATIC +extern "C" +{ +#endif +#endif // ****************************************************************** #ifdef NL_STATIC @@ -140,7 +145,11 @@ __declspec(dllexport) ISoundDriver::TDriver NLSOUND_getDriverType() } // ****************************************************************** - +#ifdef NL_COMP_MINGW +#ifndef NL_STATIC +} +#endif +#endif #elif defined (NL_OS_UNIX) #ifndef NL_STATIC diff --git a/code/nel/src/sound/driver/sound_driver.cpp b/code/nel/src/sound/driver/sound_driver.cpp index a1c0a94fd..4a87df307 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -153,7 +153,9 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD switch(driverType) { case DriverFMod: -#if defined (NL_OS_WINDOWS) +#if defined (NL_COMP_MINGW) + dllName = "libnel_drv_fmod_win"; +#elif defined (NL_OS_WINDOWS) dllName = "nel_drv_fmod_win"; #elif defined (NL_OS_UNIX) dllName = "nel_drv_fmod"; @@ -162,7 +164,9 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD #endif // NL_OS_UNIX / NL_OS_WINDOWS break; case DriverOpenAl: -#ifdef NL_OS_WINDOWS +#if defined (NL_COMP_MINGW) + dllName = "libnel_drv_openal_win"; +#elif defined (NL_OS_WINDOWS) dllName = "nel_drv_openal_win"; #elif defined (NL_OS_UNIX) dllName = "nel_drv_openal"; @@ -171,7 +175,9 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD #endif break; case DriverDSound: -#ifdef NL_OS_WINDOWS +#if defined (NL_COMP_MINGW) + dllName = "libnel_drv_dsound_win"; +#elif defined (NL_OS_WINDOWS) dllName = "nel_drv_dsound_win"; #elif defined (NL_OS_UNIX) nlerror("DriverDSound doesn't exist on Unix because it requires DirectX"); @@ -180,7 +186,9 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD #endif break; case DriverXAudio2: -#ifdef NL_OS_WINDOWS +#if defined (NL_COMP_MINGW) + dllName = "libnel_drv_xaudio2_win"; +#elif defined (NL_OS_WINDOWS) dllName = "nel_drv_xaudio2_win"; #elif defined (NL_OS_UNIX) nlerror("DriverXAudio2 doesn't exist on Unix because it requires DirectX"); @@ -189,7 +197,9 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD #endif break; default: -#ifdef NL_OS_WINDOWS +#if defined (NL_COMP_MINGW) + dllName = "libnel_drv_xaudio2_win"; +#elif defined (NL_OS_WINDOWS) dllName = "nel_drv_xaudio2_win"; #elif defined (NL_OS_UNIX) dllName = "nel_drv_openal"; From f4fd8bb669d684140d40ba0080921466d67a8a42 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 01:21:05 +0200 Subject: [PATCH 15/37] Fix linking of OpenGL driver under MinGW --- code/nel/include/nel/3d/driver.h | 2 +- code/nel/include/nel/3d/driver_user.h | 2 +- code/nel/include/nel/3d/dru.h | 7 +++++-- code/nel/include/nel/3d/u_driver.h | 4 ++-- code/nel/src/3d/driver/direct3d/driver_direct3d.cpp | 2 +- code/nel/src/3d/driver/direct3d/driver_direct3d.h | 2 +- code/nel/src/3d/driver/opengl/CMakeLists.txt | 2 +- code/nel/src/3d/driver/opengl/driver_opengl.cpp | 9 +++++++-- code/nel/src/3d/driver/opengl/driver_opengl.def | 6 ++++-- code/nel/src/3d/driver/opengl/driver_opengl.h | 2 +- code/nel/src/3d/driver/opengl/driver_opengl_window.cpp | 2 +- code/nel/src/3d/driver/opengl/stdopengl.h | 4 +++- code/nel/src/3d/driver_user.cpp | 6 +++--- 13 files changed, 31 insertions(+), 19 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 3eb5823ca..c04fffcdf 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -182,7 +182,7 @@ public: IDriver(); virtual ~IDriver(); - virtual bool init(uint windowIcon = 0, emptyProc exitFunc = 0) = 0; + virtual bool init(uintptr_t windowIcon = 0, emptyProc exitFunc = 0) = 0; /// Deriver should calls IDriver::release() first, to destroy all driver components (textures, shaders, VBuffers). virtual bool release(); diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 30ea98c65..ff9ba8973 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -123,7 +123,7 @@ public: /// \name Object // @{ - CDriverUser (uint windowIcon, UDriver::TDriver driver, emptyProc exitFunc = 0); + CDriverUser (uintptr_t windowIcon, UDriver::TDriver driver, emptyProc exitFunc = 0); virtual ~CDriverUser(); // @} diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index 115f86432..fda543ecd 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -24,8 +24,11 @@ #include "nel/misc/geom_ext.h" #include "nel/misc/line.h" - -#ifdef NL_OS_WINDOWS +#if defined (NL_COMP_MINGW) +# define NL3D_GL_DLL_NAME "libnel_drv_opengl_win" +# define NL3D_GLES_DLL_NAME "libnel_drv_opengles_win" +# define NL3D_D3D_DLL_NAME "libnel_drv_direct3d_win" +#elif defined (NL_OS_WINDOWS) # define NL3D_GL_DLL_NAME "nel_drv_opengl_win" # define NL3D_GLES_DLL_NAME "nel_drv_opengles_win" # define NL3D_D3D_DLL_NAME "nel_drv_direct3d_win" diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 2e74ae3fe..67e0c30fd 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -845,8 +845,8 @@ public: /** * This is the static function which build a UDriver, the root for all 3D functions. */ - static UDriver *createDriver(uint windowIcon = 0, bool direct3d = false, emptyProc exitFunc = 0); - static UDriver *createDriver(uint windowIcon, TDriver driver, emptyProc exitFunc = 0); + static UDriver *createDriver(uintptr_t windowIcon = 0, bool direct3d = false, emptyProc exitFunc = 0); + static UDriver *createDriver(uintptr_t windowIcon, TDriver driver, emptyProc exitFunc = 0); /** * Purge static memory diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 864406205..814ddbf1c 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1231,7 +1231,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l // *************************************************************************** -bool CDriverD3D::init (uint windowIcon, emptyProc exitFunc) +bool CDriverD3D::init (uintptr_t windowIcon, emptyProc exitFunc) { H_AUTO_D3D(CDriver3D_init ); diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 1055e105c..36a1c9804 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -839,7 +839,7 @@ public: // *************************************************************************** // Mode initialisation, requests - virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); + virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); virtual bool release(); virtual bool setMode(const GfxMode& mode); diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index aea202e8b..9e9e05918 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -37,7 +37,7 @@ NL_ADD_RUNTIME_FLAGS(${NLDRV_OGL_LIB}) IF(WIN32) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) - ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS) + ADD_DEFINITIONS(-DDRIVER_OPENGL_EXPORTS) ENDIF(WIN32) IF(APPLE) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index e8cb57a22..9ec29f0ba 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -108,7 +108,10 @@ IDriver* createGlDriverInstance () #else #ifdef NL_OS_WINDOWS - +#ifdef NL_COMP_MINGW +extern "C" +{ +#endif __declspec(dllexport) IDriver* NL3D_createIDriverInstance () { return new CDriverGL; @@ -118,7 +121,9 @@ __declspec(dllexport) uint32 NL3D_interfaceVersion () { return IDriver::InterfaceVersion; } - +#ifdef NL_COMP_MINGW +} +#endif #elif defined (NL_OS_UNIX) extern "C" diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.def b/code/nel/src/3d/driver/opengl/driver_opengl.def index bfe648552..369389fa9 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.def +++ b/code/nel/src/3d/driver/opengl/driver_opengl.def @@ -1,2 +1,4 @@ -EXPORTS NL3D_createIDriverInstance -EXPORTS NL3D_interfaceVersion +LIBRARY nel_drv_opengl_win_r +EXPORTS + NL3D_createIDriverInstance + NL3D_interfaceVersion \ No newline at end of file diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 57f73b0b6..46d12eef1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -304,7 +304,7 @@ public: virtual bool isLost() const { return false; } // there's no notion of 'lost device" in OpenGL - virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); + virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); virtual void disableHardwareVertexProgram(); virtual void disableHardwarePixelProgram(); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 07c800cdc..2fea530cf 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -296,7 +296,7 @@ bool GlWndProc(CDriverGL *driver, XEvent &e) #endif // NL_OS_UNIX // *************************************************************************** -bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) +bool CDriverGL::init (uintptr_t windowIcon, emptyProc exitFunc) { H_AUTO_OGL(CDriverGL_init) diff --git a/code/nel/src/3d/driver/opengl/stdopengl.h b/code/nel/src/3d/driver/opengl/stdopengl.h index 544829b19..9773b0048 100644 --- a/code/nel/src/3d/driver/opengl/stdopengl.h +++ b/code/nel/src/3d/driver/opengl/stdopengl.h @@ -37,7 +37,9 @@ #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include #endif diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index e5d814755..7ccf4cfce 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -82,13 +82,13 @@ void UDriver::setMatrixMode2D43() } // *************************************************************************** -UDriver *UDriver::createDriver(uint windowIcon, bool direct3d, emptyProc exitFunc) +UDriver *UDriver::createDriver(uintptr_t windowIcon, bool direct3d, emptyProc exitFunc) { return new CDriverUser (windowIcon, direct3d ? CDriverUser::Direct3d:CDriverUser::OpenGl, exitFunc); } // *************************************************************************** -UDriver *UDriver::createDriver(uint windowIcon, TDriver driver, emptyProc exitFunc) +UDriver *UDriver::createDriver(uintptr_t windowIcon, TDriver driver, emptyProc exitFunc) { return new CDriverUser (windowIcon, (CDriverUser::TDriver)driver, exitFunc); } @@ -114,7 +114,7 @@ bool CDriverUser::_StaticInit= false; // *************************************************************************** -CDriverUser::CDriverUser (uint windowIcon, TDriver driver, emptyProc exitFunc) +CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFunc) { // The enum of IDriver and UDriver MUST be the same!!! nlassert((uint)IDriver::idCount == (uint)UDriver::idCount); From 9838ef56de4244f0599ff43a4f7a706ee12627e7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 02:05:54 +0200 Subject: [PATCH 16/37] Fix Snowballs compile under MinGW --- code/CMakeModules/nel.cmake | 4 ++-- code/nel/src/misc/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 7cf518ddf..a056b280a 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -118,13 +118,13 @@ MACRO(NL_DEFAULT_PROPS name label) ENDIF(NL_LIB_PREFIX) ENDIF(${type} STREQUAL SHARED_LIBRARY) - IF(${type} STREQUAL EXECUTABLE AND WIN32) + IF(${type} STREQUAL EXECUTABLE AND WIN32 AND NOT MINGW) SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR} COMPILE_FLAGS "/GA" LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}") - ENDIF(${type} STREQUAL EXECUTABLE AND WIN32) + ENDIF(${type} STREQUAL EXECUTABLE AND WIN32 AND NOT MINGW) ENDMACRO(NL_DEFAULT_PROPS) ### diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index 0f61fd850..2d3ef9066 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -39,7 +39,7 @@ ENDIF(UNIX) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${PNG_INCLUDE_DIR} config_file) -TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES}) +TARGET_LINK_LIBRARIES(nelmisc ${CMAKE_THREAD_LIBS_INIT} ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARY}) SET_TARGET_PROPERTIES(nelmisc PROPERTIES LINK_INTERFACE_LIBRARIES "") NL_DEFAULT_PROPS(nelmisc "NeL, Library: NeL Misc") NL_ADD_RUNTIME_FLAGS(nelmisc) From ee4a9ef334eb3bc5fbcaa0a54cd0d0e26953d1af Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 12:40:53 +0200 Subject: [PATCH 17/37] Fix NeL Samples for MinGW --- code/nel/samples/3d/cluster_viewer/main.cpp | 4 +++- code/nel/samples/3d/font/main.cpp | 4 +++- code/nel/samples/3d/shape_viewer/main.cpp | 4 +++- code/nel/samples/net/chat/kbhit.cpp | 4 +++- code/nel/samples/net/chat/server.cpp | 4 +++- code/nel/samples/net/class_transport/ai_service.cpp | 4 +++- code/nel/samples/net/class_transport/gd_service.cpp | 4 +++- code/nel/samples/net/login_system/frontend_service.cpp | 4 +++- code/nel/samples/net/udp/bench_service.cpp | 4 +++- code/nel/samples/net/udp/receive_task.cpp | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/code/nel/samples/3d/cluster_viewer/main.cpp b/code/nel/samples/3d/cluster_viewer/main.cpp index e48ad3528..6004e574c 100644 --- a/code/nel/samples/3d/cluster_viewer/main.cpp +++ b/code/nel/samples/3d/cluster_viewer/main.cpp @@ -38,7 +38,9 @@ #include "nel/3d/event_mouse_listener.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/3d/font/main.cpp b/code/nel/samples/3d/font/main.cpp index df6cebdde..b4b5cc3c9 100644 --- a/code/nel/samples/3d/font/main.cpp +++ b/code/nel/samples/3d/font/main.cpp @@ -30,7 +30,9 @@ #include "nel/3d/driver_user.h" #ifdef NL_OS_WINDOWS - #define NOMINMAX + #ifndef NL_COMP_MINGW + #define NOMINMAX + #endif #include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/3d/shape_viewer/main.cpp b/code/nel/samples/3d/shape_viewer/main.cpp index 6127b7207..d1bd4825f 100644 --- a/code/nel/samples/3d/shape_viewer/main.cpp +++ b/code/nel/samples/3d/shape_viewer/main.cpp @@ -29,7 +29,9 @@ #include #ifdef NL_OS_WINDOWS - #define NOMINMAX + #ifndef NL_COMP_MINGW + #define NOMINMAX + #endif #include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/net/chat/kbhit.cpp b/code/nel/samples/net/chat/kbhit.cpp index b463d4566..177fd1d29 100644 --- a/code/nel/samples/net/chat/kbhit.cpp +++ b/code/nel/samples/net/chat/kbhit.cpp @@ -14,7 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifdef __GNUC__ +#include "nel/misc/types_nl.h" + +#ifndef NL_OS_WINDOWS #include "kbhit.h" #include #include // for read() diff --git a/code/nel/samples/net/chat/server.cpp b/code/nel/samples/net/chat/server.cpp index c3976d857..9b85b65e5 100644 --- a/code/nel/samples/net/chat/server.cpp +++ b/code/nel/samples/net/chat/server.cpp @@ -24,7 +24,9 @@ #include "nel/net/callback_server.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/net/class_transport/ai_service.cpp b/code/nel/samples/net/class_transport/ai_service.cpp index 9be3a7080..371c8ff1b 100644 --- a/code/nel/samples/net/class_transport/ai_service.cpp +++ b/code/nel/samples/net/class_transport/ai_service.cpp @@ -37,7 +37,9 @@ #include "nel/net/transport_class.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/net/class_transport/gd_service.cpp b/code/nel/samples/net/class_transport/gd_service.cpp index 0df811488..7d6eff3e2 100644 --- a/code/nel/samples/net/class_transport/gd_service.cpp +++ b/code/nel/samples/net/class_transport/gd_service.cpp @@ -37,7 +37,9 @@ #include "nel/net/transport_class.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/net/login_system/frontend_service.cpp b/code/nel/samples/net/login_system/frontend_service.cpp index 18f525076..351282a8a 100644 --- a/code/nel/samples/net/login_system/frontend_service.cpp +++ b/code/nel/samples/net/login_system/frontend_service.cpp @@ -34,7 +34,9 @@ #include "nel/net/login_server.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/net/udp/bench_service.cpp b/code/nel/samples/net/udp/bench_service.cpp index d7da69516..981a0dd0a 100644 --- a/code/nel/samples/net/udp/bench_service.cpp +++ b/code/nel/samples/net/udp/bench_service.cpp @@ -43,7 +43,9 @@ #include "receive_task.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/samples/net/udp/receive_task.cpp b/code/nel/samples/net/udp/receive_task.cpp index 5e50869d3..4ca68fd4e 100644 --- a/code/nel/samples/net/udp/receive_task.cpp +++ b/code/nel/samples/net/udp/receive_task.cpp @@ -18,7 +18,9 @@ #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined NL_OS_UNIX From 75f7b9f9313f2eff33dae86caf9ea3beb751cf1a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 12:52:03 +0200 Subject: [PATCH 18/37] Fix Snowballs service compile under MinGW --- code/nel/include/nel/net/buf_sock.h | 6 +++--- code/nel/src/net/unified_network.cpp | 2 +- code/snowballs2/server/frontend/src/main.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/net/buf_sock.h b/code/nel/include/nel/net/buf_sock.h index 947f6bff6..5a2f3c074 100644 --- a/code/nel/include/nel/net/buf_sock.h +++ b/code/nel/include/nel/net/buf_sock.h @@ -50,10 +50,10 @@ public: virtual ~CBufSock(); /// Sets the application identifier - void setAppId( uint64 id ) { _AppId = id; } + void setAppId( uintptr_t id ) { _AppId = id; } /// Returns the application identifier - uint64 appId() const { return _AppId; } + uintptr_t appId() const { return _AppId; } /// Returns a string with the characteristics of the object std::string asString() const; @@ -256,7 +256,7 @@ private: NLMISC::CObjectVector _ReadyToSendBuffer; TBlockSize _RTSBIndex; - uint64 _AppId; + uintptr_t _AppId; // Connected state (from the user's point of view, i.e. changed when the connection/disconnection event is at the front of the receive queue) bool _ConnectedState; diff --git a/code/nel/src/net/unified_network.cpp b/code/nel/src/net/unified_network.cpp index e8af9ceac..788dcdf12 100644 --- a/code/nel/src/net/unified_network.cpp +++ b/code/nel/src/net/unified_network.cpp @@ -36,7 +36,7 @@ namespace NLNET { static size_t ThreadCreator = 0; -static const uint64 AppIdDeadConnection = 0xDEAD; +static const uintptr_t AppIdDeadConnection = 0xDEAD; uint32 TotalCallbackCalled = 0; diff --git a/code/snowballs2/server/frontend/src/main.cpp b/code/snowballs2/server/frontend/src/main.cpp index 7b3470cbe..38bcc18fc 100644 --- a/code/snowballs2/server/frontend/src/main.cpp +++ b/code/snowballs2/server/frontend/src/main.cpp @@ -229,7 +229,7 @@ void cbAddClient ( CMessage& msgin, TSockId from, CCallbackNetBase& clientcb ) if(from->appId() != 0) { - CPlayer *p = (CPlayer *)(uint)from->appId(); + CPlayer *p = (CPlayer *)(void *)from->appId(); if(id == p->id) p->State = CPlayer::ONLINE; } @@ -590,12 +590,12 @@ void onDisconnectClient ( TSockId from, void *arg ) { uint32 id; - uint64 i = from->appId(); + uintptr_t i = from->appId(); if(i == 0) return; - CPlayer *p = (CPlayer *)(uint)i; + CPlayer *p = (CPlayer *)(void *)i; id = p->id; nlinfo( "A client with unique Id %u has disconnected", id ); From 40854aa5f3abe352bdcb505b91b38c48a021f8c8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 13:03:11 +0200 Subject: [PATCH 19/37] Fix NeLNS compile under MinGW --- code/nelns/login_service/connection_client.cpp | 4 ++-- code/nelns/login_service/connection_web.cpp | 2 +- code/nelns/login_service/login_service.h | 4 +++- code/nelns/login_service/mysql_helper.h | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/nelns/login_service/connection_client.cpp b/code/nelns/login_service/connection_client.cpp index 37976cb24..8ff713ec2 100644 --- a/code/nelns/login_service/connection_client.cpp +++ b/code/nelns/login_service/connection_client.cpp @@ -395,11 +395,11 @@ static void cbWSShardChooseShard (CMessage &msgin, const std::string &serviceNam string addr; msgin.serial (addr); msgout.serial (addr); - ClientsServer->send (msgout, (TSockId)cookie.getUserAddr ()); + ClientsServer->send (msgout, (TSockId)cookie.getUserAddr ()); // FIXME: 64-bit return; } msgout.serial(reason); - ClientsServer->send (msgout, (TSockId)cookie.getUserAddr ()); + ClientsServer->send (msgout, (TSockId)cookie.getUserAddr ()); // FIXME: 64-bit } static const TUnifiedCallbackItem WSCallbackArray[] = diff --git a/code/nelns/login_service/connection_web.cpp b/code/nelns/login_service/connection_web.cpp index 290884f91..e3abb9936 100644 --- a/code/nelns/login_service/connection_web.cpp +++ b/code/nelns/login_service/connection_web.cpp @@ -117,7 +117,7 @@ static void cbWSShardChooseShard/* (CMessage &msgin, TSockId from, CCallbackNetB */ } - WebServer->send (msgout, (TSockId)cookie.getUserAddr ()); + WebServer->send (msgout, (TSockId)cookie.getUserAddr ()); // FIXME: 64-bit } static const TUnifiedCallbackItem WSCallbackArray[] = diff --git a/code/nelns/login_service/login_service.h b/code/nelns/login_service/login_service.h index 7c8c5a427..3d84b1c8e 100644 --- a/code/nelns/login_service/login_service.h +++ b/code/nelns/login_service/login_service.h @@ -19,7 +19,9 @@ // we have to include windows.h because mysql.h uses it but not include it #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include typedef unsigned long ulong; diff --git a/code/nelns/login_service/mysql_helper.h b/code/nelns/login_service/mysql_helper.h index fee1d1bf6..ed4ebbd48 100644 --- a/code/nelns/login_service/mysql_helper.h +++ b/code/nelns/login_service/mysql_helper.h @@ -24,7 +24,9 @@ // we have to include windows.h because mysql.h uses it but not include it #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include typedef unsigned long ulong; From 43be0fd2a5fd40b5b5d59dd3371d5f092e1ebfaa Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 16:29:02 +0200 Subject: [PATCH 20/37] Fix D3D driver compile under MinGW --- code/nel/include/nel/3d/driver.h | 2 +- code/nel/include/nel/3d/skeleton_model.h | 2 +- .../nel/src/3d/driver/direct3d/CMakeLists.txt | 2 +- .../3d/driver/direct3d/driver_direct3d.cpp | 20 ++++++++++++------- .../3d/driver/direct3d/driver_direct3d.def | 6 ++++-- .../src/3d/driver/direct3d/driver_direct3d.h | 6 +++--- .../driver/direct3d/driver_direct3d_index.cpp | 2 +- .../direct3d/driver_direct3d_texture.cpp | 4 ++-- .../direct3d/driver_direct3d_vertex.cpp | 4 ++-- code/nel/src/3d/driver/direct3d/stddirect3d.h | 4 +++- code/nel/src/3d/driver/opengl/driver_opengl.h | 2 +- .../driver/opengl/driver_opengl_texture.cpp | 2 +- 12 files changed, 33 insertions(+), 23 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index c04fffcdf..022246838 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -1341,7 +1341,7 @@ public: * NB: if implementation does not support it, 0 may be returned. OpenGL ones return the Texture ID. * NB: unlike isTextureExist(), this method is not thread safe. */ - virtual uint getTextureHandle(const ITexture&tex) = 0; + virtual uintptr_t getTextureHandle(const ITexture&tex) = 0; // see if the Multiply-Add Tex Env operator is supported (see CMaterial::Mad) virtual bool supportMADOperator() const = 0; diff --git a/code/nel/include/nel/3d/skeleton_model.h b/code/nel/include/nel/3d/skeleton_model.h index ed4f8aadc..dccafd1f1 100644 --- a/code/nel/include/nel/3d/skeleton_model.h +++ b/code/nel/include/nel/3d/skeleton_model.h @@ -54,7 +54,7 @@ public: // The index of the skin rdrPass uint16 RdrPassIndex; // The texture id of the specular texture. This is the sort Key. - uint32 SpecId; + uintptr_t SpecId; bool operator<(const CSkinSpecularRdrPass &o) const { diff --git a/code/nel/src/3d/driver/direct3d/CMakeLists.txt b/code/nel/src/3d/driver/direct3d/CMakeLists.txt index ede76f06c..ccdb8cb10 100644 --- a/code/nel/src/3d/driver/direct3d/CMakeLists.txt +++ b/code/nel/src/3d/driver/direct3d/CMakeLists.txt @@ -10,7 +10,7 @@ NL_DEFAULT_PROPS(nel_drv_direct3d_win "NeL, Driver, Video: Direct3D") NL_ADD_RUNTIME_FLAGS(nel_drv_direct3d_win) NL_ADD_LIB_SUFFIX(nel_drv_direct3d_win) -ADD_DEFINITIONS(/Ddriver_direct3d_EXPORTS) +ADD_DEFINITIONS(-DRIVER_DIRECT3D_EXPORTS) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_direct3d_win ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.h ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.cpp) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 814ddbf1c..2316119a2 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -110,6 +110,10 @@ IDriver* createD3DDriverInstance () #else +#ifdef NL_COMP_MINGW +extern "C" +{ +#endif __declspec(dllexport) IDriver* NL3D_createIDriverInstance () { return new CDriverD3D; @@ -119,7 +123,9 @@ __declspec(dllexport) uint32 NL3D_interfaceVersion () { return IDriver::InterfaceVersion; } - +#ifdef NL_COMP_MINGW +} +#endif #endif /*static*/ bool CDriverD3D::_CacheTest[CacheTest_Count] = @@ -379,7 +385,7 @@ void CDriverD3D::resetRenderVariables() } for (i=0; iCreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE, ¶meters, &_DeviceInterface); if (result != D3D_OK) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.def b/code/nel/src/3d/driver/direct3d/driver_direct3d.def index 2e32d9601..7e6b29b2e 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.def +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.def @@ -1,2 +1,4 @@ -EXPORTS NL3D_createIDriverInstance -EXPORTS NL3D_interfaceVersion \ No newline at end of file +LIBRARY nel_drv_direct3d_win_r +EXPORTS + NL3D_createIDriverInstance + NL3D_interfaceVersion \ No newline at end of file diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 36a1c9804..254b21871 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -953,7 +953,7 @@ public: virtual void setSwapVBLInterval(uint interval); virtual uint getSwapVBLInterval(); virtual void swapTextureHandle(ITexture &tex0, ITexture &tex1); - virtual uint getTextureHandle(const ITexture&tex); + virtual uintptr_t getTextureHandle(const ITexture&tex); // Matrix, viewport and frustum virtual void setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective = true); @@ -1893,7 +1893,7 @@ public: H_AUTO_D3D(CDriverD3D_setSamplerState); nlassert (_DeviceInterface); nlassert (samplerTexture); + return (uintptr_t)(d3dtext->Texture); } // *************************************************************************** diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp index 9882a5ce1..b798acb26 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp @@ -59,7 +59,7 @@ CVBDrvInfosD3D::CVBDrvInfosD3D(CDriverD3D *drv, ItVBDrvInfoPtrList it, CVertexBu // *************************************************************************** -extern uint vertexCount=0; +uint vertexCount=0; CVBDrvInfosD3D::~CVBDrvInfosD3D() { @@ -173,7 +173,7 @@ uint8 *CVBDrvInfosD3D::lock (uint begin, uint end, bool readOnly) void *pbData; if (VertexBuffer->Lock ( begin, end-begin, &pbData, readOnly?D3DLOCK_READONLY:0) != D3D_OK) - return false; + return NULL; // Lock Profile? if(driver->_VBHardProfiling /*&& Hardware*/) diff --git a/code/nel/src/3d/driver/direct3d/stddirect3d.h b/code/nel/src/3d/driver/direct3d/stddirect3d.h index a243bf816..c7b6f7f3e 100644 --- a/code/nel/src/3d/driver/direct3d/stddirect3d.h +++ b/code/nel/src/3d/driver/direct3d/stddirect3d.h @@ -19,7 +19,9 @@ #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 46d12eef1..6217ea850 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -632,7 +632,7 @@ public: virtual void swapTextureHandle(ITexture &tex0, ITexture &tex1); - virtual uint getTextureHandle(const ITexture&tex); + virtual uintptr_t getTextureHandle(const ITexture&tex); /// \name Material multipass. /** NB: setupMaterial() must be called before thoses methods. diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp index 96d95bd5d..f26b53254 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -2269,7 +2269,7 @@ void CDriverGL::swapTextureHandle(ITexture &tex0, ITexture &tex1) // *************************************************************************** -uint CDriverGL::getTextureHandle(const ITexture &tex) +uintptr_t CDriverGL::getTextureHandle(const ITexture &tex) { H_AUTO_OGL(CDriverGL_getTextureHandle) // If DrvShare not setuped From 401d4bc791723254165923828512e8cd823aeef0 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 21:05:39 +0200 Subject: [PATCH 21/37] Fix NeL Tools compile under MinGW --- code/nel/tools/3d/cluster_viewer/view_cs.cpp | 4 +++- code/nel/tools/3d/shapes_exporter/main.cpp | 4 +++- code/nel/tools/3d/zviewer/zviewer.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/cluster_viewer/view_cs.cpp b/code/nel/tools/3d/cluster_viewer/view_cs.cpp index abe54ada5..5e31543ca 100644 --- a/code/nel/tools/3d/cluster_viewer/view_cs.cpp +++ b/code/nel/tools/3d/cluster_viewer/view_cs.cpp @@ -38,7 +38,9 @@ #include "nel/3d/event_mouse_listener.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/tools/3d/shapes_exporter/main.cpp b/code/nel/tools/3d/shapes_exporter/main.cpp index 183bd8a49..56249e357 100644 --- a/code/nel/tools/3d/shapes_exporter/main.cpp +++ b/code/nel/tools/3d/shapes_exporter/main.cpp @@ -20,7 +20,9 @@ #include "shapes_exporter.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/nel/tools/3d/zviewer/zviewer.cpp b/code/nel/tools/3d/zviewer/zviewer.cpp index d1711c286..840b77cc7 100644 --- a/code/nel/tools/3d/zviewer/zviewer.cpp +++ b/code/nel/tools/3d/zviewer/zviewer.cpp @@ -41,8 +41,10 @@ #include #ifdef NL_OS_WINDOWS - #define NOMINMAX - #include +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif +# include #endif // NL_OS_WINDOWS using namespace std; From cffd68230c663b05a8e89570787be834de948c47 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 23:18:06 +0200 Subject: [PATCH 22/37] Fix XA2 driver compile under MinGW --- .../src/sound/driver/xaudio2/adpcm_xaudio2.h | 2 +- .../sound/driver/xaudio2/driver_xaudio2.def | 10 ++-- .../driver/xaudio2/sound_driver_xaudio2.cpp | 16 +++++++ .../nel/src/sound/driver/xaudio2/stdxaudio2.h | 48 +++++++++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) diff --git a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h b/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h index 6655c57a8..3b46d1b9a 100644 --- a/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h +++ b/code/nel/src/sound/driver/xaudio2/adpcm_xaudio2.h @@ -62,7 +62,7 @@ protected: /// Mutex for cross-thread access from XAudio2 callbacks. NLMISC::CMutex _Mutex; /// Unique id for buffer. - uint _LastBufferContext; + uintptr_t _LastBufferContext; /// Current buffer. void *_ValidBufferContext[_BufferNb]; public: diff --git a/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def b/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def index 247ed160f..2a29a2d91 100644 --- a/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def +++ b/code/nel/src/sound/driver/xaudio2/driver_xaudio2.def @@ -1,4 +1,6 @@ -EXPORTS NLSOUND_createISoundDriverInstance -EXPORTS NLSOUND_interfaceVersion -EXPORTS NLSOUND_outputProfile -EXPORTS NLSOUND_getDriverType \ No newline at end of file +LIBRARY nel_drv_xaudio2_win_r +EXPORTS + NLSOUND_createISoundDriverInstance + NLSOUND_interfaceVersion + NLSOUND_outputProfile + NLSOUND_getDriverType \ No newline at end of file diff --git a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp index c1cdd3729..b95735fc5 100644 --- a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp @@ -53,6 +53,14 @@ BOOL WINAPI DllMain(HANDLE hModule, DWORD /* ul_reason_for_call */, LPVOID /* lp // *************************************************************************** +#ifndef NL_STATIC +#ifdef NL_COMP_MINGW +extern "C" { +#endif +#endif + +// *************************************************************************** + #ifdef NL_STATIC ISoundDriver* createISoundDriverInstanceXAudio2 #else @@ -99,6 +107,14 @@ __declspec(dllexport) ISoundDriver::TDriver NLSOUND_getDriverType() // ****************************************************************** +#ifndef NL_STATIC +#ifdef NL_COMP_MINGW +} +#endif +#endif + +// ****************************************************************** + #ifdef NL_DEBUG static XAUDIO2_DEBUG_CONFIGURATION NLSOUND_XAUDIO2_DEBUG_CONFIGURATION_DISABLED = { diff --git a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h index d716d91bf..76b2a13d8 100644 --- a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h +++ b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h @@ -25,9 +25,57 @@ #include #include #include +#include // 3rd Party Includes +#include #define XAUDIO2_HELPER_FUNCTIONS + +#ifdef NL_COMP_MINGW +#define __in_bcount(x) +#define __in_bcount_opt(x) +#define __in_ecount(x) +#define __in_xcount(x) +#define __inout_bcount_full(x) +#define __inout_bcount_opt(x) +#define __out_bcount(x) +#define __out_bcount_full(x) +#define __out_bcount_opt(x) +#define __out_bcount_part_opt(x,y) +#define __out_ecount(x) +#define __out_xcount(x) +#define __deref_opt_inout_bcount_part_opt(x,y) +#define __deref_out_bcount(x) +#define __deref_out_bcount_opt(x) +#define __out +#define __in +#define __inout +#define __deref_out +#define __in_opt +#define __inout_opt +#define __out_opt +#define __deref +#define __deref_inout_opt +#define __reserved +#define __XMA2DEFS_INCLUDED__ +#endif /* NL_COMP_MINGW */ + +#include + +#ifdef NL_COMP_MINGW +#undef DEFINE_CLSID +#undef DEFINE_IID +#undef DECLSPEC_UUID_WRAPPER +#define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + class className; \ + __CRT_UUID_DECL(className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) \ + EXTERN_C const GUID CLSID_##className +#define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + interface interfaceName; \ + __CRT_UUID_DECL(interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) \ + EXTERN_C const GUID IID_##interfaceName +#endif /* NL_COMP_MINGW */ + #include #include #include From 7adf98e8a762c7877e85a4ec830f87571dd92237 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 00:40:29 +0200 Subject: [PATCH 23/37] Fix NeL GUI compile under MinGW --- code/nel/src/gui/lua_object.cpp | 2 +- code/nel/src/gui/stdpch.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index 3f8924517..a50569858 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -362,7 +362,7 @@ namespace NLGUI { nlassert(key); nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a function value '%p' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a function value '%p' at key %s on object '%s' of type %s (not a table).", (void *)value, key, getId().c_str(), getTypename())); CLuaStackChecker lsc(_LuaState); push(); _LuaState->push(key); diff --git a/code/nel/src/gui/stdpch.h b/code/nel/src/gui/stdpch.h index 8ab2a3595..bb983f77c 100644 --- a/code/nel/src/gui/stdpch.h +++ b/code/nel/src/gui/stdpch.h @@ -30,7 +30,9 @@ #include "nel/misc/hierarchical_timer.h" #ifdef NL_OS_WINDOWS - #define NOMINMAX + #ifndef NL_COMP_MINGW + # define NOMINMAX + #endif #include #include #endif From 2e096a9b36871d1411e398ee93e3dcee8bc6b231 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 01:17:35 +0200 Subject: [PATCH 24/37] Fix Ryzom client compile under MinGW --- code/ryzom/client/src/commands.cpp | 4 ++-- code/ryzom/client/src/init.cpp | 4 ++-- code/ryzom/client/src/stdpch.h | 8 +++++--- code/ryzom/common/src/game_share/stdpch.h | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 3805122f2..ad8a328ba 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -3921,11 +3921,11 @@ NLMISC_COMMAND (url, "launch a browser to the specified url", "") return false; HINSTANCE result = ShellExecute(NULL, "open", args[0].c_str(), NULL,NULL, SW_SHOW); - if ((sint32)result > 32) + if ((intptr_t)result > 32) return true; else { - log.displayNL ("ShellExecute failed %d", (uint32)result); + log.displayNL ("ShellExecute failed %d", (uint32)(intptr_t)result); return false; } } diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index aa18cee6a..809232983 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -882,9 +882,9 @@ void prelogInit() UDriver::TDriver driver = UDriver::OpenGl; #ifdef NL_OS_WINDOWS - uint icon = (uint)LoadIcon(HInstance, MAKEINTRESOURCE(IDI_MAIN_ICON)); + uintptr_t icon = (uintptr_t)LoadIcon(HInstance, MAKEINTRESOURCE(IDI_MAIN_ICON)); #else - uint icon = 0; + uintptr_t icon = 0; #endif // NL_OS_WINDOWS switch(ClientCfg.Driver3D) diff --git a/code/ryzom/client/src/stdpch.h b/code/ryzom/client/src/stdpch.h index 48451ceea..5f046fcfe 100644 --- a/code/ryzom/client/src/stdpch.h +++ b/code/ryzom/client/src/stdpch.h @@ -120,7 +120,9 @@ // Foutez pas d'include du client ici svp ! Grrr ! Hulud #ifdef NL_OS_WINDOWS -#define NOMINMAX -#include -#include +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif +# include +# include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/common/src/game_share/stdpch.h b/code/ryzom/common/src/game_share/stdpch.h index e658fff41..320e8c523 100644 --- a/code/ryzom/common/src/game_share/stdpch.h +++ b/code/ryzom/common/src/game_share/stdpch.h @@ -67,7 +67,9 @@ #include #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include #endif From b18203fc4e9167b8f71d8d5798811a4d811eae9f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 20:19:39 +0200 Subject: [PATCH 25/37] Fix Ryzom server compile under MinGW --- code/nel/include/nel/misc/hierarchical_timer.h | 2 +- code/nel/include/nel/misc/types_nl.h | 6 +++--- code/nel/src/misc/mem_displayer.cpp | 13 +++++++++---- .../ryzom/common/src/game_share/mirror_prop_value.h | 8 ++++---- .../server/src/ai_service/ai_entity_physical.h | 4 +++- code/ryzom/server/src/ai_service/ai_grp_npc.cpp | 2 +- code/ryzom/server/src/ai_service/service_main.cpp | 4 +++- code/ryzom/server/src/ai_service/stdpch.h | 4 +++- .../server/src/backup_service/backup_service.cpp | 4 +++- .../server/src/entities_game_service/CMakeLists.txt | 4 ++-- .../entities_game_service/entities_game_service.cpp | 4 +++- .../server/src/frontend_service/fe_receive_task.cpp | 4 +++- .../src/frontend_service/frontend_service.cpp | 4 +++- .../server/src/frontend_service/module_manager.cpp | 4 ++-- .../src/general_utilities_service/service_main.cpp | 4 +++- code/ryzom/server/src/gpm_service/gpm_service.cpp | 4 +++- .../input_output_service/input_output_service.cpp | 4 +++- .../log_analyser_service/log_analyser_service.cpp | 4 +++- .../server/src/logger_service/logger_service.cpp | 4 +++- .../src/mail_forum_service/mail_forum_service.cpp | 4 +++- code/ryzom/server/src/mirror_service/data_set_ms.h | 4 ++-- .../server/src/mirror_service/mirror_service.cpp | 4 +++- .../server/src/monitor_service/service_main.cpp | 4 +++- .../server/src/patchman_service/service_main.cpp | 6 ++++-- .../reference_builder_service.cpp | 4 +++- .../server/src/pd_support_service/service_main.cpp | 4 +++- .../persistant_data_service.cpp | 4 +++- .../src/ryzom_admin_service/ryzom_admin_service.cpp | 4 +++- .../shard_unifier_service/shard_unifier_service.cpp | 4 +++- code/ryzom/server/src/tick_service/tick_service.cpp | 4 +++- 30 files changed, 91 insertions(+), 42 deletions(-) diff --git a/code/nel/include/nel/misc/hierarchical_timer.h b/code/nel/include/nel/misc/hierarchical_timer.h index 10f9b461e..1c1818c69 100644 --- a/code/nel/include/nel/misc/hierarchical_timer.h +++ b/code/nel/include/nel/misc/hierarchical_timer.h @@ -74,7 +74,7 @@ namespace NLMISC { -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC // Visual C++ warning : ebp maybe modified # pragma warning(disable:4731) #endif diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 388505bd9..a6d718b98 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -152,7 +152,7 @@ // // NL_ISO_TEMPLATE_SPEC can be used in front of an instanciated class-template member data definition, // because sometimes MSVC++ 6 produces an error C2908 with a definition with template <>. -#if defined(NL_OS_WINDOWS) || (defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3))) +#if defined(NL_COMP_VC) || (defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3))) # define NL_ISO_SYNTAX 0 # define NL_ISO_TEMPLATE_SPEC #else @@ -398,8 +398,8 @@ typedef uint16 ucchar; // To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234) -#ifdef NL_OS_WINDOWS -# if defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 80) +#ifdef NL_COMP_VC +# if (NL_COMP_VC_VERSION >= 80) # define INT64_CONSTANT(c) (c##LL) # define SINT64_CONSTANT(c) (c##LL) # define UINT64_CONSTANT(c) (c##LL) diff --git a/code/nel/src/misc/mem_displayer.cpp b/code/nel/src/misc/mem_displayer.cpp index 6c6d51d43..fbc0c0236 100644 --- a/code/nel/src/misc/mem_displayer.cpp +++ b/code/nel/src/misc/mem_displayer.cpp @@ -150,7 +150,11 @@ static string getSourceInfo (DWORD_TYPE addr) return str; } -static uintptr_t __stdcall GetModuleBase(HANDLE hProcess, uintptr_t dwReturnAddress) +#ifdef NL_OS_WIN64 +static DWORD64 __stdcall GetModuleBase(HANDLE hProcess, DWORD64 dwReturnAddress) +#else +static DWORD __stdcall GetModuleBase(HANDLE hProcess, DWORD dwReturnAddress) +#endif { IMAGEHLP_MODULE moduleInfo; @@ -291,12 +295,13 @@ static void displayCallStack (CLog *log) #ifdef NL_OS_WIN64 MachineType = IMAGE_FILE_MACHINE_AMD64; + BOOL res = StackWalk64(MachineType, GetCurrentProcess(), GetCurrentThread(), &callStack, + NULL, NULL, SymFunctionTableAccess, GetModuleBase, NULL); #else MachineType = IMAGE_FILE_MACHINE_I386; -#endif - - BOOL res = StackWalk (MachineType, GetCurrentProcess(), GetCurrentThread(), &callStack, + BOOL res = StackWalk(MachineType, GetCurrentProcess(), GetCurrentThread(), &callStack, NULL, NULL, SymFunctionTableAccess, GetModuleBase, NULL); +#endif /* if (res == FALSE) { diff --git a/code/ryzom/common/src/game_share/mirror_prop_value.h b/code/ryzom/common/src/game_share/mirror_prop_value.h index 1deb06f03..cbc251be2 100644 --- a/code/ryzom/common/src/game_share/mirror_prop_value.h +++ b/code/ryzom/common/src/game_share/mirror_prop_value.h @@ -1150,7 +1150,7 @@ public: typedef _CMirrorPropValueListIterator iterator; typedef _CCMirrorPropValueListIterator const_iterator; -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC friend iterator; // MSVC friend const_iterator; #else @@ -1192,7 +1192,7 @@ public: // If changing this struct, don't forget to change the places where it is initialized TSharedListRow Next; T Value; -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC }; #else } __attribute__((packed)); @@ -1237,7 +1237,7 @@ public: typedef _CMirrorPropValueListIterator iterator; typedef _CCMirrorPropValueListIterator const_iterator; -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC friend iterator; // MSVC friend const_iterator; #else @@ -1280,7 +1280,7 @@ public: // If changing this struct, don't forget to change the places where it is initialized TSharedListRow Next; uint64 Value; -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC }; #else } __attribute__((packed)); diff --git a/code/ryzom/server/src/ai_service/ai_entity_physical.h b/code/ryzom/server/src/ai_service/ai_entity_physical.h index c3a8fa966..5eb30b34f 100644 --- a/code/ryzom/server/src/ai_service/ai_entity_physical.h +++ b/code/ryzom/server/src/ai_service/ai_entity_physical.h @@ -55,7 +55,9 @@ template class CTargetable { #ifdef NL_OS_WINDOWS - friend class CTargetable; +# ifndef NL_COMP_MINGW + friend class CTargetable; +# endif #endif public: typedef NLMISC::CDbgPtr TPtr; diff --git a/code/ryzom/server/src/ai_service/ai_grp_npc.cpp b/code/ryzom/server/src/ai_service/ai_grp_npc.cpp index 937a6f421..056293a25 100644 --- a/code/ryzom/server/src/ai_service/ai_grp_npc.cpp +++ b/code/ryzom/server/src/ai_service/ai_grp_npc.cpp @@ -59,7 +59,7 @@ CSpawnGroupNpc::CSpawnGroupNpc(CPersistent& owner) _LastUpdate = (randomVal>=0)?randomVal:CTimeInterface::gameCycle(); _LastBotUpdate = CTimeInterface::gameCycle(); activityProfile().setAIProfile(new CGrpProfileNormal(this)); - _BotUpdateTimer.set((CAIS::rand32(40)+((long)this>>2))%20); // start with a random value. + _BotUpdateTimer.set((CAIS::rand32(40)+((intptr_t)this>>2))%20); // start with a random value. resetSlowUpdateCycle(); _DespawnBotsWhenNoMoreHandleTimerActive = false; } diff --git a/code/ryzom/server/src/ai_service/service_main.cpp b/code/ryzom/server/src/ai_service/service_main.cpp index 4bdb2c766..130ea1acb 100644 --- a/code/ryzom/server/src/ai_service/service_main.cpp +++ b/code/ryzom/server/src/ai_service/service_main.cpp @@ -38,7 +38,9 @@ #include "ais_user_models.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/ai_service/stdpch.h b/code/ryzom/server/src/ai_service/stdpch.h index d0978b2f7..5ad1d5f28 100644 --- a/code/ryzom/server/src/ai_service/stdpch.h +++ b/code/ryzom/server/src/ai_service/stdpch.h @@ -191,7 +191,9 @@ namespace MULTI_LINE_FORMATER { #include "ai_share/world_map.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/backup_service/backup_service.cpp b/code/ryzom/server/src/backup_service/backup_service.cpp index 698cbc02f..aed50a32c 100644 --- a/code/ryzom/server/src/backup_service/backup_service.cpp +++ b/code/ryzom/server/src/backup_service/backup_service.cpp @@ -30,7 +30,9 @@ #include "web_connection.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/entities_game_service/CMakeLists.txt b/code/ryzom/server/src/entities_game_service/CMakeLists.txt index d57ff9302..15e7794a4 100644 --- a/code/ryzom/server/src/entities_game_service/CMakeLists.txt +++ b/code/ryzom/server/src/entities_game_service/CMakeLists.txt @@ -111,8 +111,8 @@ NL_ADD_RUNTIME_FLAGS(ryzom_entities_game_service) ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) -IF(WITH_PCH) +IF(WITH_PCH AND NOT MINGW) # FIXME: PCH too large (> 130MB), crashes cc1plus under MinGW ADD_NATIVE_PRECOMPILED_HEADER(ryzom_entities_game_service ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp) -ENDIF(WITH_PCH) +ENDIF(WITH_PCH AND NOT MINGW) INSTALL(TARGETS ryzom_entities_game_service RUNTIME DESTINATION sbin COMPONENT services) diff --git a/code/ryzom/server/src/entities_game_service/entities_game_service.cpp b/code/ryzom/server/src/entities_game_service/entities_game_service.cpp index 085d67aae..8ca025870 100644 --- a/code/ryzom/server/src/entities_game_service/entities_game_service.cpp +++ b/code/ryzom/server/src/entities_game_service/entities_game_service.cpp @@ -127,7 +127,9 @@ #include "server_share/stl_allocator_checker.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/frontend_service/fe_receive_task.cpp b/code/ryzom/server/src/frontend_service/fe_receive_task.cpp index 4eb85134a..3c958f461 100644 --- a/code/ryzom/server/src/frontend_service/fe_receive_task.cpp +++ b/code/ryzom/server/src/frontend_service/fe_receive_task.cpp @@ -22,7 +22,9 @@ #include "fe_types.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #elif defined NL_OS_UNIX diff --git a/code/ryzom/server/src/frontend_service/frontend_service.cpp b/code/ryzom/server/src/frontend_service/frontend_service.cpp index e43b9ccce..cbf4a5610 100644 --- a/code/ryzom/server/src/frontend_service/frontend_service.cpp +++ b/code/ryzom/server/src/frontend_service/frontend_service.cpp @@ -57,7 +57,9 @@ #include "uid_impulsions.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/frontend_service/module_manager.cpp b/code/ryzom/server/src/frontend_service/module_manager.cpp index 24def9d18..f0d3e0514 100644 --- a/code/ryzom/server/src/frontend_service/module_manager.cpp +++ b/code/ryzom/server/src/frontend_service/module_manager.cpp @@ -178,7 +178,7 @@ void CModuleManager::addModule(uint id, TModuleExecCallback cb) { nlassert(id < _MaxModules); nlassert(cb != NULL); - nldebug("FEMMAN: [%s] Added module %d (Cb=%p) to stack", _StackName.c_str(), id, cb); + nldebug("FEMMAN: [%s] Added module %d (Cb=%p) to stack", _StackName.c_str(), id, (void *)cb); _ExecutionStack.push_back(CExecutionItem()); @@ -372,7 +372,7 @@ void CModuleManager::executeStack() nlwarning("FEMMAN: Unexpected ExecutionItem type (%d) at item %d of the execution stack %s", item.Type, i, _StackName.c_str()); uint j; for (j=0; j<_ExecutionStack.size(); ++j) - nlwarning("FEMMAN: > %d [%s] Id=%d Cb=%p", j, (item.Type == Module) ? "MOD" : (item.Type == Wait) ? "WAIT" : "ERR", item.Id, item.Cb); + nlwarning("FEMMAN: > %d [%s] Id=%d Cb=%p", j, (item.Type == Module) ? "MOD" : (item.Type == Wait) ? "WAIT" : "ERR", item.Id, (void *)item.Cb); nlerror("FEMMAN: Error in execution stack %s", _StackName.c_str()); } } diff --git a/code/ryzom/server/src/general_utilities_service/service_main.cpp b/code/ryzom/server/src/general_utilities_service/service_main.cpp index 7a19d90b7..af61c4c71 100644 --- a/code/ryzom/server/src/general_utilities_service/service_main.cpp +++ b/code/ryzom/server/src/general_utilities_service/service_main.cpp @@ -34,7 +34,9 @@ #include "service_main.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/gpm_service/gpm_service.cpp b/code/ryzom/server/src/gpm_service/gpm_service.cpp index 0756f641e..f6011fc82 100644 --- a/code/ryzom/server/src/gpm_service/gpm_service.cpp +++ b/code/ryzom/server/src/gpm_service/gpm_service.cpp @@ -50,7 +50,9 @@ #include "sheets.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/input_output_service/input_output_service.cpp b/code/ryzom/server/src/input_output_service/input_output_service.cpp index d58de20a4..de3d73458 100644 --- a/code/ryzom/server/src/input_output_service/input_output_service.cpp +++ b/code/ryzom/server/src/input_output_service/input_output_service.cpp @@ -47,7 +47,9 @@ */ #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp b/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp index 3725299d6..823a8d1e4 100644 --- a/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp +++ b/code/ryzom/server/src/log_analyser_service/log_analyser_service.cpp @@ -20,7 +20,9 @@ #include #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/logger_service/logger_service.cpp b/code/ryzom/server/src/logger_service/logger_service.cpp index dba4cae57..cb51c6a6d 100644 --- a/code/ryzom/server/src/logger_service/logger_service.cpp +++ b/code/ryzom/server/src/logger_service/logger_service.cpp @@ -36,7 +36,9 @@ #include "log_storage.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/mail_forum_service/mail_forum_service.cpp b/code/ryzom/server/src/mail_forum_service/mail_forum_service.cpp index 20c32173e..f902251e9 100644 --- a/code/ryzom/server/src/mail_forum_service/mail_forum_service.cpp +++ b/code/ryzom/server/src/mail_forum_service/mail_forum_service.cpp @@ -25,7 +25,9 @@ #include "hof_generator.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/mirror_service/data_set_ms.h b/code/ryzom/server/src/mirror_service/data_set_ms.h index 4e40557ad..4fc9a4bfc 100644 --- a/code/ryzom/server/src/mirror_service/data_set_ms.h +++ b/code/ryzom/server/src/mirror_service/data_set_ms.h @@ -338,7 +338,7 @@ public: // If changing this struct, don't forget to change the places where it is initialized TSharedListRow Next; T Value; -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC }; #else } __attribute__((packed)); @@ -409,7 +409,7 @@ void push_front( const NLMISC::CEntityId& value ); // If changing this struct, don't forget to change the places where it is initialized TSharedListRow Next; uint64 Value; -#ifdef NL_OS_WINDOWS +#ifdef NL_COMP_VC }; #else } __attribute__((packed)); diff --git a/code/ryzom/server/src/mirror_service/mirror_service.cpp b/code/ryzom/server/src/mirror_service/mirror_service.cpp index 9d1952cc7..d29ca4f3d 100644 --- a/code/ryzom/server/src/mirror_service/mirror_service.cpp +++ b/code/ryzom/server/src/mirror_service/mirror_service.cpp @@ -25,7 +25,9 @@ #include #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/monitor_service/service_main.cpp b/code/ryzom/server/src/monitor_service/service_main.cpp index 0ad027d86..a0e577269 100644 --- a/code/ryzom/server/src/monitor_service/service_main.cpp +++ b/code/ryzom/server/src/monitor_service/service_main.cpp @@ -28,7 +28,9 @@ #include "messages.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include typedef unsigned long ulong; diff --git a/code/ryzom/server/src/patchman_service/service_main.cpp b/code/ryzom/server/src/patchman_service/service_main.cpp index c26ac0924..8bf99a275 100644 --- a/code/ryzom/server/src/patchman_service/service_main.cpp +++ b/code/ryzom/server/src/patchman_service/service_main.cpp @@ -36,8 +36,10 @@ #include "patchman_tester.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX -# include +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif +# include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/pd_reference_builder/reference_builder_service.cpp b/code/ryzom/server/src/pd_reference_builder/reference_builder_service.cpp index 6bb687e8e..20eda6c18 100644 --- a/code/ryzom/server/src/pd_reference_builder/reference_builder_service.cpp +++ b/code/ryzom/server/src/pd_reference_builder/reference_builder_service.cpp @@ -21,7 +21,9 @@ #include "delta_builder_task.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/pd_support_service/service_main.cpp b/code/ryzom/server/src/pd_support_service/service_main.cpp index 81bb66f94..447f8f2c4 100644 --- a/code/ryzom/server/src/pd_support_service/service_main.cpp +++ b/code/ryzom/server/src/pd_support_service/service_main.cpp @@ -34,7 +34,9 @@ #include "service_main.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/persistant_data_service/persistant_data_service.cpp b/code/ryzom/server/src/persistant_data_service/persistant_data_service.cpp index 8a7a9cd6a..9fb21d1c9 100644 --- a/code/ryzom/server/src/persistant_data_service/persistant_data_service.cpp +++ b/code/ryzom/server/src/persistant_data_service/persistant_data_service.cpp @@ -19,7 +19,9 @@ #include "db_manager.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service.cpp b/code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service.cpp index a7c1b6f66..54701aff7 100644 --- a/code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service.cpp +++ b/code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service.cpp @@ -22,7 +22,9 @@ #include "nel/net/service.h" #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/shard_unifier_service/shard_unifier_service.cpp b/code/ryzom/server/src/shard_unifier_service/shard_unifier_service.cpp index d22cf82a9..50b4eb419 100644 --- a/code/ryzom/server/src/shard_unifier_service/shard_unifier_service.cpp +++ b/code/ryzom/server/src/shard_unifier_service/shard_unifier_service.cpp @@ -24,7 +24,9 @@ //#include #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS diff --git a/code/ryzom/server/src/tick_service/tick_service.cpp b/code/ryzom/server/src/tick_service/tick_service.cpp index a25c1c83e..95f609571 100644 --- a/code/ryzom/server/src/tick_service/tick_service.cpp +++ b/code/ryzom/server/src/tick_service/tick_service.cpp @@ -31,7 +31,9 @@ #include #ifdef NL_OS_WINDOWS -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include #endif // NL_OS_WINDOWS From fd6a95e3a33eec549504ef3ba5285c8c751d6dd8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 20:22:12 +0200 Subject: [PATCH 26/37] Backed out changeset: f665fcc42968 (except dru.cpp) --- code/nel/src/3d/deform_2d.cpp | 1 - code/nel/src/3d/motion_blur.cpp | 1 - code/nel/src/3d/ps_fan_light.cpp | 1 - code/nel/src/3d/ps_force.cpp | 2 -- code/nel/src/3d/ps_ribbon.cpp | 1 - code/nel/src/3d/ps_ribbon_look_at.cpp | 1 - code/nel/src/3d/ps_shockwave.cpp | 1 - code/nel/src/3d/ps_tail_dot.cpp | 1 - code/nel/src/3d/ps_util.cpp | 3 --- code/nel/src/3d/scene_group.cpp | 1 - code/ryzom/client/src/landscape_poly_drawer.cpp | 2 -- 11 files changed, 15 deletions(-) diff --git a/code/nel/src/3d/deform_2d.cpp b/code/nel/src/3d/deform_2d.cpp index 988d43ff9..7a4ffb507 100644 --- a/code/nel/src/3d/deform_2d.cpp +++ b/code/nel/src/3d/deform_2d.cpp @@ -103,7 +103,6 @@ void CDeform2d::doDeform(const TPoint2DVect &surf, IDriver *drv, IPerturbUV *uvp static CVertexBuffer vb; vb.setName("CDeform2d"); vb.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag); - vb.setPreferredMemory(CVertexBuffer::RAMVolatile, false); diff --git a/code/nel/src/3d/motion_blur.cpp b/code/nel/src/3d/motion_blur.cpp index 2b158062d..e9fe1fdab 100644 --- a/code/nel/src/3d/motion_blur.cpp +++ b/code/nel/src/3d/motion_blur.cpp @@ -59,7 +59,6 @@ void CMotionBlur::performMotionBlur(IDriver *driver, float motionBlurAmount) static CVertexBuffer vb ; vb.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag ) ; vb.setNumVertices(4) ; - vb.setPreferredMemory(CVertexBuffer::RAMVolatile, false); uint32 width, height ; driver->getWindowSize(width, height) ; diff --git a/code/nel/src/3d/ps_fan_light.cpp b/code/nel/src/3d/ps_fan_light.cpp index cb33fcd20..055826749 100644 --- a/code/nel/src/3d/ps_fan_light.cpp +++ b/code/nel/src/3d/ps_fan_light.cpp @@ -519,7 +519,6 @@ void CPSFanLight::getVBnIB(CVertexBuffer *&retVb, CIndexBuffer *&retIb) vb.setName("CPSFanLight"); ib.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); ib.setNumIndexes(size * _NbFans * 3); - ib.setPreferredMemory(CIndexBuffer::AGPVolatile, false); // pointer on the current index to fill CIndexBufferReadWrite iba; ib.lock (iba); diff --git a/code/nel/src/3d/ps_force.cpp b/code/nel/src/3d/ps_force.cpp index cb3445619..bbef28663 100644 --- a/code/nel/src/3d/ps_force.cpp +++ b/code/nel/src/3d/ps_force.cpp @@ -421,7 +421,6 @@ void CPSGravity::show() vb.setVertexFormat(CVertexBuffer::PositionFlag); vb.setNumVertices(6); - vb.setPreferredMemory(CVertexBuffer::RAMVolatile, false); { CVertexBufferReadWrite vba; vb.lock (vba); @@ -434,7 +433,6 @@ void CPSGravity::show() } pb.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); pb.setNumIndexes(2*4); - pb.setPreferredMemory(CIndexBuffer::RAMVolatile, false); { CIndexBufferReadWrite ibaWrite; pb.lock (ibaWrite); diff --git a/code/nel/src/3d/ps_ribbon.cpp b/code/nel/src/3d/ps_ribbon.cpp index cc7d0bcd7..af907313f 100644 --- a/code/nel/src/3d/ps_ribbon.cpp +++ b/code/nel/src/3d/ps_ribbon.cpp @@ -971,7 +971,6 @@ CPSRibbon::CVBnPB &CPSRibbon::getVBnPB() ); vb.setNumVertices((_UsedNbSegs + 1) * numRibbonInVB * numVerticesInSlice); // 1 seg = 1 line + terminal vertices pb.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); - pb.setPreferredMemory(CIndexBuffer::AGPVolatile, false); // set the primitive block size if (_BraceMode) { diff --git a/code/nel/src/3d/ps_ribbon_look_at.cpp b/code/nel/src/3d/ps_ribbon_look_at.cpp index 3b22f561e..966e5a5b1 100644 --- a/code/nel/src/3d/ps_ribbon_look_at.cpp +++ b/code/nel/src/3d/ps_ribbon_look_at.cpp @@ -582,7 +582,6 @@ CPSRibbonLookAt::CVBnPB &CPSRibbonLookAt::getVBnPB() CIndexBuffer &pb = VBnPB.PB; pb.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); pb.setNumIndexes((_UsedNbSegs << 1) * numRibbonInVB * 3); - pb.setPreferredMemory(CIndexBuffer::AGPVolatile, false); CIndexBufferReadWrite iba; pb.lock (iba); /// Setup the pb and vb parts. Not very fast but executed only once diff --git a/code/nel/src/3d/ps_shockwave.cpp b/code/nel/src/3d/ps_shockwave.cpp index 607b2d03e..20069e175 100644 --- a/code/nel/src/3d/ps_shockwave.cpp +++ b/code/nel/src/3d/ps_shockwave.cpp @@ -530,7 +530,6 @@ void CPSShockWave::getVBnPB(CVertexBuffer *&retVb, CIndexBuffer *&retPb) vb.lock (vba); pb.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); pb.setNumIndexes(2 * 3 * size * _NbSeg); - pb.setPreferredMemory(CIndexBuffer::AGPVolatile, false); CIndexBufferReadWrite ibaWrite; pb.lock (ibaWrite); uint finalIndex = 0; diff --git a/code/nel/src/3d/ps_tail_dot.cpp b/code/nel/src/3d/ps_tail_dot.cpp index 623b8e7f7..075c9a598 100644 --- a/code/nel/src/3d/ps_tail_dot.cpp +++ b/code/nel/src/3d/ps_tail_dot.cpp @@ -422,7 +422,6 @@ CPSTailDot::CVBnPB &CPSTailDot::getVBnPB() CIndexBuffer &pb = VBnPB.PB; pb.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); pb.setNumIndexes(2 * _UsedNbSegs * numRibbonInVB); - pb.setPreferredMemory(CIndexBuffer::AGPVolatile, false); /// Setup the pb and vb parts. Not very fast but executed only once uint vbIndex = 0; uint pbIndex = 0; diff --git a/code/nel/src/3d/ps_util.cpp b/code/nel/src/3d/ps_util.cpp index 0f7600d0e..84e8c096a 100644 --- a/code/nel/src/3d/ps_util.cpp +++ b/code/nel/src/3d/ps_util.cpp @@ -117,7 +117,6 @@ void CPSUtil::displayBBox(NL3D::IDriver *driver, const NLMISC::CAABBox &box, NLM CVertexBuffer vb; vb.setVertexFormat(CVertexBuffer::PositionFlag); vb.setNumVertices(8); - vb.setPreferredMemory(CVertexBuffer::AGPVolatile, false); { CVertexBufferReadWrite vba; @@ -146,7 +145,6 @@ void CPSUtil::displayBBox(NL3D::IDriver *driver, const NLMISC::CAABBox &box, NLM CIndexBuffer pb; pb.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); pb.setNumIndexes(2*12); - pb.setPreferredMemory(CIndexBuffer::RAMVolatile, false); { CIndexBufferReadWrite ibaWrite; pb.lock (ibaWrite); @@ -208,7 +206,6 @@ void CPSUtil::displayArrow(IDriver *driver, const CVector &start, const CVector CVertexBuffer vb; vb.setVertexFormat(CVertexBuffer::PositionFlag); vb.setNumVertices(5); - vb.setPreferredMemory(CVertexBuffer::AGPVolatile, false); { diff --git a/code/nel/src/3d/scene_group.cpp b/code/nel/src/3d/scene_group.cpp index 7bd50e79b..d539278cd 100644 --- a/code/nel/src/3d/scene_group.cpp +++ b/code/nel/src/3d/scene_group.cpp @@ -1307,7 +1307,6 @@ void CInstanceGroup::displayDebugClusters(IDriver *drv, class CTextContext *tx const uint maxVertices= 10000; vb.setVertexFormat(CVertexBuffer::PositionFlag); vb.setNumVertices(maxVertices); - vb.setPreferredMemory(CVertexBuffer::RAMVolatile, false); CIndexBuffer clusterTriangles; CIndexBuffer clusterLines; CIndexBuffer portalTriangles; diff --git a/code/ryzom/client/src/landscape_poly_drawer.cpp b/code/ryzom/client/src/landscape_poly_drawer.cpp index e98f17dc7..714684e26 100644 --- a/code/ryzom/client/src/landscape_poly_drawer.cpp +++ b/code/ryzom/client/src/landscape_poly_drawer.cpp @@ -396,7 +396,6 @@ void CLandscapePolyDrawer::buildShadowVolume(uint poly) // because they are calculated in camera location. vb.setVertexFormat(CVertexBuffer::PositionFlag); vb.setNumVertices(2*verticesNb + 2); - vb.setPreferredMemory(CVertexBuffer::RAMVolatile, false); { CVertexBufferReadWrite vba; vb.lock(vba); @@ -412,7 +411,6 @@ void CLandscapePolyDrawer::buildShadowVolume(uint poly) int index = 0; ib.setFormat(NL_DEFAULT_INDEX_BUFFER_FORMAT); ib.setNumIndexes(12*verticesNb); - ib.setPreferredMemory(CIndexBuffer::RAMVolatile, false); { CIndexBufferReadWrite iba; ib.lock (iba); From 66922f04bd3d7bcd0007733d2190587f59ca418d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 20:43:03 +0200 Subject: [PATCH 27/37] Fix Ryzom server compile under MinGW --- .../server_share/stl_allocator_checker.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/code/ryzom/server/src/server_share/stl_allocator_checker.cpp b/code/ryzom/server/src/server_share/stl_allocator_checker.cpp index 893ff9cb3..daf9b79b6 100644 --- a/code/ryzom/server/src/server_share/stl_allocator_checker.cpp +++ b/code/ryzom/server/src/server_share/stl_allocator_checker.cpp @@ -27,12 +27,12 @@ bool EnableStlAllocatorChecker= true; NLMISC_VARIABLE(bool,EnableStlAllocatorChecker,"Enable stl allocator tests"); -uint32 StlAllocatorMaxFree= 0; -NLMISC_VARIABLE(uint32,StlAllocatorMaxFree,"When EnableStlAllocatorChecker is true, this value gives the largest number of free blocks encountered"); +uintptr_t StlAllocatorMaxFree= 0; +NLMISC_VARIABLE(uintptr_t,StlAllocatorMaxFree,"When EnableStlAllocatorChecker is true, this value gives the largest number of free blocks encountered"); -// setup a 'max iterations' value of 3GBytes/ sizeof(uint32*) +// setup a 'max iterations' value of 3GBytes/ sizeof(void*) (32bit) // => this is equivalent to the total addressable memory space under linux -static const uint32 MaxIterations= 768*1024*1024; +static const uintptr_t MaxIterations= 768*1024*1024; // the following static vector exists only for the use of the testStlMemoryAllocator() routine // - it is required to allow us to get hold of the stl small block memory allocator @@ -54,20 +54,20 @@ void testStlMemoryAllocator(const char* state) if (IsCrashed) return; // setup a pointer 'p' to the first block in the allocator's linked list of free blocks - std::vector::allocator_type allocator= StaticIntVector.get_allocator(); - uint32 *p; + std::vector::allocator_type allocator= StaticIntVector.get_allocator(); + uintptr_t *p; p= allocator.allocate(1); allocator.deallocate(p,1); - // setup a counter to 3GBytes/ sizeof(uint32*) => equivalent to the total addressable memory space under linux - uint32 counter= MaxIterations; + // setup a counter to 3GBytes/ sizeof(void*) (32bit) => equivalent to the total addressable memory space under linux + uintptr_t counter= MaxIterations; if (setjmp(Context) == 0) { do { // step forwards allong the linked list - p= (uint32*)*p; + p= (uintptr_t*)*p; // if the counter hits zero then we can assume that we're in an infinite loop if (--counter==0) @@ -78,7 +78,7 @@ void testStlMemoryAllocator(const char* state) // if we hit a NULL end of list terminator then return happily if (p==NULL) { - uint32 numIterations= MaxIterations- counter; + uintptr_t numIterations= MaxIterations- counter; StlAllocatorMaxFree= std::max(numIterations,StlAllocatorMaxFree); signal(SIGSEGV, NULL); return; @@ -88,7 +88,7 @@ void testStlMemoryAllocator(const char* state) // note that our memory allocators contain invalid data so any call to 'nlassert' etc may modify // data thta they shouldn't and make our debugging task harder // ... so just provoke an access violation - *(uint32**)(0) = p; + *(uintptr_t**)(0) = p; } // we just hit a crash case so setup flags / globals accordingly From 93e97c56cd1b15d1c2845ee65b4754fc30208c4b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 19 Jun 2014 21:49:33 +0200 Subject: [PATCH 28/37] Implement occlusion queries for AMD/ATI in the OpenGL driver --- .../src/3d/driver/opengl/driver_opengl.cpp | 46 ++++++++++++++----- code/nel/src/3d/driver/opengl/driver_opengl.h | 1 + .../driver/opengl/driver_opengl_extension.cpp | 33 +++++++++++++ .../driver/opengl/driver_opengl_extension.h | 14 +++++- 4 files changed, 81 insertions(+), 13 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 9ec29f0ba..3d6031caf 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -2657,7 +2657,7 @@ void CDriverGL::checkTextureOn() const bool CDriverGL::supportOcclusionQuery() const { H_AUTO_OGL(CDriverGL_supportOcclusionQuery) - return _Extensions.NVOcclusionQuery; + return _Extensions.NVOcclusionQuery || _Extensions.ARBOcclusionQuery; } // *************************************************************************** @@ -2688,11 +2688,14 @@ bool CDriverGL::supportFrameBufferObject() const IOcclusionQuery *CDriverGL::createOcclusionQuery() { H_AUTO_OGL(CDriverGL_createOcclusionQuery) - nlassert(_Extensions.NVOcclusionQuery); + nlassert(_Extensions.NVOcclusionQuery || _Extensions.ARBOcclusionQuery); #ifndef USE_OPENGLES GLuint id; - nglGenOcclusionQueriesNV(1, &id); + if (_Extensions.NVOcclusionQuery) + nglGenOcclusionQueriesNV(1, &id); + else + nglGenQueriesARB(1, &id); if (id == 0) return NULL; COcclusionQueryGL *oqgl = new COcclusionQueryGL; oqgl->Driver = this; @@ -2719,7 +2722,10 @@ void CDriverGL::deleteOcclusionQuery(IOcclusionQuery *oq) oqgl->Driver = NULL; nlassert(oqgl->ID != 0); GLuint id = oqgl->ID; - nglDeleteOcclusionQueriesNV(1, &id); + if (_Extensions.NVOcclusionQuery) + nglDeleteOcclusionQueriesNV(1, &id); + else + nglDeleteQueriesARB(1, &id); _OcclusionQueryList.erase(oqgl->Iterator); if (oqgl == _CurrentOcclusionQuery) { @@ -2738,7 +2744,10 @@ void COcclusionQueryGL::begin() nlassert(Driver); nlassert(Driver->_CurrentOcclusionQuery == NULL); // only one query at a time nlassert(ID); - nglBeginOcclusionQueryNV(ID); + if (Driver->_Extensions.NVOcclusionQuery) + nglBeginOcclusionQueryNV(ID); + else + nglBeginQueryARB(GL_SAMPLES_PASSED, ID); Driver->_CurrentOcclusionQuery = this; OcclusionType = NotAvailable; VisibleCount = 0; @@ -2754,7 +2763,10 @@ void COcclusionQueryGL::end() nlassert(Driver); nlassert(Driver->_CurrentOcclusionQuery == this); // only one query at a time nlassert(ID); - nglEndOcclusionQueryNV(); + if (Driver->_Extensions.NVOcclusionQuery) + nglEndOcclusionQueryNV(); + else + nglEndQueryARB(GL_SAMPLES_PASSED); Driver->_CurrentOcclusionQuery = NULL; #endif } @@ -2770,15 +2782,25 @@ IOcclusionQuery::TOcclusionType COcclusionQueryGL::getOcclusionType() nlassert(Driver->_CurrentOcclusionQuery != this); // can't query result between a begin/end pair! if (OcclusionType == NotAvailable) { - GLuint result; - // retrieve result - nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_AVAILABLE_NV, &result); - if (result != GL_FALSE) + if (Driver->_Extensions.NVOcclusionQuery) + { + GLuint result; + // retrieve result + nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_AVAILABLE_NV, &result); + if (result != GL_FALSE) + { + nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_NV, &result); + OcclusionType = result != 0 ? NotOccluded : Occluded; + VisibleCount = (uint) result; + // Note : we could return the exact number of pixels that passed the z-test, but this value is not supported by all implementation (Direct3D ...) + } + } + else { - nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_NV, &result); + GLuint result; + nglGetQueryObjectuivARB(ID, GL_QUERY_RESULT, &result); OcclusionType = result != 0 ? NotOccluded : Occluded; VisibleCount = (uint) result; - // Note : we could return the exact number of pixels that passed the z-test, but this value is not supported by all implementation (Direct3D ...) } } #endif diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 6217ea850..241b3bb95 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -1591,6 +1591,7 @@ private: // @} // misc public: + friend class COcclusionQueryGL; static GLenum NLCubeFaceToGLCubeFace[6]; static CMaterial::CTexEnv _TexEnvReplace; // occlusion query diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index f24855ea8..515d553aa 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -449,6 +449,16 @@ PFNGLENDOCCLUSIONQUERYNVPROC nglEndOcclusionQueryNV; PFNGLGETOCCLUSIONQUERYIVNVPROC nglGetOcclusionQueryivNV; PFNGLGETOCCLUSIONQUERYUIVNVPROC nglGetOcclusionQueryuivNV; +// ARB_occlusion_query +PFNGLGENQUERIESPROC nglGenQueriesARB; +PFNGLDELETEQUERIESPROC nglDeleteQueriesARB; +PFNGLISQUERYPROC nglIsQueryARB; +PFNGLBEGINQUERYPROC nglBeginQueryARB; +PFNGLENDQUERYPROC nglEndQueryARB; +PFNGLGETQUERYIVPROC nglGetQueryivARB; +PFNGLGETQUERYOBJECTIVPROC nglGetQueryObjectivARB; +PFNGLGETQUERYOBJECTUIVPROC nglGetQueryObjectuivARB; + // GL_EXT_framebuffer_object PFNGLISRENDERBUFFEREXTPROC nglIsRenderbufferEXT; PFNGLISFRAMEBUFFEREXTPROC nglIsFramebufferEXT; @@ -1371,6 +1381,26 @@ static bool setupNVOcclusionQuery(const char *glext) return true; } +// *************************************************************************** +static bool setupARBOcclusionQuery(const char *glext) +{ + H_AUTO_OGL(setupARBOcclusionQuery); + CHECK_EXT("ARB_occlusion_query"); + +#ifndef USE_OPENGLES + CHECK_ADDRESS(PFNGLGENQUERIESPROC, glGenQueriesARB); + CHECK_ADDRESS(PFNGLDELETEQUERIESPROC, glDeleteQueriesARB); + CHECK_ADDRESS(PFNGLISQUERYPROC, glIsQueryARB); + CHECK_ADDRESS(PFNGLBEGINQUERYPROC, glBeginQueryARB); + CHECK_ADDRESS(PFNGLENDQUERYPROC, glEndQueryARB); + CHECK_ADDRESS(PFNGLGETQUERYIVPROC, glGetQueryivARB); + CHECK_ADDRESS(PFNGLGETQUERYOBJECTIVPROC, glGetQueryObjectivARB); + CHECK_ADDRESS(PFNGLGETQUERYOBJECTUIVPROC, glGetQueryObjectuivARB); +#endif + + return true; +} + // *************************************************************************** static bool setupNVTextureRectangle(const char *glext) @@ -1663,6 +1693,9 @@ void registerGlExtensions(CGlExtensions &ext) // Check NV_occlusion_query ext.NVOcclusionQuery = setupNVOcclusionQuery(glext); + // Check ARB_occlusion_query + ext.ARBOcclusionQuery = setupARBOcclusionQuery(glext); + // Check GL_NV_texture_rectangle ext.NVTextureRectangle = setupNVTextureRectangle(glext); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h index 83d2d529f..07599366c 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -58,6 +58,7 @@ struct CGlExtensions bool EXTVertexShader; bool NVTextureShader; bool NVOcclusionQuery; + bool ARBOcclusionQuery; bool NVTextureRectangle; bool EXTTextureRectangle; bool ARBTextureRectangle; @@ -178,6 +179,7 @@ public: ARBTextureNonPowerOfTwo = false; ARBMultisample = false; NVOcclusionQuery = false; + ARBOcclusionQuery = false; FrameBufferObject = false; FrameBufferBlit = false; FrameBufferMultisample = false; @@ -239,6 +241,7 @@ public: result += EXTSecondaryColor ? "EXTSecondaryColor " : ""; result += EXTBlendColor ? "EXTBlendColor " : ""; result += NVOcclusionQuery ? "NVOcclusionQuery " : ""; + result += ARBOcclusionQuery ? "ARBOcclusionQuery " : ""; result += NVStateVARWithoutFlush ? "NVStateVARWithoutFlush " : ""; result += ARBMultisample ? "ARBMultisample " : ""; result += NVXGPUMemoryInfo ? "NVXGPUMemoryInfo " : ""; @@ -737,7 +740,16 @@ extern PFNGLENDOCCLUSIONQUERYNVPROC nglEndOcclusionQueryNV; extern PFNGLGETOCCLUSIONQUERYIVNVPROC nglGetOcclusionQueryivNV; extern PFNGLGETOCCLUSIONQUERYUIVNVPROC nglGetOcclusionQueryuivNV; - +// ARB_occlusion_query +//================================== +extern PFNGLGENQUERIESPROC nglGenQueriesARB; +extern PFNGLDELETEQUERIESPROC nglDeleteQueriesARB; +extern PFNGLISQUERYPROC nglIsQueryARB; +extern PFNGLBEGINQUERYPROC nglBeginQueryARB; +extern PFNGLENDQUERYPROC nglEndQueryARB; +extern PFNGLGETQUERYIVPROC nglGetQueryivARB; +extern PFNGLGETQUERYOBJECTIVPROC nglGetQueryObjectivARB; +extern PFNGLGETQUERYOBJECTUIVPROC nglGetQueryObjectuivARB; #ifdef NL_OS_WINDOWS From 43a061bebd2e2fb8cf3702332fd1775c3a89ad16 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 20 Jun 2014 03:08:51 +0200 Subject: [PATCH 29/37] SSE2: Compile fix --HG-- branch : sse2 --- code/nel/include/nel/misc/types_nl.h | 2 +- code/nel/src/misc/matrix.cpp | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 6f41deff1..d0111fb08 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -383,7 +383,7 @@ extern void operator delete[](void *p) throw(); #else /* NL_HAS_SSE2 */ #define NL_DEFAULT_MEMORY_ALIGNMENT 4 -#define NL_ALIGN_SSE2(nb) +#define NL_ALIGN_SSE2 #endif /* NL_HAS_SSE2 */ diff --git a/code/nel/src/misc/matrix.cpp b/code/nel/src/misc/matrix.cpp index acfe7ee96..e907fb2e0 100644 --- a/code/nel/src/misc/matrix.cpp +++ b/code/nel/src/misc/matrix.cpp @@ -140,10 +140,6 @@ inline void CMatrix::testExpandRot() const self->Scale33= 1; } } -void CMatrix::testExpandRotEx() const -{ - testExpandRot(); -} inline void CMatrix::testExpandProj() const { @@ -156,10 +152,6 @@ inline void CMatrix::testExpandProj() const self->a41=0; self->a42=0; self->a43=0; self->a44=1; } } -void CMatrix::testExpandProjEx() const -{ - testExpandProj(); -} // ====================================================================================================== From 07dd9eb85bcc48cba57a2ca01478793bf33d5dd4 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 20 Jun 2014 17:53:38 +0200 Subject: [PATCH 30/37] Compile fix --- code/nel/src/misc/object_arena_allocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/object_arena_allocator.cpp b/code/nel/src/misc/object_arena_allocator.cpp index 8084b4ac9..5fba66005 100644 --- a/code/nel/src/misc/object_arena_allocator.cpp +++ b/code/nel/src/misc/object_arena_allocator.cpp @@ -68,7 +68,7 @@ void *CObjectArenaAllocator::alloc(uint size) if (size >= _MaxAllocSize) { // use standard allocator - nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT > sizeof(uint)); + nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT >= sizeof(uint)); uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block if (!block) return NULL; #ifdef NL_DEBUG From ed5721a79b06b9e13d458ac8d55c1cab19da158f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 20 Jun 2014 18:51:34 +0200 Subject: [PATCH 31/37] Add SSE3 compile flag if enabled --- code/CMakeModules/nel.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 07ea78f25..2d7632aa8 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -617,6 +617,10 @@ MACRO(NL_SETUP_BUILD) ENDIF(CLANG) ENDIF(WIN32) + IF(WITH_SSE3) + ADD_PLATFORM_FLAGS("-msse3") + ENDIF(WITH_SSE3) + IF(APPLE) IF(NOT XCODE) IF(CMAKE_OSX_ARCHITECTURES) From 5312547295cd5b6799a89e513b767e192e2491ee Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 20 Jun 2014 19:46:33 +0200 Subject: [PATCH 32/37] Add option for -mfpmath=both flag --- code/CMakeModules/nel.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 2d7632aa8..dd8dee49f 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -327,6 +327,10 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) OPTION(WITH_SSE2 "With SSE2" ON ) OPTION(WITH_SSE3 "With SSE3" ON ) + + IF(NOT MSVC) + OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) + ENDIF(NOT MSVC) ENDMACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) MACRO(NL_SETUP_NELNS_DEFAULT_OPTIONS) @@ -621,6 +625,10 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-msse3") ENDIF(WITH_SSE3) + IF(WITH_GCC_FPMATH_BOTH) + ADD_PLATFORM_FLAGS("-mfpmath=both") + ENDIF(WITH_GCC_FPMATH_BOTH) + IF(APPLE) IF(NOT XCODE) IF(CMAKE_OSX_ARCHITECTURES) From 655c22e8396443b868ee353b78c5371c2df23717 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 20 Jun 2014 23:24:54 +0200 Subject: [PATCH 33/37] Fix compile --- code/nel/include/nel/misc/types_nl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index d0111fb08..d27fc4b48 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -365,6 +365,7 @@ typedef unsigned int uint; // at least 32bits (depend of processor) inline void *aligned_malloc(size_t size, size_t alignment) { return _aligned_malloc(size, alignment); } inline void aligned_free(void *ptr) { _aligned_free(ptr); } #else +#include inline void *aligned_malloc(size_t size, size_t alignment) { return memalign(alignment, size); } inline void aligned_free(void *ptr) { free(ptr); } #endif /* NL_COMP_ */ @@ -383,7 +384,7 @@ extern void operator delete[](void *p) throw(); #else /* NL_HAS_SSE2 */ #define NL_DEFAULT_MEMORY_ALIGNMENT 4 -#define NL_ALIGN_SSE2 +#define NL_ALIGN_SSE2 #endif /* NL_HAS_SSE2 */ From cf3e779ae94debff3141f85bb005a7475318451e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 20 Jun 2014 23:38:44 +0200 Subject: [PATCH 34/37] Fix compile --- code/nel/src/3d/mesh_mrm_skin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/nel/src/3d/mesh_mrm_skin.cpp b/code/nel/src/3d/mesh_mrm_skin.cpp index a34eeb766..23ff04fee 100644 --- a/code/nel/src/3d/mesh_mrm_skin.cpp +++ b/code/nel/src/3d/mesh_mrm_skin.cpp @@ -16,6 +16,10 @@ #include "std3d.h" +#ifdef NL_HAS_SSE2 +# include +#endif + #include "nel/misc/bsphere.h" #include "nel/misc/fast_mem.h" #include "nel/misc/system_info.h" From 5cb8a7700e04b91202ffa0a1d8fa408b0dddf816 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 21 Jun 2014 05:46:20 +0200 Subject: [PATCH 35/37] Exit with error --- code/nel/src/gui/interface_parser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 3d7a1c849..b26a403c4 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -647,8 +647,7 @@ namespace NLGUI { if(!parseLUAScript(root)) { - nlwarning ("could not parse 'lua'"); - exit( EXIT_FAILURE ); + nlerror ("could not parse 'lua'"); } } else From 353c74ff21137a9d882d19d06b63552cf92d03ed Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 21 Jun 2014 06:41:14 +0200 Subject: [PATCH 36/37] Don't enforce native fragment programs on modern hardware. Fixes water for the open source ATI/AMD driver, which reports fragment programs as not native (as they are translated to modern hardware). --- code/nel/src/3d/driver/opengl/driver_opengl.cpp | 5 +++++ .../src/3d/driver/opengl/driver_opengl_extension.cpp | 12 +++++++++++- .../src/3d/driver/opengl/driver_opengl_extension.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 3d6031caf..eb59f2205 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -483,6 +483,11 @@ bool CDriverGL::setupDisplay() glLightModeli((GLenum)GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT); #endif } + + if (_Extensions.ARBFragmentShader) + { + _ForceNativeFragmentPrograms = false; + } _VertexProgramEnabled= false; _PixelProgramEnabled= false; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index 515d553aa..aee3e74bb 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -1249,6 +1249,15 @@ static bool setupNVFragmentProgram2(const char *glext) return true; } +// ********************************* +static bool setupARBFragmentShader(const char *glext) +{ + H_AUTO_OGL(setupNVFragmentProgram2); + CHECK_EXT("GL_ARB_fragment_shader"); + + return true; +} + // *************************************************************************** static bool setupARBVertexBufferObject(const char *glext) { @@ -1627,7 +1636,7 @@ void registerGlExtensions(CGlExtensions &ext) { ext.NVVertexProgram = setupNVVertexProgram(glext); ext.EXTVertexShader = setupEXTVertexShader(glext); - ext.ARBVertexProgram= setupARBVertexProgram(glext); + ext.ARBVertexProgram = setupARBVertexProgram(glext); } else { @@ -1642,6 +1651,7 @@ void registerGlExtensions(CGlExtensions &ext) { ext.ARBFragmentProgram = setupARBFragmentProgram(glext); ext.NVFragmentProgram2 = setupNVFragmentProgram2(glext); + ext.ARBFragmentShader = setupARBFragmentShader(glext); } else { diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h index 07599366c..dba5facfb 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -104,6 +104,7 @@ struct CGlExtensions bool ARBVertexProgram; bool ARBTextureNonPowerOfTwo; bool ARBMultisample; + bool ARBFragmentShader; // NV Pixel Programs bool NVFragmentProgram2; @@ -178,6 +179,7 @@ public: ARBTextureRectangle = false; ARBTextureNonPowerOfTwo = false; ARBMultisample = false; + ARBFragmentShader = false; NVOcclusionQuery = false; ARBOcclusionQuery = false; FrameBufferObject = false; From e8f7851dd20ab27d429762a9764999bc16181ded Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 21 Jun 2014 22:32:49 +0200 Subject: [PATCH 37/37] Fix compile --- code/ryzom/client/src/CMakeLists.txt | 4 ++-- code/ryzom/client/src/camera.cpp | 2 +- code/ryzom/client/src/main_loop_debug.cpp | 2 +- code/ryzom/client/src/main_loop_temp.cpp | 2 +- code/ryzom/client/src/main_loop_utilities.cpp | 2 +- code/ryzom/client/src/ping.cpp | 2 +- code/ryzom/client/src/profiling.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/ryzom/client/src/CMakeLists.txt b/code/ryzom/client/src/CMakeLists.txt index 1fc53145b..637003321 100644 --- a/code/ryzom/client/src/CMakeLists.txt +++ b/code/ryzom/client/src/CMakeLists.txt @@ -121,9 +121,9 @@ NL_ADD_RUNTIME_FLAGS(ryzom_client) NL_ADD_LIB_SUFFIX(ryzom_client) -IF(WITH_PCH) +IF(WITH_PCH AND (NOT MINGW OR NOT WITH_SYMBOLS)) ADD_NATIVE_PRECOMPILED_HEADER(ryzom_client ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp) -ENDIF(WITH_PCH) +ENDIF(WITH_PCH AND (NOT MINGW OR NOT WITH_SYMBOLS)) INSTALL(TARGETS ryzom_client RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client BUNDLE DESTINATION /Applications) diff --git a/code/ryzom/client/src/camera.cpp b/code/ryzom/client/src/camera.cpp index c409f9e58..5f388fb28 100644 --- a/code/ryzom/client/src/camera.cpp +++ b/code/ryzom/client/src/camera.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdpch.h" #include "camera.h" #include diff --git a/code/ryzom/client/src/main_loop_debug.cpp b/code/ryzom/client/src/main_loop_debug.cpp index dbcb47b96..8b224f27f 100644 --- a/code/ryzom/client/src/main_loop_debug.cpp +++ b/code/ryzom/client/src/main_loop_debug.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdpch.h" #include "main_loop_debug.h" #include diff --git a/code/ryzom/client/src/main_loop_temp.cpp b/code/ryzom/client/src/main_loop_temp.cpp index 0b3f24fa3..0bb49b13f 100644 --- a/code/ryzom/client/src/main_loop_temp.cpp +++ b/code/ryzom/client/src/main_loop_temp.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdpch.h" #include "main_loop_temp.h" #include "global.h" diff --git a/code/ryzom/client/src/main_loop_utilities.cpp b/code/ryzom/client/src/main_loop_utilities.cpp index bca1ccad2..194810ea9 100644 --- a/code/ryzom/client/src/main_loop_utilities.cpp +++ b/code/ryzom/client/src/main_loop_utilities.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdpch.h" #include "main_loop_utilities.h" #include diff --git a/code/ryzom/client/src/ping.cpp b/code/ryzom/client/src/ping.cpp index 5a07a2b9d..98d469592 100644 --- a/code/ryzom/client/src/ping.cpp +++ b/code/ryzom/client/src/ping.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdpch.h" #include "ping.h" #include "interface_v3/interface_manager.h" diff --git a/code/ryzom/client/src/profiling.cpp b/code/ryzom/client/src/profiling.cpp index a5a0f770f..85805bbf4 100644 --- a/code/ryzom/client/src/profiling.cpp +++ b/code/ryzom/client/src/profiling.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdpch.h" #include "profiling.h" // NeL includes