summaryrefslogtreecommitdiff
path: root/indra/llrender/llvertexbuffer.cpp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-03-07 11:27:43 -0800
committerRider Linden <rider@lindenlab.com>2018-03-07 11:27:43 -0800
commit7b56db31f91545102744885b4f70c93278e837bd (patch)
tree97bd880e3aeb1f60d667344e6693b46c8ba120eb /indra/llrender/llvertexbuffer.cpp
parent4235231b5adbb7f064cab732f761dd359ef4b648 (diff)
parentf8c76535a35aaf245e261357a59e977bac5b2501 (diff)
Merge
Diffstat (limited to 'indra/llrender/llvertexbuffer.cpp')
-rw-r--r--indra/llrender/llvertexbuffer.cpp38
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();
}