From 16e92cdd91bd46e2909465a7509960a3ca2eeeb6 Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Sun, 8 Oct 2017 20:01:26 -0600 Subject: [PATCH] Fix new compiler warnings in GLInstancedRendering.cpp Bug: skia:7109 Change-Id: I6d42991d4aba611819260411aaebd508ff242d09 Reviewed-on: https://skia-review.googlesource.com/56921 Reviewed-by: Ben Wagner Commit-Queue: Ben Wagner --- src/gpu/instanced/GLInstancedRendering.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gpu/instanced/GLInstancedRendering.cpp b/src/gpu/instanced/GLInstancedRendering.cpp index b2eb9ebb7a..df51cd827c 100644 --- a/src/gpu/instanced/GLInstancedRendering.cpp +++ b/src/gpu/instanced/GLInstancedRendering.cpp @@ -235,8 +235,9 @@ void GLInstancedRendering::onDraw(const GrPipeline& pipeline, const InstanceProc SkASSERT(fDrawIndirectBuffer); int glCmdsIdx = op->fGLDrawCmdsIdx; this->flushInstanceAttribs(op->fEmulatedBaseInstance); + uintptr_t glCmdsOffset = glCmdsIdx * sizeof(GrGLDrawElementsIndirectCommand); GL_CALL(MultiDrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, - (GrGLDrawElementsIndirectCommand*) nullptr + glCmdsIdx, + reinterpret_cast(glCmdsOffset), numCommands, 0)); return; } @@ -246,13 +247,14 @@ void GLInstancedRendering::onDraw(const GrPipeline& pipeline, const InstanceProc int glCmdIdx = op->fGLDrawCmdsIdx + i; this->flushInstanceAttribs(emulatedBaseInstance); if (fDrawIndirectBuffer) { + uintptr_t glCmdOffset = glCmdIdx * sizeof(GrGLDrawElementsIndirectCommand); GL_CALL(DrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, - (GrGLDrawElementsIndirectCommand*) nullptr + glCmdIdx)); + reinterpret_cast(glCmdOffset))); } else { const GLDrawCmdInfo& cmdInfo = fGLDrawCmdsInfo[glCmdIdx]; GL_CALL(DrawElementsInstanced(GR_GL_TRIANGLES, cmdInfo.fGeometry.fCount, GR_GL_UNSIGNED_BYTE, - (GrGLubyte*) nullptr + cmdInfo.fGeometry.fStart, + reinterpret_cast(cmdInfo.fGeometry.fStart), cmdInfo.fInstanceCount)); } if (!glCaps.baseInstanceSupport()) { @@ -269,36 +271,37 @@ void GLInstancedRendering::flushInstanceAttribs(int baseInstance) { SkASSERT(fInstanceBuffer); if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() || fInstanceAttribsBaseInstance != baseInstance) { - Instance* offsetInBuffer = (Instance*) nullptr + baseInstance; + uintptr_t offsetInBuffer = baseInstance * sizeof(Instance); + const Instance* offsetAsPtr = reinterpret_cast(offsetInBuffer); this->glGpu()->bindBuffer(kVertex_GrBufferType, fInstanceBuffer.get()); // Info attrib. GL_CALL(EnableVertexAttribArray((int)Attrib::kInstanceInfo)); GL_CALL(VertexAttribIPointer((int)Attrib::kInstanceInfo, 1, GR_GL_UNSIGNED_INT, - sizeof(Instance), &offsetInBuffer->fInfo)); + sizeof(Instance), &offsetAsPtr->fInfo)); GL_CALL(VertexAttribDivisor((int)Attrib::kInstanceInfo, 1)); // Shape matrix attrib. GL_CALL(EnableVertexAttribArray((int)Attrib::kShapeMatrixX)); GL_CALL(EnableVertexAttribArray((int)Attrib::kShapeMatrixY)); GL_CALL(VertexAttribPointer((int)Attrib::kShapeMatrixX, 3, GR_GL_FLOAT, GR_GL_FALSE, - sizeof(Instance), &offsetInBuffer->fShapeMatrix2x3[0])); + sizeof(Instance), &offsetAsPtr->fShapeMatrix2x3[0])); GL_CALL(VertexAttribPointer((int)Attrib::kShapeMatrixY, 3, GR_GL_FLOAT, GR_GL_FALSE, - sizeof(Instance), &offsetInBuffer->fShapeMatrix2x3[3])); + sizeof(Instance), &offsetAsPtr->fShapeMatrix2x3[3])); GL_CALL(VertexAttribDivisor((int)Attrib::kShapeMatrixX, 1)); GL_CALL(VertexAttribDivisor((int)Attrib::kShapeMatrixY, 1)); // Color attrib. GL_CALL(EnableVertexAttribArray((int)Attrib::kColor)); GL_CALL(VertexAttribPointer((int)Attrib::kColor, 4, GR_GL_UNSIGNED_BYTE, GR_GL_TRUE, - sizeof(Instance), &offsetInBuffer->fColor)); + sizeof(Instance), &offsetAsPtr->fColor)); GL_CALL(VertexAttribDivisor((int)Attrib::kColor, 1)); // Local rect attrib. GL_CALL(EnableVertexAttribArray((int)Attrib::kLocalRect)); GL_CALL(VertexAttribPointer((int)Attrib::kLocalRect, 4, GR_GL_FLOAT, GR_GL_FALSE, - sizeof(Instance), &offsetInBuffer->fLocalRect)); + sizeof(Instance), &offsetAsPtr->fLocalRect)); GL_CALL(VertexAttribDivisor((int)Attrib::kLocalRect, 1)); fInstanceAttribsBufferUniqueId = fInstanceBuffer->uniqueID();