fixed #18538: TrianglesCommand hashing technique doesn't take padding into account (#18543)

* fixed #18538: TrianglesCommand hashing technique doesn't take padding into account

* sizeof fix
This commit is contained in:
James Chen 2017-12-08 16:05:58 +08:00 committed by minggo
parent 2d9fc6703c
commit f77f724caa
1 changed files with 6 additions and 1 deletions

View File

@ -94,12 +94,17 @@ void TrianglesCommand::generateMaterialID()
// if they don't have the same glProgramState, they might still have the same
// uniforms/values and glProgram, but it would be too expensive to check the uniforms.
struct {
void* glProgramState;
GLuint textureId;
GLenum blendSrc;
GLenum blendDst;
void* glProgramState;
} hashMe;
// NOTE: Initialize hashMe struct to make the value of padding bytes be filled with zero.
// It's important since XXH32 below will also consider the padding bytes which probably
// are set to random values by different compilers.
memset(&hashMe, 0, sizeof(hashMe));
hashMe.textureId = _textureID;
hashMe.blendSrc = _blendType.src;
hashMe.blendDst = _blendType.dst;