diff options
author | Dave Parks <davep@lindenlab.com> | 2011-11-18 15:04:26 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-11-18 15:04:26 -0600 |
commit | 5c690db63ff118b6bc66fe1607624a59f4162b30 (patch) | |
tree | 1e0222d2d162301194f6a02a1e0976cf969d5e36 /indra/llrender | |
parent | 50112c163a1d7fcea4bd3be815d6eddd7d44364e (diff) |
SH-2700 Fix for random black textures due to texture index out of bounds. Also change shader to show bright pink on index out of bounds and add assertions to help prevent this sort of bug in the future.
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 4 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 19 |
2 files changed, 21 insertions, 2 deletions
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 75c584daab..eea768a3ea 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -695,7 +695,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } text[count++] = strdup("\t}\n"); - text[count++] = strdup("\treturn vec4(0,0,0,0);\n"); + text[count++] = strdup("\treturn vec4(1,0,1,1);\n"); text[count++] = strdup("}\n"); } else @@ -718,7 +718,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade text[count++] = strdup(if_str.c_str()); } - text[count++] = strdup("\treturn vec4(0,0,0,0);\n"); + text[count++] = strdup("\treturn vec4(1,0,1,1);\n"); text[count++] = strdup("}\n"); } } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b426421f88..3948145580 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -511,6 +511,25 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of llerrs << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << llendl; } } + + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + + if (shader && shader->mFeatures.mIndexedTextureChannels > 1) + { + LLStrider<LLVector4a> v; + //hack to get non-const reference + LLVertexBuffer* vb = (LLVertexBuffer*) this; + vb->getVertexStrider(v); + + for (U32 i = start; i < end; i++) + { + S32 idx = (S32) (v[i][3]+0.25f); + if (idx < 0 || idx >= shader->mFeatures.mIndexedTextureChannels) + { + llerrs << "Bad texture index found in vertex data stream." << llendl; + } + } + } } } |