diff options
author | callum_linden <callum@lindenlab.com> | 2017-11-30 14:44:44 -0800 |
---|---|---|
committer | callum_linden <callum@lindenlab.com> | 2017-11-30 14:44:44 -0800 |
commit | dd0d2805e2b495246525f49325c4492b7b57f157 (patch) | |
tree | 96ae78468bbe760c4934416764a4cd89cf5ae381 /indra/llrender/llvertexbuffer.cpp | |
parent | 2e3c5ac88a434ee437bc3e68b321d5bd0bcd7cc9 (diff) | |
parent | e3a2c5e3217ae74a0277f2e6d4e1e708fe398a1c (diff) |
Automated erge with tip of viewer64
Diffstat (limited to 'indra/llrender/llvertexbuffer.cpp')
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 420cd2d9c4..5048799854 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1065,7 +1065,14 @@ LLVertexBuffer::~LLVertexBuffer() sVertexCount -= mNumVerts; sIndexCount -= mNumIndices; - llassert_always(!mMappedData && !mMappedIndexData); + if (mMappedData) + { + LL_ERRS() << "Failed to clear vertex buffer's vertices" << LL_ENDL; + } + if (mMappedIndexData) + { + LL_ERRS() << "Failed to clear vertex buffer's indices" << LL_ENDL; + } }; void LLVertexBuffer::placeFence() const @@ -1167,7 +1174,7 @@ void LLVertexBuffer::releaseIndices() sGLCount--; } -void LLVertexBuffer::createGLBuffer(U32 size) +bool LLVertexBuffer::createGLBuffer(U32 size) { if (mGLBuffer) { @@ -1176,9 +1183,11 @@ void LLVertexBuffer::createGLBuffer(U32 size) if (size == 0) { - return; + return true; } + bool sucsess = true; + mEmpty = true; mMappedDataUsingVBOs = useVBOs(); @@ -1196,9 +1205,15 @@ void LLVertexBuffer::createGLBuffer(U32 size) mSize = size; claimMem(mSize); } + + if (!mMappedData) + { + sucsess = false; + } + return sucsess; } -void LLVertexBuffer::createGLIndices(U32 size) +bool LLVertexBuffer::createGLIndices(U32 size) { if (mGLIndices) { @@ -1207,9 +1222,11 @@ void LLVertexBuffer::createGLIndices(U32 size) if (size == 0) { - return; + return true; } + bool sucsess = true; + mEmpty = true; //pad by 16 bytes for aligned copies @@ -1230,6 +1247,12 @@ void LLVertexBuffer::createGLIndices(U32 size) mGLIndices = ++gl_buffer_idx; mIndicesSize = size; } + + if (!mMappedIndexData) + { + sucsess = false; + } + return sucsess; } void LLVertexBuffer::destroyGLBuffer() @@ -1272,10 +1295,12 @@ void LLVertexBuffer::destroyGLIndices() //unbind(); } -void LLVertexBuffer::updateNumVerts(S32 nverts) +bool LLVertexBuffer::updateNumVerts(S32 nverts) { llassert(nverts >= 0); + bool sucsess = true; + if (nverts > 65536) { LL_WARNS() << "Vertex buffer overflow!" << LL_ENDL; @@ -1286,31 +1311,37 @@ void LLVertexBuffer::updateNumVerts(S32 nverts) if (needed_size > mSize || needed_size <= mSize/2) { - createGLBuffer(needed_size); + sucsess &= createGLBuffer(needed_size); } sVertexCount -= mNumVerts; mNumVerts = nverts; sVertexCount += mNumVerts; + + return sucsess; } -void LLVertexBuffer::updateNumIndices(S32 nindices) +bool LLVertexBuffer::updateNumIndices(S32 nindices) { llassert(nindices >= 0); + bool sucsess = true; + U32 needed_size = sizeof(U16) * nindices; if (needed_size > mIndicesSize || needed_size <= mIndicesSize/2) { - createGLIndices(needed_size); + sucsess &= createGLIndices(needed_size); } sIndexCount -= mNumIndices; mNumIndices = nindices; sIndexCount += mNumIndices; + + return sucsess; } -void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) +bool LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) { stop_glerror(); @@ -1320,13 +1351,15 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) LL_ERRS() << "Bad vertex buffer allocation: " << nverts << " : " << nindices << LL_ENDL; } - updateNumVerts(nverts); - updateNumIndices(nindices); + bool sucsess = true; + + sucsess &= updateNumVerts(nverts); + sucsess &= updateNumIndices(nindices); if (create && (nverts || nindices)) { //actually allocate space for the vertex buffer if using VBO mapping - flush(); + flush(); //unmap if (gGLManager.mHasVertexArrayObject && useVBOs() && sUseVAO) { @@ -1336,6 +1369,8 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) setupVertexArray(); } } + + return sucsess; } static LLTrace::BlockTimerStatHandle FTM_SETUP_VERTEX_ARRAY("Setup VAO"); @@ -1466,23 +1501,27 @@ void LLVertexBuffer::setupVertexArray() unbind(); } -void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) +bool LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) { llassert(newnverts >= 0); llassert(newnindices >= 0); - updateNumVerts(newnverts); - updateNumIndices(newnindices); + bool sucsess = true; + + sucsess &= updateNumVerts(newnverts); + sucsess &= updateNumIndices(newnindices); if (useVBOs()) { - flush(); + flush(); //unmap if (mGLArray) { //if size changed, offsets changed setupVertexArray(); } } + + return sucsess; } bool LLVertexBuffer::useVBOs() const |