summaryrefslogtreecommitdiff
path: root/indra/llrender/llvertexbuffer.cpp
diff options
context:
space:
mode:
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();
}