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 <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Chris Dalton 2017-10-08 20:01:26 -06:00 committed by Skia Commit-Bot
parent abff956455
commit 16e92cdd91

View File

@ -235,8 +235,9 @@ void GLInstancedRendering::onDraw(const GrPipeline& pipeline, const InstanceProc
SkASSERT(fDrawIndirectBuffer); SkASSERT(fDrawIndirectBuffer);
int glCmdsIdx = op->fGLDrawCmdsIdx; int glCmdsIdx = op->fGLDrawCmdsIdx;
this->flushInstanceAttribs(op->fEmulatedBaseInstance); this->flushInstanceAttribs(op->fEmulatedBaseInstance);
uintptr_t glCmdsOffset = glCmdsIdx * sizeof(GrGLDrawElementsIndirectCommand);
GL_CALL(MultiDrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, GL_CALL(MultiDrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE,
(GrGLDrawElementsIndirectCommand*) nullptr + glCmdsIdx, reinterpret_cast<const void*>(glCmdsOffset),
numCommands, 0)); numCommands, 0));
return; return;
} }
@ -246,13 +247,14 @@ void GLInstancedRendering::onDraw(const GrPipeline& pipeline, const InstanceProc
int glCmdIdx = op->fGLDrawCmdsIdx + i; int glCmdIdx = op->fGLDrawCmdsIdx + i;
this->flushInstanceAttribs(emulatedBaseInstance); this->flushInstanceAttribs(emulatedBaseInstance);
if (fDrawIndirectBuffer) { if (fDrawIndirectBuffer) {
uintptr_t glCmdOffset = glCmdIdx * sizeof(GrGLDrawElementsIndirectCommand);
GL_CALL(DrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, GL_CALL(DrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE,
(GrGLDrawElementsIndirectCommand*) nullptr + glCmdIdx)); reinterpret_cast<const void*>(glCmdOffset)));
} else { } else {
const GLDrawCmdInfo& cmdInfo = fGLDrawCmdsInfo[glCmdIdx]; const GLDrawCmdInfo& cmdInfo = fGLDrawCmdsInfo[glCmdIdx];
GL_CALL(DrawElementsInstanced(GR_GL_TRIANGLES, cmdInfo.fGeometry.fCount, GL_CALL(DrawElementsInstanced(GR_GL_TRIANGLES, cmdInfo.fGeometry.fCount,
GR_GL_UNSIGNED_BYTE, GR_GL_UNSIGNED_BYTE,
(GrGLubyte*) nullptr + cmdInfo.fGeometry.fStart, reinterpret_cast<const void*>(cmdInfo.fGeometry.fStart),
cmdInfo.fInstanceCount)); cmdInfo.fInstanceCount));
} }
if (!glCaps.baseInstanceSupport()) { if (!glCaps.baseInstanceSupport()) {
@ -269,36 +271,37 @@ void GLInstancedRendering::flushInstanceAttribs(int baseInstance) {
SkASSERT(fInstanceBuffer); SkASSERT(fInstanceBuffer);
if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() || if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() ||
fInstanceAttribsBaseInstance != baseInstance) { fInstanceAttribsBaseInstance != baseInstance) {
Instance* offsetInBuffer = (Instance*) nullptr + baseInstance; uintptr_t offsetInBuffer = baseInstance * sizeof(Instance);
const Instance* offsetAsPtr = reinterpret_cast<const Instance*>(offsetInBuffer);
this->glGpu()->bindBuffer(kVertex_GrBufferType, fInstanceBuffer.get()); this->glGpu()->bindBuffer(kVertex_GrBufferType, fInstanceBuffer.get());
// Info attrib. // Info attrib.
GL_CALL(EnableVertexAttribArray((int)Attrib::kInstanceInfo)); GL_CALL(EnableVertexAttribArray((int)Attrib::kInstanceInfo));
GL_CALL(VertexAttribIPointer((int)Attrib::kInstanceInfo, 1, GR_GL_UNSIGNED_INT, 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)); GL_CALL(VertexAttribDivisor((int)Attrib::kInstanceInfo, 1));
// Shape matrix attrib. // Shape matrix attrib.
GL_CALL(EnableVertexAttribArray((int)Attrib::kShapeMatrixX)); GL_CALL(EnableVertexAttribArray((int)Attrib::kShapeMatrixX));
GL_CALL(EnableVertexAttribArray((int)Attrib::kShapeMatrixY)); GL_CALL(EnableVertexAttribArray((int)Attrib::kShapeMatrixY));
GL_CALL(VertexAttribPointer((int)Attrib::kShapeMatrixX, 3, GR_GL_FLOAT, GR_GL_FALSE, 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, 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::kShapeMatrixX, 1));
GL_CALL(VertexAttribDivisor((int)Attrib::kShapeMatrixY, 1)); GL_CALL(VertexAttribDivisor((int)Attrib::kShapeMatrixY, 1));
// Color attrib. // Color attrib.
GL_CALL(EnableVertexAttribArray((int)Attrib::kColor)); GL_CALL(EnableVertexAttribArray((int)Attrib::kColor));
GL_CALL(VertexAttribPointer((int)Attrib::kColor, 4, GR_GL_UNSIGNED_BYTE, GR_GL_TRUE, 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)); GL_CALL(VertexAttribDivisor((int)Attrib::kColor, 1));
// Local rect attrib. // Local rect attrib.
GL_CALL(EnableVertexAttribArray((int)Attrib::kLocalRect)); GL_CALL(EnableVertexAttribArray((int)Attrib::kLocalRect));
GL_CALL(VertexAttribPointer((int)Attrib::kLocalRect, 4, GR_GL_FLOAT, GR_GL_FALSE, 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)); GL_CALL(VertexAttribDivisor((int)Attrib::kLocalRect, 1));
fInstanceAttribsBufferUniqueId = fInstanceBuffer->uniqueID(); fInstanceAttribsBufferUniqueId = fInstanceBuffer->uniqueID();