mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-28 03:10:54 +00:00
Merge with develop
This commit is contained in:
parent
0f44e01d18
commit
d2676c3b57
32 changed files with 475 additions and 126 deletions
|
@ -865,6 +865,12 @@ public:
|
|||
* get the official name of the driver
|
||||
*/
|
||||
virtual const char *getVideocardInformation () = 0;
|
||||
|
||||
/**
|
||||
* Get total video memory.
|
||||
* get the amount of video memory of current adapter, result is in KiB, -1 if unable to determine
|
||||
*/
|
||||
virtual sint getTotalVideoMemory () const = 0;
|
||||
// @}
|
||||
|
||||
|
||||
|
@ -1342,6 +1348,7 @@ public:
|
|||
uint32 DeviceId;
|
||||
uint32 SubSysId;
|
||||
uint32 Revision;
|
||||
sint32 VideoMemory; // video memory in KiB, -1 if unable to determine
|
||||
};
|
||||
|
||||
// Get the number of hardware renderer available on the client platform.
|
||||
|
|
|
@ -412,6 +412,7 @@ public:
|
|||
virtual uint32 getImplementationVersion () const;
|
||||
virtual const char* getDriverInformation ();
|
||||
virtual const char* getVideocardInformation ();
|
||||
virtual sint getTotalVideoMemory () const;
|
||||
virtual uint getNbTextureStages();
|
||||
virtual void getWindowSize (uint32 &width, uint32 &height);
|
||||
virtual uint getWindowWidth ();
|
||||
|
|
|
@ -505,6 +505,12 @@ public:
|
|||
*/
|
||||
virtual const char* getVideocardInformation () = 0;
|
||||
|
||||
/**
|
||||
* Get total video memory.
|
||||
* get the amount of video memory of current adapter, result is in KiB, -1 if unable to determine
|
||||
*/
|
||||
virtual sint getTotalVideoMemory () const = 0;
|
||||
|
||||
/// Get the number of texture stage available, for multitexturing (Normal material shaders). Valid only after setDisplay().
|
||||
virtual uint getNbTextureStages() = 0;
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace NLMISC
|
|||
# define NL_WIN_CALLBACK
|
||||
#endif
|
||||
|
||||
// Default to 8KB stack for tasks
|
||||
const unsigned int NL_TASK_STACK_SIZE = 8*1024;
|
||||
// Default to 1MiB stack for tasks
|
||||
const uint NL_TASK_STACK_SIZE = 1024*1024;
|
||||
|
||||
// forward def for platform specific data
|
||||
struct TCoTaskData;
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef _WIN32_WINDOWS
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# define _WIN32_WINDOWS 0x0500
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0400
|
||||
# define _WIN32_WINNT 0x0500
|
||||
#endif
|
||||
#ifndef WINVER
|
||||
# define WINVER 0x0400
|
||||
# define WINVER 0x0500
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef _WIN32_WINDOWS
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# define _WIN32_WINDOWS 0x0500
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0400
|
||||
# define _WIN32_WINNT 0x0500
|
||||
#endif
|
||||
#ifndef WINVER
|
||||
# define WINVER 0x0400
|
||||
# define WINVER 0x0500
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
|
|
|
@ -293,12 +293,7 @@ public:
|
|||
if (!atomic_swap (&_Lock))
|
||||
break;
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
nlSleep (wait_time);
|
||||
#else
|
||||
//std::cout << "Sleeping i=" << i << std::endl;
|
||||
usleep( wait_time*1000 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -401,12 +396,7 @@ public:
|
|||
if (!CFastMutex::atomic_swap (&_Lock))
|
||||
break;
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
nlSleep (wait_time);
|
||||
#else
|
||||
//std::cout << "Sleeping i=" << i << std::endl;
|
||||
usleep( wait_time*1000 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,9 +195,11 @@ inline std::string toString(const sint64 &val) { return toString("%"NL_I64"d", v
|
|||
// error fix for size_t? gcc 4.1.2 requested this type instead of size_t ...
|
||||
inline std::string toString(const long unsigned int &val)
|
||||
{
|
||||
if (sizeof(long unsigned int) == 8)
|
||||
return toString((uint64)val);
|
||||
#ifdef _LP64
|
||||
return toString((uint64)val);
|
||||
#else
|
||||
return toString((uint32)val);
|
||||
#endif
|
||||
}
|
||||
|
||||
# endif
|
||||
|
@ -210,6 +212,7 @@ inline std::string toString(const size_t &val) { return toString("%"NL_I64"u", v
|
|||
inline std::string toString(const size_t &val) { return toString("%u", val); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inline std::string toString(const float &val) { return toString("%f", val); }
|
||||
inline std::string toString(const double &val) { return toString("%lf", val); }
|
||||
inline std::string toString(const bool &val) { return toString("%u", val?1:0); }
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
/// Detect whether the current process is a windowed application. Return true if definitely yes, false if unknown
|
||||
static bool detectWindowedApplication();
|
||||
|
||||
static sint getTotalVideoMemory();
|
||||
};
|
||||
|
||||
} // NLMISC
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef _WIN32_WINDOWS
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# define _WIN32_WINDOWS 0x0500
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0400
|
||||
# define _WIN32_WINNT 0x0500
|
||||
#endif
|
||||
#ifndef WINVER
|
||||
# define WINVER 0x0400
|
||||
# define WINVER 0x0500
|
||||
#endif
|
||||
#ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace NL3D
|
|||
{
|
||||
|
||||
// ***************************************************************************
|
||||
const uint32 IDriver::InterfaceVersion = 0x6f; // getters for anisotropic filter
|
||||
const uint32 IDriver::InterfaceVersion = 0x70; // total video memory
|
||||
|
||||
// ***************************************************************************
|
||||
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )
|
||||
|
|
|
@ -2381,6 +2381,7 @@ bool CDriverD3D::getAdapter(uint adapter, IDriver::CAdapter &desc) const
|
|||
desc.Revision = identifier.Revision;
|
||||
desc.SubSysId = identifier.SubSysId;
|
||||
desc.VendorId = identifier.VendorId;
|
||||
desc.VideoMemory = _Adapter == _adapter ? getTotalVideoMemory():-1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2874,6 +2875,17 @@ const char *CDriverD3D::getVideocardInformation ()
|
|||
|
||||
// ***************************************************************************
|
||||
|
||||
sint CDriverD3D::getTotalVideoMemory () const
|
||||
{
|
||||
H_AUTO_D3D(CDriverD3D_getTotalVideoMemory);
|
||||
|
||||
// Can't use _DeviceInterface->GetAvailableTextureMem() because it's not reliable
|
||||
// Returns 4 GiB instead of 2 with my GPU
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
void CDriverD3D::getBuffer (CBitmap &bitmap)
|
||||
{
|
||||
H_AUTO_D3D(CDriverD3D_getBuffer);
|
||||
|
|
|
@ -900,6 +900,7 @@ public:
|
|||
virtual uint32 getImplementationVersion () const;
|
||||
virtual const char* getDriverInformation ();
|
||||
virtual const char* getVideocardInformation ();
|
||||
virtual sint getTotalVideoMemory () const;
|
||||
virtual CVertexBuffer::TVertexColorType getVertexColorFormat() const;
|
||||
|
||||
// Textures
|
||||
|
|
|
@ -1199,6 +1199,105 @@ const char *CDriverGL::getVideocardInformation ()
|
|||
return name;
|
||||
}
|
||||
|
||||
sint CDriverGL::getTotalVideoMemory() const
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_getTotalVideoMemory);
|
||||
|
||||
if (_Extensions.NVXGPUMemoryInfo)
|
||||
{
|
||||
GLint memoryInKiB = 0;
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &memoryInKiB);
|
||||
|
||||
nlinfo("3D: GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX returned %d KiB", memoryInKiB);
|
||||
return memoryInKiB;
|
||||
}
|
||||
|
||||
if (_Extensions.ATIMeminfo)
|
||||
{
|
||||
GLint memoryInKiB = 0;
|
||||
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &memoryInKiB);
|
||||
|
||||
nlinfo("3D: GL_TEXTURE_FREE_MEMORY_ATI returned %d KiB", memoryInKiB);
|
||||
return memoryInKiB;
|
||||
}
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
if (_Extensions.WGLAMDGPUAssociation)
|
||||
{
|
||||
GLuint uNoOfGPUs = nwglGetGPUIDsAMD(0, 0);
|
||||
GLuint *uGPUIDs = new GLuint[uNoOfGPUs];
|
||||
nwglGetGPUIDsAMD(uNoOfGPUs, uGPUIDs);
|
||||
|
||||
GLuint memoryInMiB = 0;
|
||||
nwglGetGPUInfoAMD(uGPUIDs[0], WGL_GPU_RAM_AMD, GL_UNSIGNED_INT, sizeof(GLuint), &memoryInMiB);
|
||||
|
||||
delete [] uGPUIDs;
|
||||
|
||||
nlinfo("3D: WGL_GPU_RAM_AMD returned %d MiB", memoryInMiB);
|
||||
return memoryInMiB * 1024;
|
||||
}
|
||||
#elif defined(NL_OS_MAC)
|
||||
GLint rendererID;
|
||||
|
||||
// get current renderer ID
|
||||
CGLError error = CGLGetParameter([_ctx CGLContextObj], kCGLCPCurrentRendererID, &rendererID);
|
||||
|
||||
if (error == kCGLNoError)
|
||||
{
|
||||
GLint nrend = 0;
|
||||
CGLRendererInfoObj rend;
|
||||
|
||||
// get renderer info for all renderers
|
||||
error = CGLQueryRendererInfo(0xffffffff, &rend, &nrend);
|
||||
|
||||
if (error == kCGLNoError)
|
||||
{
|
||||
for (GLint i = 0; i < nrend; ++i)
|
||||
{
|
||||
GLint thisRendererID;
|
||||
error = CGLDescribeRenderer(rend, i, kCGLRPRendererID, &thisRendererID);
|
||||
|
||||
if (error == kCGLNoError)
|
||||
{
|
||||
// see if this is the one we want
|
||||
if (thisRendererID == rendererID)
|
||||
{
|
||||
GLint memoryInMiB = 0;
|
||||
CGLError error = CGLDescribeRenderer(rend, i, kCGLRPVideoMemoryMegabytes, &memoryInMiB);
|
||||
|
||||
if (error == kCGLNoError)
|
||||
{
|
||||
// convert in KiB
|
||||
return memoryInMiB * 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("3D: Unable to get video memory (%s)", CGLErrorString(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("3D: Unable to get renderer ID (%s)", CGLErrorString(error));
|
||||
}
|
||||
}
|
||||
|
||||
CGLDestroyRendererInfo(rend);
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("3D: Unable to get renderers info (%s)", CGLErrorString(error));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlerror("3D: Unable to get current renderer ID (%s)", CGLErrorString(error));
|
||||
}
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CDriverGL::clipRect(NLMISC::CRect &rect)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_clipRect)
|
||||
|
@ -2546,6 +2645,7 @@ bool CDriverGL::getAdapter(uint adapter, CAdapter &desc) const
|
|||
desc.Revision = 0;
|
||||
desc.SubSysId = 0;
|
||||
desc.VendorId = 0;
|
||||
desc.VideoMemory = getTotalVideoMemory();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -520,6 +520,8 @@ public:
|
|||
|
||||
virtual const char* getVideocardInformation ();
|
||||
|
||||
virtual sint getTotalVideoMemory() const;
|
||||
|
||||
virtual bool isActive ();
|
||||
|
||||
virtual uint8 getBitPerPixel ();
|
||||
|
|
|
@ -1790,44 +1790,7 @@ void registerGlExtensions(CGlExtensions &ext)
|
|||
|
||||
#ifndef USE_OPENGLES
|
||||
ext.NVXGPUMemoryInfo = setupNVXGPUMemoryInfo(glext);
|
||||
|
||||
if (ext.NVXGPUMemoryInfo)
|
||||
{
|
||||
GLint nEvictionCount = 0;
|
||||
#ifdef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &nEvictionCount);
|
||||
#endif
|
||||
|
||||
GLint nEvictionMemory = 0;
|
||||
#ifdef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &nEvictionMemory);
|
||||
#endif
|
||||
|
||||
GLint nDedicatedMemoryInKB = 0;
|
||||
#ifdef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &nDedicatedMemoryInKB);
|
||||
#endif
|
||||
|
||||
GLint nTotalMemoryInKB = 0;
|
||||
#ifdef GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &nTotalMemoryInKB);
|
||||
#endif
|
||||
|
||||
GLint nCurAvailMemoryInKB = 0;
|
||||
#ifdef GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &nCurAvailMemoryInKB);
|
||||
#endif
|
||||
|
||||
nlinfo("Memory: total: %d available: %d dedicated: %d", nTotalMemoryInKB, nCurAvailMemoryInKB, nDedicatedMemoryInKB);
|
||||
}
|
||||
|
||||
ext.ATIMeminfo = setupATIMeminfo(glext);
|
||||
|
||||
if (ext.ATIMeminfo)
|
||||
{
|
||||
GLint nCurAvailMemoryInKB = 0;
|
||||
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &nCurAvailMemoryInKB);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1999,18 +1962,6 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
|
|||
|
||||
ext.WGLAMDGPUAssociation = setupWGLAMDGPUAssociation(glext);
|
||||
|
||||
if (ext.WGLAMDGPUAssociation)
|
||||
{
|
||||
GLuint uNoOfGPUs = nwglGetGPUIDsAMD(0, 0);
|
||||
GLuint *uGPUIDs = new GLuint[uNoOfGPUs];
|
||||
nwglGetGPUIDsAMD(uNoOfGPUs, uGPUIDs);
|
||||
|
||||
GLuint uTotalMemoryInMB = 0;
|
||||
nwglGetGPUInfoAMD(uGPUIDs[0], WGL_GPU_RAM_AMD, GL_UNSIGNED_INT, sizeof(GLuint), &uTotalMemoryInMB);
|
||||
|
||||
delete [] uGPUIDs;
|
||||
}
|
||||
|
||||
ext.WGLNVGPUAffinity = setupWGLNVGPUAssociation(glext);
|
||||
|
||||
if (ext.WGLNVGPUAffinity)
|
||||
|
|
|
@ -1534,6 +1534,12 @@ const char* CDriverUser::getVideocardInformation ()
|
|||
|
||||
return _Driver->getVideocardInformation ();
|
||||
}
|
||||
sint CDriverUser::getTotalVideoMemory () const
|
||||
{
|
||||
NL3D_HAUTO_UI_DRIVER;
|
||||
|
||||
return _Driver->getTotalVideoMemory ();
|
||||
}
|
||||
uint CDriverUser::getNbTextureStages()
|
||||
{
|
||||
NL3D_HAUTO_UI_DRIVER;
|
||||
|
|
|
@ -24,12 +24,6 @@
|
|||
#include "nel/misc/i_xml.h"
|
||||
#include "nel/misc/o_xml.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#ifndef NL_COMP_MINGW
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif // NL_OS_WINDOWS
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
|
|
@ -362,7 +362,7 @@ string bytesToHumanReadable (const std::string &bytes)
|
|||
|
||||
string bytesToHumanReadable (uint64 bytes)
|
||||
{
|
||||
static const char *divTable[]= { "B", "KB", "MB", "GB", "TB" };
|
||||
static const char *divTable[]= { "B", "KiB", "MiB", "GiB", "TiB" };
|
||||
uint div = 0;
|
||||
uint64 res = bytes;
|
||||
uint64 newres = res;
|
||||
|
|
|
@ -715,7 +715,8 @@ public:
|
|||
{
|
||||
str = "<NoModule>";
|
||||
}
|
||||
str += toString("!0x%X", addr);
|
||||
|
||||
str += toString("!0x%p", (void*)addr);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -740,9 +741,8 @@ public:
|
|||
{
|
||||
str = "<NoModule>";
|
||||
}
|
||||
char tmp[32];
|
||||
sprintf (tmp, "!0x%p", addr);
|
||||
str += tmp;
|
||||
|
||||
str += toString("!0x%p", (void*)addr);
|
||||
//}
|
||||
str +=" DEBUG:"+toString("0x%p", addr);
|
||||
|
||||
|
|
|
@ -138,9 +138,8 @@ static string getSourceInfo (DWORD_TYPE addr)
|
|||
{
|
||||
str = "<NoModule>";
|
||||
}
|
||||
char tmp[32];
|
||||
sprintf (tmp, "!0x%X", addr);
|
||||
str += tmp;
|
||||
|
||||
str += toString("!0x%p", (void*)addr);
|
||||
}
|
||||
|
||||
return str;
|
||||
|
|
|
@ -46,12 +46,12 @@
|
|||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# define _WIN32_WINDOWS 0x0500
|
||||
# ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0400
|
||||
# define _WIN32_WINNT 0x0500
|
||||
# endif
|
||||
# ifndef NL_COMP_MINGW
|
||||
# define WINVER 0x0400
|
||||
# define WINVER 0x0500
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <WinSock2.h>
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
#include "nel/misc/system_utils.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#define INITGUID
|
||||
#include <ddraw.h>
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <dxgi.h>
|
||||
#include <initguid.h>
|
||||
#include <CGuid.h>
|
||||
# include <ObjBase.h>
|
||||
# ifdef _WIN32_WINNT_WIN7
|
||||
// only supported by Windows 7 Platform SDK
|
||||
|
@ -365,4 +373,234 @@ bool CSystemUtils::detectWindowedApplication()
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#ifndef SAFE_RELEASE
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
typedef HRESULT (WINAPI* LPDIRECTDRAWCREATE)(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter);
|
||||
typedef HRESULT (WINAPI* LPCREATEDXGIFACTORY)(REFIID, void**);
|
||||
|
||||
static std::string FormatError(HRESULT hr)
|
||||
{
|
||||
std::string res;
|
||||
|
||||
LPTSTR errorText = NULL;
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errorText, 0, NULL);
|
||||
|
||||
if (errorText)
|
||||
{
|
||||
res = NLMISC::toString("%s (0x%x)", errorText, hr);
|
||||
LocalFree(errorText);
|
||||
errorText = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct SAdapter
|
||||
{
|
||||
uint id;
|
||||
std::string name;
|
||||
sint memory;
|
||||
GUID guid;
|
||||
HMONITOR hMonitor;
|
||||
bool found;
|
||||
|
||||
SAdapter()
|
||||
{
|
||||
id = 0;
|
||||
memory = -1;
|
||||
guid = GUID_NULL;
|
||||
hMonitor = NULL;
|
||||
found = false;
|
||||
}
|
||||
};
|
||||
|
||||
static std::list<SAdapter> s_dxgiAdapters;
|
||||
|
||||
static void EnumerateUsingDXGI(IDXGIFactory *pDXGIFactory)
|
||||
{
|
||||
nlassert(pDXGIFactory != NULL);
|
||||
|
||||
for(uint index = 0; ; ++index)
|
||||
{
|
||||
IDXGIAdapter *pAdapter = NULL;
|
||||
HRESULT hr = pDXGIFactory->EnumAdapters(index, &pAdapter);
|
||||
// DXGIERR_NOT_FOUND is expected when the end of the list is hit
|
||||
if (FAILED(hr)) break;
|
||||
|
||||
DXGI_ADAPTER_DESC desc;
|
||||
memset(&desc, 0, sizeof(DXGI_ADAPTER_DESC));
|
||||
|
||||
if (SUCCEEDED(pAdapter->GetDesc(&desc)))
|
||||
{
|
||||
SAdapter adapter;
|
||||
adapter.id = index;
|
||||
adapter.name = ucstring((ucchar*)desc.Description).toUtf8();
|
||||
adapter.memory = desc.DedicatedVideoMemory / 1024;
|
||||
adapter.found = true;
|
||||
|
||||
nldebug("DXGI Adapter: %u - %s - DedicatedVideoMemory: %d KiB", index, adapter.name.c_str(), adapter.memory);
|
||||
|
||||
s_dxgiAdapters.push_back(adapter);
|
||||
}
|
||||
|
||||
SAFE_RELEASE(pAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DDEnumCallbackEx(GUID FAR* lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
|
||||
{
|
||||
SAdapter * pAdapter = (SAdapter*)lpContext;
|
||||
|
||||
if (pAdapter->hMonitor == hm)
|
||||
{
|
||||
pAdapter->name = lpDriverDescription;
|
||||
pAdapter->guid = *lpGUID;
|
||||
pAdapter->found = true;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sint CSystemUtils::getTotalVideoMemory()
|
||||
{
|
||||
sint res = -1;
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
// using DXGI
|
||||
HINSTANCE hDXGI = LoadLibraryA("dxgi.dll");
|
||||
|
||||
if (hDXGI)
|
||||
{
|
||||
|
||||
// We prefer the use of DXGI 1.1
|
||||
LPCREATEDXGIFACTORY pCreateDXGIFactory = (LPCREATEDXGIFACTORY)GetProcAddress(hDXGI, "CreateDXGIFactory1");
|
||||
|
||||
if (!pCreateDXGIFactory)
|
||||
{
|
||||
pCreateDXGIFactory = (LPCREATEDXGIFACTORY)GetProcAddress(hDXGI, "CreateDXGIFactory");
|
||||
}
|
||||
|
||||
if (pCreateDXGIFactory)
|
||||
{
|
||||
IDXGIFactory *pDXGIFactory = NULL;
|
||||
HRESULT hr = pCreateDXGIFactory(__uuidof(IDXGIFactory), (LPVOID*)&pDXGIFactory);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
EnumerateUsingDXGI(pDXGIFactory);
|
||||
|
||||
SAFE_RELEASE(pDXGIFactory);
|
||||
|
||||
if (!s_dxgiAdapters.empty())
|
||||
{
|
||||
// TODO: determine what adapter is used by NeL
|
||||
res = s_dxgiAdapters.front().memory;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to find an DXGI adapter");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to create DXGI factory");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("dxgi.dll missing entry-point");
|
||||
}
|
||||
|
||||
FreeLibrary(hDXGI);
|
||||
}
|
||||
|
||||
if (res == -1)
|
||||
{
|
||||
// using DirectDraw
|
||||
HMODULE hInstDDraw = LoadLibraryA("ddraw.dll");
|
||||
|
||||
if (hInstDDraw)
|
||||
{
|
||||
SAdapter adapter;
|
||||
adapter.hMonitor = MonitorFromWindow(s_window, MONITOR_DEFAULTTONULL);
|
||||
|
||||
LPDIRECTDRAWENUMERATEEXA pDirectDrawEnumerateEx = (LPDIRECTDRAWENUMERATEEXA)GetProcAddress(hInstDDraw, "DirectDrawEnumerateExA");
|
||||
LPDIRECTDRAWCREATE pDDCreate = (LPDIRECTDRAWCREATE)GetProcAddress(hInstDDraw, "DirectDrawCreate");
|
||||
|
||||
if (pDirectDrawEnumerateEx && pDDCreate)
|
||||
{
|
||||
HRESULT hr = pDirectDrawEnumerateEx(DDEnumCallbackEx, (VOID*)&adapter, DDENUM_ATTACHEDSECONDARYDEVICES);
|
||||
|
||||
if (SUCCEEDED(hr) && adapter.found)
|
||||
{
|
||||
LPDIRECTDRAW pDDraw = NULL;
|
||||
hr = pDDCreate(&adapter.guid, &pDDraw, NULL);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
LPDIRECTDRAW7 pDDraw7 = NULL;
|
||||
hr = pDDraw->QueryInterface(IID_IDirectDraw7, (VOID**)&pDDraw7);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
DDSCAPS2 ddscaps;
|
||||
memset(&ddscaps, 0, sizeof(DDSCAPS2));
|
||||
ddscaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
|
||||
|
||||
DWORD pdwAvailableVidMem;
|
||||
hr = pDDraw7->GetAvailableVidMem(&ddscaps, &pdwAvailableVidMem, NULL);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
res = (sint)pdwAvailableVidMem / 1024;
|
||||
nlinfo("DirectDraw Adapter: %s - DedicatedVideoMemory: %d KiB", adapter.name.c_str(), adapter.memory);
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to get DirectDraw available video memory: %s", FormatError(hr).c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(pDDraw7);
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to query IDirectDraw7 interface: %s", FormatError(hr).c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to call DirectDrawCreate: %s", FormatError(hr).c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to enumerate DirectDraw adapters (%s): %s", (adapter.found ? "found":"not found"), FormatError(hr).c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to get pointer on DirectDraw functions (DirectDrawEnumerateExA %p, DirectDrawCreate %p)", pDirectDrawEnumerateEx, pDDCreate);
|
||||
}
|
||||
|
||||
FreeLibrary(hInstDDraw);
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to load ddraw.dll");
|
||||
}
|
||||
}
|
||||
#else
|
||||
// TODO: implement for other systems
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // NLMISC
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
# define _WIN32_WINDOWS 0x0410
|
||||
# define _WIN32_WINDOWS 0x0500
|
||||
# ifndef NL_COMP_MINGW
|
||||
# define WINVER 0x0400
|
||||
# define WINVER 0x0500
|
||||
# define NOMINMAX
|
||||
# endif
|
||||
# include <winsock2.h>
|
||||
|
|
|
@ -80,18 +80,19 @@ public:
|
|||
|
||||
#include <QtPlugin>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#if defined(Q_OS_WIN32)
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#elif defined(Q_OS_MAC)
|
||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
|
||||
#endif
|
||||
#elif defined(Q_OS_UNIX)
|
||||
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
int main( int argc, char **argv )
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifndef WIN32
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
// Workaround to default -style=gtk+ on recent Cinnamon versions
|
||||
char *currentDesktop = getenv("XDG_CURRENT_DESKTOP");
|
||||
if (currentDesktop)
|
||||
|
@ -111,14 +112,13 @@ int main( int argc, char **argv )
|
|||
CCmdLineParser::parse( argc, argv, params );
|
||||
|
||||
CCrashReportWidget w;
|
||||
w.setup( params );
|
||||
w.setup(params);
|
||||
w.show();
|
||||
|
||||
int ret = app.exec();
|
||||
|
||||
if( ret != EXIT_SUCCESS )
|
||||
if(ret != EXIT_SUCCESS)
|
||||
return ret;
|
||||
else
|
||||
return w.getReturnValue();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,20 @@
|
|||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
|
||||
#ifdef QT_STATICPLUGIN
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
|
||||
#elif defined(Q_OS_MAC)
|
||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
|
||||
#elif defined(Q_OS_UNIX)
|
||||
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
|
|
@ -12,6 +12,20 @@
|
|||
#define NL_WORDS_DIC_CFG "."
|
||||
#endif
|
||||
|
||||
#ifdef QT_STATICPLUGIN
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
|
||||
#elif defined(Q_OS_MAC)
|
||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
|
||||
#elif defined(Q_OS_UNIX)
|
||||
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
|
|
|
@ -886,6 +886,15 @@ void initMainLoop()
|
|||
{
|
||||
if(ClientCfg.HDEntityTexture)
|
||||
{
|
||||
// temporary code for debug
|
||||
sint videoMemory = Driver->getTotalVideoMemory();
|
||||
|
||||
if (videoMemory < 0) videoMemory = CSystemUtils::getTotalVideoMemory();
|
||||
|
||||
videoMemory /= 1024; // size in MiB
|
||||
|
||||
nlinfo("Video Memory detected: %d MiB", videoMemory);
|
||||
|
||||
// setup "v2 texture" (or 512*512)
|
||||
Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL, ENTITY_TEXTURE_HIGH_LEVEL);
|
||||
// Allow a big cache for them (should be on 512 Mo card only)
|
||||
|
|
|
@ -88,7 +88,7 @@ struct SBotChatAutomatonState
|
|||
uint On[5]; // value to return on player click of slot 0..4
|
||||
|
||||
// ctor -----------------------------------------------------------------
|
||||
SBotChatAutomatonState(SBotChatPage *page,uint on0=~0u,uint on1=~0u,uint on2=~0u,uint on3=~0u,uint on4=~0u)
|
||||
SBotChatAutomatonState(SBotChatPage *page,uint on0=std::numeric_limits<uint>::max(),uint on1=std::numeric_limits<uint>::max(),uint on2=std::numeric_limits<uint>::max(),uint on3=std::numeric_limits<uint>::max(),uint on4=std::numeric_limits<uint>::max())
|
||||
{
|
||||
Page=page;
|
||||
On[0]=on0;
|
||||
|
@ -100,8 +100,8 @@ struct SBotChatAutomatonState
|
|||
// make sure the number of arguments supplied corresponds to the
|
||||
// number of options prresent on the user interfac page
|
||||
nlassert(page->NumOptions>=0 && page->NumOptions<=4);
|
||||
nlassert(page->NumOptions==0 || On[page->NumOptions-1]!=~0u);
|
||||
nlassert(page->NumOptions==4 || On[page->NumOptions]==~0u);
|
||||
nlassert(page->NumOptions==0 || On[page->NumOptions-1]!=std::numeric_limits<uint>::max());
|
||||
nlassert(page->NumOptions==4 || On[page->NumOptions]==std::numeric_limits<uint>::max());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -344,7 +344,7 @@ struct CBotChat
|
|||
|
||||
void setState(uint32 state)
|
||||
{
|
||||
if (state>=Automaton->Size && state!=~0u)
|
||||
if (state>=Automaton->Size && state!=std::numeric_limits<uint32>::max())
|
||||
{
|
||||
nlwarning("CBotChatEntry()::setState: Invalid state: %d",state);
|
||||
return;
|
||||
|
@ -356,7 +356,7 @@ struct CBotChat
|
|||
|
||||
// open the new page
|
||||
CurrentState=state;
|
||||
if (state==~0u)
|
||||
if (state==std::numeric_limits<uint32>::max())
|
||||
Done=true;
|
||||
else
|
||||
Done=!Automaton->States[CurrentState].Page->PageType->open(Player,Bot);
|
||||
|
@ -377,7 +377,7 @@ struct CBotChat
|
|||
void setAutomaton(SBotChatAutomaton *automaton)
|
||||
{
|
||||
Automaton=automaton;
|
||||
CurrentState=~0u; // set this to a ~0 so that setState doesn't try to clse existing page
|
||||
CurrentState=std::numeric_limits<uint32>::max(); // set this to a ~0 so that setState doesn't try to clse existing page
|
||||
setState(0);
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ struct CBotChat
|
|||
|
||||
void endChat ()
|
||||
{
|
||||
setState(~0u);
|
||||
setState(std::numeric_limits<uint32>::max());
|
||||
}
|
||||
|
||||
CEntityId Player;
|
||||
|
@ -672,7 +672,7 @@ struct SBotChatAutomatonState
|
|||
uint On[5]; // value to return on player click of slot 0..4
|
||||
|
||||
// ctor -----------------------------------------------------------------
|
||||
SBotChatAutomatonState(SBotChatPage *page,uint on0=~0u,uint on1=~0u,uint on2=~0u,uint on3=~0u,uint on4=~0u)
|
||||
SBotChatAutomatonState(SBotChatPage *page,uint on0=std::numeric_limits<uint>::max(),uint on1=std::numeric_limits<uint>::max(),uint on2=std::numeric_limits<uint>::max(),uint on3=std::numeric_limits<uint>::max(),uint on4=std::numeric_limits<uint>::max())
|
||||
{
|
||||
Page=page;
|
||||
On[0]=on0;
|
||||
|
@ -684,8 +684,8 @@ struct SBotChatAutomatonState
|
|||
// make sure the number of arguments supplied corresponds to the
|
||||
// number of options prresent on the user interfac page
|
||||
nlassert(page->NumOptions>=0 && page->NumOptions<=4);
|
||||
nlassert(page->NumOptions==0 || On[page->NumOptions-1]!=~0u);
|
||||
nlassert(page->NumOptions==4 || On[page->NumOptions]==~0u);
|
||||
nlassert(page->NumOptions==0 || On[page->NumOptions-1]!=std::numeric_limits<uint>::max());
|
||||
nlassert(page->NumOptions==4 || On[page->NumOptions]==std::numeric_limits<uint>::max());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -928,7 +928,7 @@ struct CBotChat
|
|||
|
||||
void setState(uint32 state)
|
||||
{
|
||||
if (state>=Automaton->Size && state!=~0u)
|
||||
if (state>=Automaton->Size && state!=std::numeric_limits<uint32>::max())
|
||||
{
|
||||
nlwarning("CBotChatEntry()::setState: Invalid state: %d",state);
|
||||
return;
|
||||
|
@ -940,7 +940,7 @@ struct CBotChat
|
|||
|
||||
// open the new page
|
||||
CurrentState=state;
|
||||
if (state==~0u)
|
||||
if (state==std::numeric_limits<uint32>::max())
|
||||
Done=true;
|
||||
else
|
||||
Done=!Automaton->States[CurrentState].Page->PageType->open(Player,Bot);
|
||||
|
@ -961,7 +961,7 @@ struct CBotChat
|
|||
void setAutomaton(SBotChatAutomaton *automaton)
|
||||
{
|
||||
Automaton=automaton;
|
||||
CurrentState=~0u; // set this to a ~0 so that setState doesn't try to clse existing page
|
||||
CurrentState=std::numeric_limits<uint32>::max(); // set this to a std::numeric_limits<uint32>::max() so that setState doesn't try to clse existing page
|
||||
setState(0);
|
||||
}
|
||||
|
||||
|
@ -980,7 +980,7 @@ struct CBotChat
|
|||
|
||||
void endChat ()
|
||||
{
|
||||
setState(~0u);
|
||||
setState(std::numeric_limits<uint32>::max());
|
||||
}
|
||||
|
||||
CEntityId Player;
|
||||
|
|
|
@ -4880,7 +4880,7 @@ void CCharacter::updateVisualInformation( uint16 InventoryEmpty, uint16 SlotEmpt
|
|||
}
|
||||
// update visual property only if srcForm is valid
|
||||
if(srcForm)
|
||||
setVisualPropertyForEquipment( SlotEmpty, srcForm, 0 , 254 );
|
||||
setVisualPropertyForEquipment( SlotEmpty, srcForm, 0 , 6 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,18 +25,19 @@
|
|||
|
||||
#include <QtPlugin>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#if defined(Q_OS_WIN32)
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#elif defined(Q_OS_MAC)
|
||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
|
||||
#endif
|
||||
#elif defined(Q_OS_UNIX)
|
||||
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
|
||||
#endif
|
||||
|
||||
int main( sint32 argc, char **argv )
|
||||
#endif
|
||||
|
||||
int main(sint32 argc, char **argv)
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QApplication::setWindowIcon(QIcon(":/resources/welcome_icon.png"));
|
||||
QPixmap pixmap(":/resources/splash_screen.png" );
|
||||
|
|
|
@ -357,7 +357,7 @@ class Users{
|
|||
//error_log(print_r($rows,true));
|
||||
//error_log(print_r($result,true));
|
||||
//error_log(print_r($json,true));
|
||||
foreach ($json as $key => $value) {
|
||||
if ($json) foreach ($json as $key => $value) {
|
||||
//error_log(print_r($key,true));
|
||||
//error_log(print_r($value,true));
|
||||
|
||||
|
|
Loading…
Reference in a new issue