OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GLInstancedRendering.h" | 8 #include "GLInstancedRendering.h" |
9 | 9 |
10 #include "GrResourceProvider.h" | 10 #include "GrResourceProvider.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 this->flushInstanceAttribs(batch->fEmulatedBaseInstance); | 235 this->flushInstanceAttribs(batch->fEmulatedBaseInstance); |
236 GL_CALL(MultiDrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, | 236 GL_CALL(MultiDrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, |
237 (GrGLDrawElementsIndirectCommand*) nul lptr + glCmdsIdx, | 237 (GrGLDrawElementsIndirectCommand*) nul lptr + glCmdsIdx, |
238 numCommands, 0)); | 238 numCommands, 0)); |
239 return; | 239 return; |
240 } | 240 } |
241 | 241 |
242 int emulatedBaseInstance = batch->fEmulatedBaseInstance; | 242 int emulatedBaseInstance = batch->fEmulatedBaseInstance; |
243 for (int i = 0; i < numCommands; ++i) { | 243 for (int i = 0; i < numCommands; ++i) { |
244 int glCmdIdx = batch->fGLDrawCmdsIdx + i; | 244 int glCmdIdx = batch->fGLDrawCmdsIdx + i; |
245 const GLDrawCmdInfo& cmdInfo = fGLDrawCmdsInfo[glCmdIdx]; | |
246 this->flushInstanceAttribs(emulatedBaseInstance); | 245 this->flushInstanceAttribs(emulatedBaseInstance); |
247 if (fDrawIndirectBuffer) { | 246 if (fDrawIndirectBuffer) { |
248 GL_CALL(DrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, | 247 GL_CALL(DrawElementsIndirect(GR_GL_TRIANGLES, GR_GL_UNSIGNED_BYTE, |
249 (GrGLDrawElementsIndirectCommand*) null ptr + glCmdIdx)); | 248 (GrGLDrawElementsIndirectCommand*) null ptr + glCmdIdx)); |
250 } else { | 249 } else { |
250 const GLDrawCmdInfo& cmdInfo = fGLDrawCmdsInfo[glCmdIdx]; | |
251 GL_CALL(DrawElementsInstanced(GR_GL_TRIANGLES, cmdInfo.fGeometry.fCo unt, | 251 GL_CALL(DrawElementsInstanced(GR_GL_TRIANGLES, cmdInfo.fGeometry.fCo unt, |
252 GR_GL_UNSIGNED_BYTE, | 252 GR_GL_UNSIGNED_BYTE, |
253 (GrGLubyte*) nullptr + cmdInfo.fGeomet ry.fStart, | 253 (GrGLubyte*) nullptr + cmdInfo.fGeomet ry.fStart, |
254 cmdInfo.fInstanceCount)); | 254 cmdInfo.fInstanceCount)); |
255 } | 255 if (!glCaps.baseInstanceSupport()) { |
256 if (!glCaps.baseInstanceSupport()) { | 256 emulatedBaseInstance += cmdInfo.fInstanceCount; |
257 emulatedBaseInstance += cmdInfo.fInstanceCount; | 257 } |
csmartdalton
2016/09/15 16:16:24
This needs to happen for the glDrawElementsIndirec
| |
258 } | 258 } |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 void GLInstancedRendering::flushInstanceAttribs(int baseInstance) { | 262 void GLInstancedRendering::flushInstanceAttribs(int baseInstance) { |
263 SkASSERT(fVertexArrayID); | 263 SkASSERT(fVertexArrayID); |
264 this->glGpu()->bindVertexArray(fVertexArrayID); | 264 this->glGpu()->bindVertexArray(fVertexArrayID); |
265 | 265 |
266 SkASSERT(fInstanceBuffer); | 266 SkASSERT(fInstanceBuffer); |
267 if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() || | 267 if (fInstanceAttribsBufferUniqueId != fInstanceBuffer->uniqueID() || |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 GL_CALL(DeleteVertexArrays(1, &fVertexArrayID)); | 314 GL_CALL(DeleteVertexArrays(1, &fVertexArrayID)); |
315 this->glGpu()->notifyVertexArrayDelete(fVertexArrayID); | 315 this->glGpu()->notifyVertexArrayDelete(fVertexArrayID); |
316 } | 316 } |
317 fVertexArrayID = 0; | 317 fVertexArrayID = 0; |
318 fInstanceBuffer.reset(); | 318 fInstanceBuffer.reset(); |
319 fDrawIndirectBuffer.reset(); | 319 fDrawIndirectBuffer.reset(); |
320 fInstanceAttribsBufferUniqueId = SK_InvalidUniqueID; | 320 fInstanceAttribsBufferUniqueId = SK_InvalidUniqueID; |
321 } | 321 } |
322 | 322 |
323 } | 323 } |
OLD | NEW |