summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorJonathan Yap <jhwelch@gmail.com>2018-01-12 09:08:49 -0500
committerJonathan Yap <jhwelch@gmail.com>2018-01-12 09:08:49 -0500
commit1e586749efeeb8c40503330572680a8709ae5487 (patch)
tree5c1ebee5dbdb5004f354b9fb0837d60f6dd3cfcc /indra/llrender
parent32f16633c77564d567ed0752e56eb38abb916ccd (diff)
parent1693ccba58eef676df1f91e50627545ac35bb819 (diff)
STORM-2145 Merge up to viewer-release
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llgl.cpp2
-rw-r--r--indra/llrender/llgl.h2
-rw-r--r--indra/llrender/llimagegl.cpp6
-rw-r--r--indra/llrender/llrender.cpp11
-rw-r--r--indra/llrender/llvertexbuffer.cpp81
-rw-r--r--indra/llrender/llvertexbuffer.h12
6 files changed, 83 insertions, 31 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 7757198af5..1847c661d7 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -65,7 +65,7 @@ static const std::string HEADLESS_VENDOR_STRING("Linden Lab");
static const std::string HEADLESS_RENDERER_STRING("Headless");
static const std::string HEADLESS_VERSION_STRING("1.0");
-std::ofstream gFailLog;
+llofstream gFailLog;
#if GL_ARB_debug_output
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 75e5fe86ec..aa98b3f6bc 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -47,7 +47,7 @@
extern BOOL gDebugGL;
extern BOOL gDebugSession;
-extern std::ofstream gFailLog;
+extern llofstream gFailLog;
#define LL_GL_ERRS LL_ERRS("RenderState")
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 81a5537f78..20cba68f84 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1267,6 +1267,12 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
llassert(gGLManager.mInited);
stop_glerror();
+ if (!imageraw || imageraw->isBufferInvalid())
+ {
+ LL_WARNS() << "Trying to create a texture from invalid image data" << LL_ENDL;
+ return FALSE;
+ }
+
if (discard_level < 0)
{
llassert(mCurrentDiscardLevel >= 0);
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 69420dd0bb..3e7c69611d 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -267,7 +267,14 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)
}
else
{
- LL_WARNS() << "NULL LLTexUnit::bind texture" << LL_ENDL;
+ if (texture)
+ {
+ LL_DEBUGS() << "NULL LLTexUnit::bind GL image" << LL_ENDL;
+ }
+ else
+ {
+ LL_DEBUGS() << "NULL LLTexUnit::bind texture" << LL_ENDL;
+ }
return false;
}
}
@@ -286,7 +293,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind)
if(!texture)
{
- LL_WARNS() << "NULL LLTexUnit::bind texture" << LL_ENDL;
+ LL_DEBUGS() << "NULL LLTexUnit::bind texture" << LL_ENDL;
return false;
}
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 0fae600a90..0b4427a31a 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -448,7 +448,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
else
{
- GLenum array[] =
+ static const GLenum array[] =
{
GL_VERTEX_ARRAY,
GL_NORMAL_ARRAY,
@@ -456,7 +456,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
GL_COLOR_ARRAY,
};
- GLenum mask[] =
+ static const GLenum mask[] =
{
MAP_VERTEX,
MAP_NORMAL,
@@ -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,11 +1247,17 @@ void LLVertexBuffer::createGLIndices(U32 size)
mGLIndices = ++gl_buffer_idx;
mIndicesSize = size;
}
+
+ if (!mMappedIndexData)
+ {
+ sucsess = false;
+ }
+ return sucsess;
}
void LLVertexBuffer::destroyGLBuffer()
{
- if (mGLBuffer)
+ if (mGLBuffer || mMappedData)
{
if (mMappedDataUsingVBOs)
{
@@ -1254,7 +1277,7 @@ void LLVertexBuffer::destroyGLBuffer()
void LLVertexBuffer::destroyGLIndices()
{
- if (mGLIndices)
+ if (mGLIndices || mMappedIndexData)
{
if (mMappedIndexDataUsingVBOs)
{
@@ -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");
@@ -1457,23 +1492,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
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index c05fd01595..bd27296eb6 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -214,12 +214,12 @@ protected:
bool bindGLArray();
void releaseBuffer();
void releaseIndices();
- void createGLBuffer(U32 size);
- void createGLIndices(U32 size);
+ bool createGLBuffer(U32 size);
+ bool createGLIndices(U32 size);
void destroyGLBuffer();
void destroyGLIndices();
- void updateNumVerts(S32 nverts);
- void updateNumIndices(S32 nindices);
+ bool updateNumVerts(S32 nverts);
+ bool updateNumIndices(S32 nindices);
void unmapBuffer();
public:
@@ -235,8 +235,8 @@ public:
virtual void setBuffer(U32 data_mask); // calls setupVertexBuffer() if data_mask is not 0
void flush(); //flush pending data to GL memory
// allocate buffer
- void allocateBuffer(S32 nverts, S32 nindices, bool create);
- virtual void resizeBuffer(S32 newnverts, S32 newnindices);
+ bool allocateBuffer(S32 nverts, S32 nindices, bool create);
+ virtual bool resizeBuffer(S32 newnverts, S32 newnindices);
// Only call each getVertexPointer, etc, once before calling unmapBuffer()
// call unmapBuffer() after calls to getXXXStrider() before any cals to setBuffer()