From f66c15c5da3b8d5472bf31b5864d0182742d31f8 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 26 Dec 2015 14:38:37 +0100 Subject: [PATCH] Merge with develop --- code/nel/include/nel/gui/view_renderer.h | 2 +- code/nel/include/nel/gui/widget_manager.h | 8 +- .../3d/driver/opengl/driver_opengl_window.cpp | 1 + code/nel/src/3d/quad_effect.cpp | 15 +- code/nel/src/3d/water_model.cpp | 3 + code/nel/src/gui/group_container.cpp | 6 +- code/nel/src/gui/group_table.cpp | 15 +- code/nel/src/gui/libwww.cpp | 2 +- code/nel/src/gui/widget_manager.cpp | 74 +++---- code/nel/src/misc/bitmap_gif.cpp | 10 +- code/nel/src/misc/system_utils.cpp | 190 +++++++++++++++++- code/ryzom/client/src/init_main_loop.cpp | 78 +++++-- .../src/interface_v3/interface_manager.cpp | 4 +- 13 files changed, 317 insertions(+), 91 deletions(-) diff --git a/code/nel/include/nel/gui/view_renderer.h b/code/nel/include/nel/gui/view_renderer.h index fe5dad405..a54708b04 100644 --- a/code/nel/include/nel/gui/view_renderer.h +++ b/code/nel/include/nel/gui/view_renderer.h @@ -169,7 +169,7 @@ namespace NLGUI /* * getScreenSize : get the screen window size changed (at last checkNewScreenSize called) */ - void getScreenSize (uint32 &w, uint32 &h); + void getScreenSize(uint32 &w, uint32 &h); /* * get OOW / OOH diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index c30bdd663..9d8ff060e 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -335,7 +335,7 @@ namespace NLGUI sint32 newW, sint32 newH) const; // move windows according to new screen size - void moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI ); + void moveAllWindowsToNewScreenSize(uint32 newScreenW, uint32 newScreenH, bool fixCurrentUI ); void updateAllLocalisedElements(); @@ -481,7 +481,7 @@ namespace NLGUI void setIngame( bool i ){ inGame = i; } bool isIngame() const{ return inGame; } - void setScreenWH( uint32 w, uint32 h ){ screenW = w; screenH = h; } + void setScreenWH(uint32 w, uint32 h){ _ScreenW = w; _ScreenH = h; } void registerNewScreenSizeHandler( INewScreenSizeHandler *handler ); void removeNewScreenSizeHandler( INewScreenSizeHandler *handler ); @@ -612,8 +612,8 @@ namespace NLGUI CEventDescriptorKey lastKeyEvent; - uint32 screenH; - uint32 screenW; + uint32 _ScreenH; + uint32 _ScreenW; std::vector< CInterfaceAnim* > activeAnims; 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 3c60da0c0..d2abbfd38 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2087,6 +2087,7 @@ bool CDriverGL::getModes(std::vector &modes) GfxMode mode; mode.Width = sizes[i].width; mode.Height = sizes[i].height; + mode.Depth = 32; mode.Frequency = 0; modes.push_back(mode); // nldebug("3D: Mode %d: %dx%d", i, mode.Width, mode.Height); diff --git a/code/nel/src/3d/quad_effect.cpp b/code/nel/src/3d/quad_effect.cpp index ab9fd91b8..8b40a786c 100644 --- a/code/nel/src/3d/quad_effect.cpp +++ b/code/nel/src/3d/quad_effect.cpp @@ -56,19 +56,17 @@ void CQuadEffect::makeRasters(const TPoint2DVect &poly { dest.clear(); - const float epsilon = 10E-5f; + startY = 0.f; sint size = (sint)poly.size(); + + if (!size) return; + + const float epsilon = 10E-5f; uint aelSize = 0; // size of active edge list sint k; // loop counter - - - dest.clear(); - - if (!size) return; - static TEdgeList lel, ael; // the left edge list, and the active edge list float highest = poly[0].y; lel.clear(); @@ -217,7 +215,8 @@ void CQuadEffect::makeRasters(const TPoint2DVect &poly currY += quadHeight; - } while (size || aelSize); + } + while (size || aelSize); } //** diff --git a/code/nel/src/3d/water_model.cpp b/code/nel/src/3d/water_model.cpp index eb8ceae27..fb53100cb 100644 --- a/code/nel/src/3d/water_model.cpp +++ b/code/nel/src/3d/water_model.cpp @@ -1640,6 +1640,9 @@ void CWaterModel::traverseRender() for(sint k = 0; k < (sint) poly.Vertices.size() - 2; ++k) { NLMISC::CTriangleUV truv; + truv.Uv0.set(0.f, 0.f); + truv.Uv1.set(0.f, 0.f); + truv.Uv2.set(0.f, 0.f); truv.V0.set(poly.Vertices[0].x, poly.Vertices[0].y, 0.f); truv.V1.set(poly.Vertices[k + 1].x, poly.Vertices[k + 1].y, 0.f); truv.V2.set(poly.Vertices[k + 2].x, poly.Vertices[k + 2].y, 0.f); diff --git a/code/nel/src/gui/group_container.cpp b/code/nel/src/gui/group_container.cpp index 5003654f9..818c71278 100644 --- a/code/nel/src/gui/group_container.cpp +++ b/code/nel/src/gui/group_container.cpp @@ -64,7 +64,7 @@ namespace NLGUI rVR.getClipWindow(x, y, w, h); uint32 sw, sh; rVR.getScreenSize(sw, sh); - rVR.setClipWindow(0, 0, (sint32) sw, (sint32) sh); + rVR.setClipWindow(0, 0, (sint32)sw, (sint32)sh); rVR.drawRotFlipBitmap (renderLayer, xreal, yreal, wreal, hreal, 0, false, rVR.getBlankTextureId(), color ); rVR.setClipWindow(x, y, w ,h); } @@ -350,7 +350,7 @@ namespace NLGUI { if (_ResizerPos & Hotspot_xR) { - clippedNewW = std::min((sint32) sw + _Parent->getW() - _Parent->getXReal(), clippedNewW); + clippedNewW = std::min((sint32)sw + _Parent->getW() - _Parent->getXReal(), clippedNewW); } else { @@ -365,7 +365,7 @@ namespace NLGUI } else { - clippedNewW = std::min((sint32) sw - _Parent->getXReal(), clippedNewW); + clippedNewW = std::min((sint32)sw - _Parent->getXReal(), clippedNewW); } } // diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index c762fb15d..a82ad5617 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -715,7 +715,7 @@ namespace NLGUI // *** Get the column sizes, we need to know min for the table uint i; - sint column = 0; + uint column = 0; _Columns.clear (); for (i=0; i<_Cells.size(); i++) { @@ -764,7 +764,7 @@ namespace NLGUI } // Resize the array - if (column>=_Columns.size()) + if (column >= _Columns.size()) _Columns.resize(column+1); // Handle rowspan from previous row @@ -773,7 +773,7 @@ namespace NLGUI _Columns[column].RowSpan--; column++; // if previous row had less elements, then we missing columns - if (column>=_Columns.size()) + if (column >= _Columns.size()) _Columns.resize(column+1); } @@ -783,13 +783,12 @@ namespace NLGUI // new column, set rowspan from current _Columns[column].RowSpan = cell->RowSpan; float colspan = 1.f / cell->ColSpan; - float rowspan = 1.f / cell->RowSpan; // Update sizes if (cellWidth*colspan > _Columns[column].Width) - _Columns[column].Width = cellWidth*colspan; + _Columns[column].Width = (sint32)(cellWidth*colspan); if (cell->WidthMax*colspan > _Columns[column].WidthMax) - _Columns[column].WidthMax = cell->WidthMax*colspan; + _Columns[column].WidthMax = (sint32)(cell->WidthMax*colspan); if (cell->TableRatio*colspan > _Columns[column].TableRatio) _Columns[column].TableRatio = cell->TableRatio*colspan; if (cell->WidthWanted*colspan + additionnalWidth > _Columns[column].WidthWanted) @@ -1035,7 +1034,7 @@ namespace NLGUI if (cell->TableColumnIndex > 0) { // we have active rowspan, must add up 'skipped' columns - for( ; columnTableColumnIndex; ++column) + for( ; column < (uint)cell->TableColumnIndex; ++column) currentX += _Columns[column].Width + padding*2 + CellSpacing; } @@ -1081,7 +1080,7 @@ namespace NLGUI cell->Group->updateCoords(); // Resize the row array - float rowspan = 1 / cell->RowSpan; + float rowspan = 1.f / (float)cell->RowSpan; _Rows.back().Height = std::max((sint32)(cell->Height*rowspan), std::max(_Rows.back().Height, (sint32)(cell->Group->getH()*rowspan))); // Next column diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index 54e28abf0..800c4d1e3 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -398,7 +398,7 @@ namespace NLGUI { time_t now; time(&now); - if (expires < now) + if (expires < (uint32)now) { nlwarning("cookie expired, remove from list '%s'", nsformat); HTTPCookies[domain].erase(chunks[5]); diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index cdbe3ec73..37a115965 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1722,8 +1722,8 @@ namespace NLGUI // *** First detect from which screen position the window is the more sticked (borders or center) // In X: best hotspot is left, middle or right? sint32 posXToLeft= x; - sint32 posXToMiddle= x+w/2-screenW/2; - sint32 posXToRight= screenW-(x+w); + sint32 posXToMiddle= x+w/2-_ScreenW/2; + sint32 posXToRight= _ScreenW-(x+w); sint32 bestXHotSpot= Hotspot_xL; sint32 bestXPosVal= posXToLeft; if(abs(posXToMiddle) < bestXPosVal) @@ -1740,8 +1740,8 @@ namespace NLGUI // Same In Y: best hotspot is bottom, middle or top? // remember here that y is the top of window (relative to bottom of screen) sint32 posYToBottom= y-h; - sint32 posYToMiddle= y-h/2-screenH/2; - sint32 posYToTop= screenH-y; + sint32 posYToMiddle= y-h/2-_ScreenH/2; + sint32 posYToTop= _ScreenH-y; sint32 bestYHotSpot= Hotspot_Bx; sint32 bestYPosVal= posYToBottom; const sint32 middleYWeight= 6; // Avoid default Mission/Team/Map/ContactList positions to be considered as "middle" @@ -1774,13 +1774,13 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - void CWidgetManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI) + void CWidgetManager::moveAllWindowsToNewScreenSize(uint32 newScreenW, uint32 newScreenH, bool fixCurrentUI) { std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = getAllMasterGroup(); // If resolutions correctly setuped, and really different from new setup - if( screenW >0 && screenH>0 && + if( _ScreenW >0 && _ScreenH>0 && newScreenW >0 && newScreenH>0 && - ( screenW != newScreenW || screenH != newScreenH) + ( _ScreenW != newScreenW || _ScreenH != newScreenH) ) { // *** Do it for the Active Desktop (if wanted) @@ -1790,13 +1790,13 @@ namespace NLGUI for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if(!rMG.Group || rMG.Group->getId()!="ui:interface") + if (!rMG.Group || rMG.Group->getId() != "ui:interface") continue; // For all priorities, but the worldspace one for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) { - if(nPriority==WIN_PRIORITY_WORLD_SPACE) + if (nPriority==WIN_PRIORITY_WORLD_SPACE) continue; // For All windows (only layer 0 group container) @@ -1842,8 +1842,8 @@ namespace NLGUI // Now those are the last screen coordinates used for window position correction if(newScreenW >0 && newScreenH>0) { - screenW = newScreenW; - screenH = newScreenH; + _ScreenW = newScreenW; + _ScreenH = newScreenH; } } @@ -1966,13 +1966,13 @@ namespace NLGUI uint32 w, h; CViewRenderer::getInstance()->checkNewScreenSize (); CViewRenderer::getInstance()->getScreenSize (w, h); - if ((w != screenW) || (h != screenH)) + if ((w != _ScreenW) || (h != _ScreenH)) { // No Op if screen minimized if(w!=0 && h!=0 && !CViewRenderer::getInstance()->isMinimized()) { updateAllLocalisedElements (); - setScreenWH( w, h ); + setScreenWH(w, h); } } @@ -2075,18 +2075,18 @@ namespace NLGUI } // Draw the pointer and DND Item - if( getPointer() != NULL) + if (getPointer() != NULL) { - if ( getPointer()->getActive()) + if (getPointer()->getActive()) getPointer()->draw (); } - if( CInterfaceElement::getEditorMode() ) + if (CInterfaceElement::getEditorMode()) { - for( int i = 0; i < editorSelection.size(); i++ ) + for(uint i = 0; i < editorSelection.size(); ++i) { - CInterfaceElement *e = getElementFromId( editorSelection[ i ] ); - if( e != NULL ) + CInterfaceElement *e = getElementFromId(editorSelection[i]); + if (e != NULL) e->drawHighlight(); } } @@ -3376,8 +3376,8 @@ namespace NLGUI void CWidgetManager::getEditorSelection( std::vector< std::string > &selection ) { selection.clear(); - for( int i = 0; i < editorSelection.size(); i++ ) - selection.push_back( editorSelection[ i ] ); + for(uint i = 0; i < editorSelection.size(); ++i) + selection.push_back(editorSelection[i]); } void CWidgetManager::selectWidget( const std::string &name ) @@ -3539,11 +3539,11 @@ namespace NLGUI std::vector< CInterfaceElement* > elms; // Resolve the widget names - for( int i = 0; i < editorSelection.size(); i++ ) + for(uint i = 0; i < editorSelection.size(); ++i) { - CInterfaceElement *e = getElementFromId( editorSelection[ i ] ); - if( e != NULL ) - elms.push_back( e ); + CInterfaceElement *e = getElementFromId(editorSelection[i]); + if (e != NULL) + elms.push_back(e); } editorSelection.clear(); @@ -3562,21 +3562,21 @@ namespace NLGUI std::string oldId; // Reparent the widgets to the new group - for( int i = 0; i < elms.size(); i++ ) + for(uint i = 0; i < elms.size(); ++i) { - CInterfaceElement *e = elms[ i ]; + CInterfaceElement *e = elms[i]; oldId = e->getId(); CInterfaceGroup *p = e->getParent(); - if( p != NULL ) - p->takeElement( e ); + if (p != NULL) + p->takeElement(e); - g->addElement( e ); - e->setParent( g ); - e->setParentPos( g ); - e->setParentSize( g ); - e->setIdRecurse( e->getShortId() ); + g->addElement(e); + e->setParent(g); + e->setParentPos(g); + e->setParentSize(g); + e->setIdRecurse(e->getShortId()); - onWidgetMoved( oldId, e->getId() ); + onWidgetMoved(oldId, e->getId()); } elms.clear(); @@ -3631,7 +3631,7 @@ namespace NLGUI { reset(); - for( int i = 0; i < _MasterGroups.size(); i++ ) + for(uint i = 0; i < _MasterGroups.size(); ++i) delete _MasterGroups[i].Group; _MasterGroups.clear(); @@ -3724,7 +3724,7 @@ namespace NLGUI _MouseOverWindow = false; inGame = false; - setScreenWH( 0, 0 ); + setScreenWH(0, 0); _GroupSelection = false; multiSelection = false; diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 74f75a968..30e8b652c 100644 --- a/code/nel/src/misc/bitmap_gif.cpp +++ b/code/nel/src/misc/bitmap_gif.cpp @@ -214,12 +214,13 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f ) dstOffset+= dstChannels; uint32 index = curFrame->RasterBits[srcOffset]; - if (index != transparency) + + if ((sint32)index != transparency) { // make sure color index is not outside colormap if (ColorMap) { - if (index > ColorMap->ColorCount) + if ((sint)index > ColorMap->ColorCount) { index = 0; } @@ -260,12 +261,13 @@ uint8 CBitmap::readGIF( NLMISC::IStream &f ) dstOffset+= dstChannels; uint32 index = curFrame->RasterBits[srcOffset]; - if (index != transparency) + + if ((sint32)index != transparency) { // make sure color index is not outside colormap if (ColorMap) { - if (index > ColorMap->ColorCount) + if ((sint)index > ColorMap->ColorCount) { index = 0; } diff --git a/code/nel/src/misc/system_utils.cpp b/code/nel/src/misc/system_utils.cpp index a350ab305..6c9b3ae01 100644 --- a/code/nel/src/misc/system_utils.cpp +++ b/code/nel/src/misc/system_utils.cpp @@ -32,6 +32,8 @@ # include # define TASKBAR_PROGRESS 1 # endif +#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC) +#include "nel/misc/file.h" #endif #ifdef DEBUG_NEW @@ -472,7 +474,7 @@ sint CSystemUtils::getTotalVideoMemory() { sint res = -1; -#ifdef NL_OS_WINDOWS +#if defined(NL_OS_WINDOWS) // using DXGI HINSTANCE hDXGI = LoadLibraryA("dxgi.dll"); @@ -596,8 +598,192 @@ sint CSystemUtils::getTotalVideoMemory() nlwarning("Unable to load ddraw.dll"); } } +#elif defined(NL_OS_MAC) + // the right method is using OpenGL #else - // TODO: implement for other systems + // under Linux, no method is really reliable... + NLMISC::CIFile file; + + std::string logFile = "/var/log/Xorg.0.log"; + + // parse last Xorg.0.log + if (file.open(logFile, true)) + { + char buffer[256]; + + while(!file.eof()) + { + file.getline(buffer, 256); + + if (buffer[0] == '\0') break; + + std::string line(buffer); + + // nvidia driver + std::string::size_type pos = line.find(") NVIDIA("); + + if (pos != std::string::npos) + { + // [ 20.883] (--) NVIDIA(0): Memory: 2097152 kBytes + pos = line.find("Memory: ", pos); + + // found memory line + if (pos == std::string::npos) continue; + pos += 8; + + std::string::size_type posUnits = line.find(" kBytes", pos); + + // found units in KiB + if (posUnits == std::string::npos) continue; + + std::string videoMemory = line.substr(pos, posUnits-pos); + + if (!NLMISC::fromString(videoMemory, res)) continue; + + nlinfo("Xorg NVIDIA driver reported %d KiB of video memory", res); + break; + } + + // intel driver + pos = line.find(") intel("); + + if (pos != std::string::npos) + { + // (**) intel(0): VideoRam: 131072 KB + pos = line.find("VideoRam: ", pos); + + // found memory line + if (pos == std::string::npos) continue; + pos += 10; + + std::string::size_type posUnits = line.find(" KB", pos); + + // found units in KiB + if (posUnits == std::string::npos) continue; + + std::string videoMemory = line.substr(pos, posUnits-pos); + + if (!NLMISC::fromString(videoMemory, res)) continue; + + nlinfo("Xorg Intel driver reported %d KiB of video memory", res); + break; + } + + // TODO: other drivers: nv, fglrx (ATI), radeon (ATI) + } + + file.close(); + } + + if (res == -1) + { + // use lspci + std::string command = "lspci"; + + std::string out = getCommandOutput(command); + + if (out.empty()) + { + nlwarning("Unable to launch %s", command.c_str()); + } + else + { + std::vector lines; + std::string deviceId; + + explode(out, std::string("\n"), lines, true); + + // process each line + for(uint i = 0; i < lines.size(); ++i) + { + std::string line = lines[i]; + + if (line.find("VGA") == std::string::npos && + line.find("3D") == std::string::npos && + line.find("2D") == std::string::npos) + continue; + + std::string::size_type pos = line.find(' '); + + if (pos == std::string::npos) continue; + + // found device ID + deviceId = line.substr(0, pos); + break; + } + + if (deviceId.empty()) + { + nlwarning("Unable to find a 3D device with lspci"); + } + else + { + command = "lspci -v -s " + deviceId; + + out = getCommandOutput(command); + + if (out.empty()) + { + nlwarning("Unable to launch %s", command.c_str()); + } + else + { + explode(out, std::string("\n"), lines, true); + + // process each line + for(uint i = 0; i < lines.size(); ++i) + { + std::string line = lines[i]; + + // look for a size + std::string::size_type pos0 = line.find("[size="); + if (pos0 == std::string::npos) continue; + + // move to first digit + pos0 += 6; + + // end of the size + std::string::size_type pos1 = line.find("]", pos0); + if (pos1 == std::string::npos) continue; + + sint units; + + if (line.substr(pos1-1, 1) == "M") + { + // size in MiB + units = 1024; + --pos1; + } + else if (line.substr(pos1-1, 1) == "K") + { + // size in KiB + units = 1; + --pos1; + } + else + { + // size in B + units = 0; + } + + // extract the size + std::string sizeStr = line.substr(pos0, pos1-pos0); + + // convert size to integer with right units + sint tmpSize; + if (!NLMISC::fromString(sizeStr, tmpSize)) continue; + + tmpSize *= units; + + // take the higher size (up to 256 MiB apparently) + if (tmpSize > res) res = tmpSize; + } + + nlinfo("lspci reported %d KiB of video memory", res); + } + } + } + } #endif return res; diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 152279a15..14f72a1b8 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -152,8 +152,10 @@ bool UseEscapeDuringLoading = USE_ESCAPE_DURING_LOADING; #define ENTITY_TEXTURE_NORMAL_LEVEL 1 #define ENTITY_TEXTURE_HIGH_LEVEL 0 // Size in MB of the cache for entity texturing. -#define ENTITY_TEXTURE_NORMAL_MEMORY 40 -#define ENTITY_TEXTURE_HIGH_MEMORY 160 +#define ENTITY_TEXTURE_LOW_MEMORY 10 // 64, 32 or less +#define ENTITY_TEXTURE_NORMAL_MEMORY 40 // 128 +#define ENTITY_TEXTURE_HIGH_MEMORY 80 // 256 +#define ENTITY_TEXTURE_VERY_HIGH_MEMORY 160 // 512 and more // Size in KB of max upload per frame #define ENTITY_TEXTURE_LOW_MAXUP 64 #define ENTITY_TEXTURE_NORMAL_MAXUP 128 @@ -884,33 +886,67 @@ void initMainLoop() // setup according to client if (ClientCfg.HDTextureInstalled) { - if(ClientCfg.HDEntityTexture) - { - // temporary code for debug - sint videoMemory = Driver->getTotalVideoMemory(); + sint videoMemory; + // only detect amount of video memory if using HD textures + if (ClientCfg.HDEntityTexture) + { + // determine video memory using 3D driver + videoMemory = Driver->getTotalVideoMemory(); + + // if unable to determine, use plaform methods if (videoMemory < 0) videoMemory = CSystemUtils::getTotalVideoMemory(); + // in the worst case, use default value of 128 MiB + if (videoMemory < 0) videoMemory = 128 * 1024; + 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) - Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_HIGH_MEMORY*1024*1024); - // Allow high upload - Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_HIGH_MAXUP*1024); + nlinfo("Video memory detected: %d MiB", videoMemory); } else { - // setup "v1 texture" (or 256*256) - Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL, ENTITY_TEXTURE_NORMAL_LEVEL); - // Allow a big cache for them - Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_NORMAL_MEMORY*1024*1024); - // Allow normal upload - Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_NORMAL_MAXUP*1024); + // 32 MiB of VRAM if DivideTextureSizeBy2 else 64 MiB + videoMemory = ClientCfg.DivideTextureSizeBy2 ? 32:64; } + + uint maxText, maxLevel, maxup; + + if (videoMemory > 256) + { + // 512 MB or higher + maxLevel = ENTITY_TEXTURE_HIGH_LEVEL; + maxText = ENTITY_TEXTURE_VERY_HIGH_MEMORY; + maxup = ENTITY_TEXTURE_HIGH_MAXUP; + } + else if (videoMemory > 128) + { + // 256 MB + maxLevel = ENTITY_TEXTURE_HIGH_LEVEL; + maxText = ENTITY_TEXTURE_HIGH_MEMORY; + maxup = ENTITY_TEXTURE_HIGH_MAXUP; + } + else if (videoMemory > 64) + { + // 128 MB + maxLevel = ENTITY_TEXTURE_NORMAL_LEVEL; + maxText = ENTITY_TEXTURE_NORMAL_MEMORY; + maxup = ENTITY_TEXTURE_HIGH_MAXUP; + } + else + { + // 64 MB or lower + maxLevel = ENTITY_TEXTURE_NORMAL_LEVEL; + maxText = ENTITY_TEXTURE_LOW_MEMORY; + maxup = ENTITY_TEXTURE_NORMAL_MAXUP; + } + + // setup "v2 texture" (or 512*512) or "v1 texture" (or 256*256) + Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL, maxLevel); + // Allow a big cache for them + Driver->setupMaxTotalAsyncTextureSize(maxText*1024*1024); + // Allow normal or high upload + Driver->setupAsyncTextureMaxUploadPerFrame(maxup*1024); } else { @@ -919,7 +955,7 @@ void initMainLoop() */ Driver->setupAsyncTextureLod(ENTITY_TEXTURE_COARSE_LEVEL-1, ENTITY_TEXTURE_NORMAL_LEVEL-1); // Allow a big cache for them - Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_NORMAL_MEMORY*1024*1024); + Driver->setupMaxTotalAsyncTextureSize(ENTITY_TEXTURE_LOW_MEMORY*1024*1024); // Allow low upload Driver->setupAsyncTextureMaxUploadPerFrame(ENTITY_TEXTURE_LOW_MAXUP*1024); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 2624aef77..44aeaa7d6 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -495,8 +495,8 @@ CInterfaceManager::CInterfaceManager() CViewRenderer::getInstance()->checkNewScreenSize(); { uint32 w,h; - CViewRenderer::getInstance()->getScreenSize( w, h ); - CWidgetManager::getInstance()->setScreenWH( w, h ); + CViewRenderer::getInstance()->getScreenSize(w, h); + CWidgetManager::getInstance()->setScreenWH(w, h); } CViewRenderer::getInstance()->init();