b=570538; [webgl] fix up buffer validation with interleaved data; r=bjacob

This commit is contained in:
Vladimir Vukicevic
2010-06-08 15:14:43 -07:00
parent 00f1a6bbd2
commit 833cd1cfdd
6 changed files with 179 additions and 51 deletions

View File

@@ -51,6 +51,8 @@ WebGLContext::ValidateBuffers(PRUint32 count)
GLint currentProgram = -1;
GLint numAttributes = -1;
NS_ENSURE_TRUE(count > 0, PR_TRUE);
MakeContextCurrent();
// XXX cache this per program
@@ -93,7 +95,10 @@ WebGLContext::ValidateBuffers(PRUint32 count)
return PR_FALSE;
}
WebGLuint needed = vd.byteOffset + vd.actualStride() * count;
WebGLuint needed = vd.byteOffset + // the base offset
vd.actualStride() * (count-1) + // to stride to the start of the last element group
vd.componentSize() * vd.size; // and the number of bytes needed for these components
if (vd.buf->ByteLength() < needed) {
LogMessage("VBO too small for bound attrib index %d: need at least %d bytes, but have only %d", i, needed, vd.buf->ByteLength());
return PR_FALSE;