diff options
| author | Ankur Ahlawat <anchor@lindenlab.com> | 2018-03-07 10:00:07 -0800 |
|---|---|---|
| committer | Ankur Ahlawat <anchor@lindenlab.com> | 2018-03-07 10:00:07 -0800 |
| commit | ac558e384214e22b4a8da2045854e2180b7428bf (patch) | |
| tree | 7de576ff5552cbb9956c6cdf0e4d84b52514316e /indra/llrender/llvertexbuffer.cpp | |
| parent | 485193c7f530fa3d8574c74304e452ab6d012e41 (diff) | |
| parent | f8c76535a35aaf245e261357a59e977bac5b2501 (diff) | |
Merged lindenlab/viewer-release into default
Diffstat (limited to 'indra/llrender/llvertexbuffer.cpp')
| -rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 5048799854..f10301b42d 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1057,10 +1057,12 @@ LLVertexBuffer::~LLVertexBuffer() if (mFence) { + // Sanity check. We have weird crashes in this destructor (on delete). Yet mFence is disabled. + // TODO: mFence was added in scope of SH-2038, but was never enabled, consider removing mFence. + LL_ERRS() << "LLVertexBuffer destruction failed" << LL_ENDL; delete mFence; + mFence = NULL; } - - mFence = NULL; sVertexCount -= mNumVerts; sIndexCount -= mNumIndices; @@ -1930,7 +1932,21 @@ void LLVertexBuffer::unmapBuffer() const MappedRegion& region = mMappedVertexRegions[i]; S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0; S32 length = sTypeSize[region.mType]*region.mCount; - glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedData+offset); + if (mSize >= length + offset) + { + glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, (U8*)mMappedData + offset); + } + else + { + GLint size = 0; + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + LL_WARNS() << "Attempted to map regions to a buffer that is too small, " + << "mapped size: " << mSize + << ", gl buffer size: " << size + << ", length: " << length + << ", offset: " << offset + << LL_ENDL; + } stop_glerror(); } @@ -1998,7 +2014,21 @@ void LLVertexBuffer::unmapBuffer() const MappedRegion& region = mMappedIndexRegions[i]; S32 offset = region.mIndex >= 0 ? sizeof(U16)*region.mIndex : 0; S32 length = sizeof(U16)*region.mCount; - glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedIndexData+offset); + if (mIndicesSize >= length + offset) + { + glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedIndexData+offset); + } + else + { + GLint size = 0; + glGetBufferParameterivARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + LL_WARNS() << "Attempted to map regions to a buffer that is too small, " + << "mapped size: " << mIndicesSize + << ", gl buffer size: " << size + << ", length: " << length + << ", offset: " << offset + << LL_ENDL; + } stop_glerror(); } |
