Make VBO optimization partially optional

Yuck, there is a vertexbuffer being built on static init -.-
This commit is contained in:
Siana Gearz
2010-12-30 23:47:42 +01:00
parent 5fd5049e9b
commit 5f7840a997
4 changed files with 25 additions and 8 deletions

View File

@@ -41,6 +41,8 @@
#include "llmemtype.h"
#include "llrender.h"
#include "llcontrol.h"
//============================================================================
//static
@@ -63,6 +65,7 @@ BOOL LLVertexBuffer::sIBOActive = FALSE;
U32 LLVertexBuffer::sAllocatedBytes = 0;
BOOL LLVertexBuffer::sMapped = FALSE;
BOOL LLVertexBuffer::sUseStreamDraw = TRUE;
BOOL LLVertexBuffer::sOmitBlank = FALSE;
std::vector<U32> LLVertexBuffer::sDeleteList;
@@ -491,7 +494,7 @@ void LLVertexBuffer::createGLBuffer()
static int gl_buffer_idx = 0;
mGLBuffer = ++gl_buffer_idx;
mMappedData = new U8[size];
//memset(mMappedData, 0, size);
if(!sOmitBlank) memset((void*)mMappedData, 0, size);
}
}
@@ -521,7 +524,7 @@ void LLVertexBuffer::createGLIndices()
else
{
mMappedIndexData = new U8[size];
//memset(mMappedIndexData, 0, size);
if(!sOmitBlank) memset((void*)mMappedIndexData, 0, size);
static int gl_buffer_idx = 0;
mGLIndices = ++gl_buffer_idx;
}
@@ -697,16 +700,16 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
if (old)
{
memcpy((void*)mMappedData, (void*)old, llmin(newsize, oldsize));
if (newsize > oldsize)
if ((newsize > oldsize) && !sOmitBlank)
{
//memset(mMappedData+oldsize, 0, newsize-oldsize);
memset((void*)(mMappedData+oldsize), 0, newsize-oldsize);
}
delete [] old;
}
else
{
//memset(mMappedData, 0, newsize);
if (!sOmitBlank) memset((void*)mMappedData, 0, newsize);
mEmpty = TRUE;
}
}
@@ -735,15 +738,15 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
if (old)
{
memcpy((void*)mMappedIndexData, (void*)old, llmin(new_index_size, old_index_size));
if (new_index_size > old_index_size)
if ((new_index_size > old_index_size) && !sOmitBlank)
{
//memset(mMappedIndexData+old_index_size, 0, new_index_size - old_index_size);
memset((void*)(mMappedIndexData+old_index_size), 0, new_index_size - old_index_size);
}
delete [] old;
}
else
{
//memset(mMappedIndexData, 0, new_index_size);
if (!sOmitBlank) memset((void*)mMappedIndexData, 0, new_index_size);
mEmpty = TRUE;
}
}

View File

@@ -86,6 +86,7 @@ public:
static LLVBOPool sDynamicIBOPool;
static BOOL sUseStreamDraw;
static BOOL sOmitBlank;
static void initClass(bool use_vbo);
static void cleanupClass();

View File

@@ -3,6 +3,17 @@
<map>
<!-- Ascent-Specific Settings -->
<key>SianaRenderOmitBlankVBO</key>
<map>
<key>Comment</key>
<string>Optimization: omit prefilling VBOs with zeroes. Default: OFF</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>SianaUnsitOnCamReset</key>
<map>
<key>Comment</key>

View File

@@ -334,6 +334,7 @@ void LLPipeline::init()
sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("ShyotlRenderUseStreamVBO");
LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("SianaRenderOmitBlankVBO");
sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
@@ -4892,6 +4893,7 @@ void LLPipeline::resetVertexBuffers()
{
sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("ShyotlRenderUseStreamVBO");
LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("SianaRenderOmitBlankVBO");
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{