• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/gpu/gl/GrGLOpsRenderPass.h"
9 
10 #include "src/gpu/GrProgramInfo.h"
11 #include "src/gpu/GrRenderTarget.h"
12 
13 #ifdef SK_DEBUG
14 #include "include/gpu/GrDirectContext.h"
15 #include "src/gpu/GrDirectContextPriv.h"
16 #endif
17 
18 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
19 
set(GrRenderTarget * rt,bool useMSAASurface,const SkIRect & contentBounds,GrSurfaceOrigin origin,const LoadAndStoreInfo & colorInfo,const StencilLoadAndStoreInfo & stencilInfo)20 void GrGLOpsRenderPass::set(GrRenderTarget* rt, bool useMSAASurface, const SkIRect& contentBounds,
21                             GrSurfaceOrigin origin, const LoadAndStoreInfo& colorInfo,
22                             const StencilLoadAndStoreInfo& stencilInfo) {
23     SkASSERT(fGpu);
24     SkASSERT(!fRenderTarget);
25     SkASSERT(fGpu == rt->getContext()->priv().getGpu());
26 
27     this->INHERITED::set(rt, origin);
28     fUseMultisampleFBO = useMSAASurface;
29     fContentBounds = contentBounds;
30     fColorLoadAndStoreInfo = colorInfo;
31     fStencilLoadAndStoreInfo = stencilInfo;
32 }
33 
dmsaaLoadStoreBounds() const34 GrNativeRect GrGLOpsRenderPass::dmsaaLoadStoreBounds() const {
35     if (fGpu->glCaps().framebufferResolvesMustBeFullSize()) {
36         // If frambeffer resolves have to be full size, then resolve the entire render target during
37         // load and store both, even if we will be doing so with a draw. We do this because we will
38         // have no other choice than to do a full size resolve at the end of the render pass, so the
39         // full DMSAA attachment needs to have valid content.
40         return GrNativeRect::MakeRelativeTo(fOrigin, fRenderTarget->height(),
41                                             SkIRect::MakeSize(fRenderTarget->dimensions()));
42     } else {
43         return GrNativeRect::MakeRelativeTo(fOrigin, fRenderTarget->height(), fContentBounds);
44     }
45 }
46 
onBegin()47 void GrGLOpsRenderPass::onBegin() {
48     auto glRT = static_cast<GrGLRenderTarget*>(fRenderTarget);
49     if (fUseMultisampleFBO &&
50         fColorLoadAndStoreInfo.fLoadOp == GrLoadOp::kLoad &&
51         glRT->hasDynamicMSAAAttachment()) {
52         // Load the single sample fbo into the dmsaa attachment.
53         if (fGpu->glCaps().canResolveSingleToMSAA()) {
54             fGpu->resolveRenderFBOs(glRT, this->dmsaaLoadStoreBounds().asSkIRect(),
55                                     GrGLGpu::ResolveDirection::kSingleToMSAA);
56         } else {
57             fGpu->drawSingleIntoMSAAFBO(glRT, this->dmsaaLoadStoreBounds().asSkIRect());
58         }
59     }
60 
61     fGpu->beginCommandBuffer(glRT, fUseMultisampleFBO, fContentBounds, fOrigin,
62                              fColorLoadAndStoreInfo, fStencilLoadAndStoreInfo);
63 }
64 
onEnd()65 void GrGLOpsRenderPass::onEnd() {
66     auto glRT = static_cast<GrGLRenderTarget*>(fRenderTarget);
67     fGpu->endCommandBuffer(glRT, fUseMultisampleFBO, fColorLoadAndStoreInfo,
68                            fStencilLoadAndStoreInfo);
69 
70     if (fUseMultisampleFBO &&
71         fColorLoadAndStoreInfo.fStoreOp == GrStoreOp::kStore &&
72         glRT->hasDynamicMSAAAttachment()) {
73         // Blit the msaa attachment into the single sample fbo.
74         fGpu->resolveRenderFBOs(glRT, this->dmsaaLoadStoreBounds().asSkIRect(),
75                                 GrGLGpu::ResolveDirection::kMSAAToSingle,
76                                 true /*invalidateReadBufferAfterBlit*/);
77     }
78 }
79 
onBindPipeline(const GrProgramInfo & programInfo,const SkRect & drawBounds)80 bool GrGLOpsRenderPass::onBindPipeline(const GrProgramInfo& programInfo,
81                                        const SkRect& drawBounds) {
82     fPrimitiveType = programInfo.primitiveType();
83     return fGpu->flushGLState(fRenderTarget, fUseMultisampleFBO, programInfo);
84 }
85 
onSetScissorRect(const SkIRect & scissor)86 void GrGLOpsRenderPass::onSetScissorRect(const SkIRect& scissor) {
87     fGpu->flushScissorRect(scissor, fRenderTarget->height(), fOrigin);
88 }
89 
onBindTextures(const GrGeometryProcessor & geomProc,const GrSurfaceProxy * const geomProcTextures[],const GrPipeline & pipeline)90 bool GrGLOpsRenderPass::onBindTextures(const GrGeometryProcessor& geomProc,
91                                        const GrSurfaceProxy* const geomProcTextures[],
92                                        const GrPipeline& pipeline) {
93     GrGLProgram* program = fGpu->currentProgram();
94     SkASSERT(program);
95     program->bindTextures(geomProc, geomProcTextures, pipeline);
96     return true;
97 }
98 
onBindBuffers(sk_sp<const GrBuffer> indexBuffer,sk_sp<const GrBuffer> instanceBuffer,sk_sp<const GrBuffer> vertexBuffer,GrPrimitiveRestart primitiveRestart)99 void GrGLOpsRenderPass::onBindBuffers(sk_sp<const GrBuffer> indexBuffer,
100                                       sk_sp<const GrBuffer> instanceBuffer,
101                                       sk_sp<const GrBuffer> vertexBuffer,
102                                       GrPrimitiveRestart primitiveRestart) {
103     SkASSERT((primitiveRestart == GrPrimitiveRestart::kNo) || indexBuffer);
104     GrGLProgram* program = fGpu->currentProgram();
105     SkASSERT(program);
106 
107 #ifdef SK_DEBUG
108     fDidBindInstanceBuffer = false;
109     fDidBindVertexBuffer = false;
110 #endif
111 
112     int numAttribs = program->numVertexAttributes() + program->numInstanceAttributes();
113     fAttribArrayState = fGpu->bindInternalVertexArray(indexBuffer.get(), numAttribs,
114                                                       primitiveRestart);
115 
116     if (indexBuffer) {
117         if (indexBuffer->isCpuBuffer()) {
118             auto* cpuIndexBuffer = static_cast<const GrCpuBuffer*>(indexBuffer.get());
119             fIndexPointer = reinterpret_cast<const uint16_t*>(cpuIndexBuffer->data());
120         } else {
121             fIndexPointer = nullptr;
122         }
123     }
124 
125     // If this platform does not support baseInstance, defer binding of the instance buffer.
126     if (fGpu->glCaps().baseVertexBaseInstanceSupport()) {
127         this->bindInstanceBuffer(instanceBuffer.get(), 0);
128         SkDEBUGCODE(fDidBindInstanceBuffer = true;)
129     }
130     fActiveInstanceBuffer = std::move(instanceBuffer);
131 
132     // We differ binding the vertex buffer for one of two situations:
133     // 1) This platform does not support baseVertex with indexed draws.
134     // 2) There is a driver bug affecting glDrawArrays.
135     if ((indexBuffer && fGpu->glCaps().baseVertexBaseInstanceSupport()) ||
136         (!indexBuffer && !fGpu->glCaps().drawArraysBaseVertexIsBroken())) {
137             this->bindVertexBuffer(vertexBuffer.get(), 0);
138             SkDEBUGCODE(fDidBindVertexBuffer = true;)
139     }
140     fActiveVertexBuffer = std::move(vertexBuffer);
141     fActiveIndexBuffer = std::move(indexBuffer);
142 }
143 
bindInstanceBuffer(const GrBuffer * instanceBuffer,int baseInstance)144 void GrGLOpsRenderPass::bindInstanceBuffer(const GrBuffer* instanceBuffer, int baseInstance) {
145     GrGLProgram* program = fGpu->currentProgram();
146     SkASSERT(program);
147     if (int instanceStride = program->instanceStride()) {
148         SkASSERT(instanceBuffer);
149         SkASSERT(instanceBuffer->isCpuBuffer() ||
150                  !static_cast<const GrGpuBuffer*>(instanceBuffer)->isMapped());
151         size_t bufferOffset = baseInstance * static_cast<size_t>(instanceStride);
152         int attribIdx = program->numVertexAttributes();
153         for (int i = 0; i < program->numInstanceAttributes(); ++i, ++attribIdx) {
154             const auto& attrib = program->instanceAttribute(i);
155             static constexpr int kDivisor = 1;
156             fAttribArrayState->set(fGpu, attrib.fLocation, instanceBuffer, attrib.fCPUType,
157                                    attrib.fGPUType, instanceStride, bufferOffset + attrib.fOffset,
158                                    kDivisor);
159         }
160     }
161 }
162 
bindVertexBuffer(const GrBuffer * vertexBuffer,int baseVertex)163 void GrGLOpsRenderPass::bindVertexBuffer(const GrBuffer* vertexBuffer, int baseVertex) {
164     GrGLProgram* program = fGpu->currentProgram();
165     SkASSERT(program);
166     if (int vertexStride = program->vertexStride()) {
167         SkASSERT(vertexBuffer);
168         SkASSERT(vertexBuffer->isCpuBuffer() ||
169                  !static_cast<const GrGpuBuffer*>(vertexBuffer)->isMapped());
170         size_t bufferOffset = baseVertex * static_cast<size_t>(vertexStride);
171         for (int i = 0; i < program->numVertexAttributes(); ++i) {
172             const auto& attrib = program->vertexAttribute(i);
173             static constexpr int kDivisor = 0;
174             fAttribArrayState->set(fGpu, attrib.fLocation, vertexBuffer, attrib.fCPUType,
175                                    attrib.fGPUType, vertexStride, bufferOffset + attrib.fOffset,
176                                    kDivisor);
177         }
178     }
179 }
180 
onDraw(int vertexCount,int baseVertex)181 void GrGLOpsRenderPass::onDraw(int vertexCount, int baseVertex) {
182     SkASSERT(fDidBindVertexBuffer || fGpu->glCaps().drawArraysBaseVertexIsBroken());
183     GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
184     if (fGpu->glCaps().drawArraysBaseVertexIsBroken()) {
185         this->bindVertexBuffer(fActiveVertexBuffer.get(), baseVertex);
186         baseVertex = 0;
187     }
188     GL_CALL(DrawArrays(glPrimType, baseVertex, vertexCount));
189 }
190 
onDrawIndexed(int indexCount,int baseIndex,uint16_t minIndexValue,uint16_t maxIndexValue,int baseVertex)191 void GrGLOpsRenderPass::onDrawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue,
192                                       uint16_t maxIndexValue, int baseVertex) {
193     GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
194     if (fGpu->glCaps().baseVertexBaseInstanceSupport()) {
195         SkASSERT(fGpu->glCaps().drawInstancedSupport());
196         SkASSERT(fDidBindVertexBuffer);
197         if (baseVertex != 0) {
198             GL_CALL(DrawElementsInstancedBaseVertexBaseInstance(
199                     glPrimType, indexCount, GR_GL_UNSIGNED_SHORT,
200                     this->offsetForBaseIndex(baseIndex), 1, baseVertex, 0));
201             return;
202         }
203     } else {
204         this->bindVertexBuffer(fActiveVertexBuffer.get(), baseVertex);
205     }
206 
207     if (fGpu->glCaps().drawRangeElementsSupport()) {
208         GL_CALL(DrawRangeElements(glPrimType, minIndexValue, maxIndexValue, indexCount,
209                                   GR_GL_UNSIGNED_SHORT, this->offsetForBaseIndex(baseIndex)));
210     } else {
211         GL_CALL(DrawElements(glPrimType, indexCount, GR_GL_UNSIGNED_SHORT,
212                              this->offsetForBaseIndex(baseIndex)));
213     }
214 }
215 
onDrawInstanced(int instanceCount,int baseInstance,int vertexCount,int baseVertex)216 void GrGLOpsRenderPass::onDrawInstanced(int instanceCount, int baseInstance, int vertexCount,
217                                         int baseVertex) {
218     SkASSERT(fDidBindVertexBuffer || fGpu->glCaps().drawArraysBaseVertexIsBroken());
219     if (fGpu->glCaps().drawArraysBaseVertexIsBroken()) {
220         // We weren't able to bind the vertex buffer during onBindBuffers because of a driver bug
221         // affecting glDrawArrays.
222         this->bindVertexBuffer(fActiveVertexBuffer.get(), 0);
223     }
224     int maxInstances = fGpu->glCaps().maxInstancesPerDrawWithoutCrashing(instanceCount);
225     for (int i = 0; i < instanceCount; i += maxInstances) {
226         GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
227         int instanceCountForDraw = std::min(instanceCount - i, maxInstances);
228         int baseInstanceForDraw = baseInstance + i;
229         if (fGpu->glCaps().baseVertexBaseInstanceSupport()) {
230             SkASSERT(fDidBindInstanceBuffer);
231             GL_CALL(DrawArraysInstancedBaseInstance(glPrimType, baseVertex, vertexCount,
232                                                     instanceCountForDraw, baseInstanceForDraw));
233         } else {
234             this->bindInstanceBuffer(fActiveInstanceBuffer.get(), baseInstanceForDraw);
235             GL_CALL(DrawArraysInstanced(glPrimType, baseVertex, vertexCount, instanceCountForDraw));
236         }
237     }
238 }
239 
onDrawIndexedInstanced(int indexCount,int baseIndex,int instanceCount,int baseInstance,int baseVertex)240 void GrGLOpsRenderPass::onDrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount,
241                                                int baseInstance, int baseVertex) {
242     int maxInstances = fGpu->glCaps().maxInstancesPerDrawWithoutCrashing(instanceCount);
243     for (int i = 0; i < instanceCount; i += maxInstances) {
244         GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
245         int instanceCountForDraw = std::min(instanceCount - i, maxInstances);
246         int baseInstanceForDraw = baseInstance + i;
247         if (fGpu->glCaps().baseVertexBaseInstanceSupport()) {
248             SkASSERT(fDidBindInstanceBuffer);
249             SkASSERT(fDidBindVertexBuffer);
250             GL_CALL(DrawElementsInstancedBaseVertexBaseInstance(
251                     glPrimType, indexCount, GR_GL_UNSIGNED_SHORT,
252                     this->offsetForBaseIndex(baseIndex), instanceCountForDraw, baseVertex,
253                     baseInstanceForDraw));
254         } else {
255             this->bindInstanceBuffer(fActiveInstanceBuffer.get(), baseInstanceForDraw);
256             this->bindVertexBuffer(fActiveVertexBuffer.get(), baseVertex);
257             GL_CALL(DrawElementsInstanced(glPrimType, indexCount, GR_GL_UNSIGNED_SHORT,
258                                         this->offsetForBaseIndex(baseIndex), instanceCountForDraw));
259         }
260     }
261 }
262 
buffer_offset_to_gl_address(const GrBuffer * drawIndirectBuffer,size_t offset)263 static const void* buffer_offset_to_gl_address(const GrBuffer* drawIndirectBuffer, size_t offset) {
264     if (drawIndirectBuffer->isCpuBuffer()) {
265         return static_cast<const GrCpuBuffer*>(drawIndirectBuffer)->data() + offset;
266     } else {
267         return (offset) ? reinterpret_cast<const void*>(offset) : nullptr;
268     }
269 }
270 
onDrawIndirect(const GrBuffer * drawIndirectBuffer,size_t offset,int drawCount)271 void GrGLOpsRenderPass::onDrawIndirect(const GrBuffer* drawIndirectBuffer, size_t offset,
272                                        int drawCount) {
273     using MultiDrawType = GrGLCaps::MultiDrawType;
274 
275     SkASSERT(fGpu->caps()->nativeDrawIndirectSupport());
276     SkASSERT(fGpu->glCaps().baseVertexBaseInstanceSupport());
277     SkASSERT(fDidBindVertexBuffer || fGpu->glCaps().drawArraysBaseVertexIsBroken());
278 
279     if (fGpu->glCaps().drawArraysBaseVertexIsBroken()) {
280         // We weren't able to bind the vertex buffer during onBindBuffers because of a driver bug
281         // affecting glDrawArrays.
282         this->bindVertexBuffer(fActiveVertexBuffer.get(), 0);
283     }
284 
285     if (fGpu->glCaps().multiDrawType() == MultiDrawType::kANGLEOrWebGL) {
286         // ANGLE and WebGL don't support glDrawElementsIndirect. We draw everything as a multi draw.
287         this->multiDrawArraysANGLEOrWebGL(drawIndirectBuffer, offset, drawCount);
288         return;
289     }
290 
291     fGpu->bindBuffer(GrGpuBufferType::kDrawIndirect, drawIndirectBuffer);
292 
293     if (drawCount > 1 && fGpu->glCaps().multiDrawType() == MultiDrawType::kMultiDrawIndirect) {
294         GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
295         GL_CALL(MultiDrawArraysIndirect(glPrimType,
296                                         buffer_offset_to_gl_address(drawIndirectBuffer, offset),
297                                         drawCount, sizeof(GrDrawIndirectCommand)));
298         return;
299     }
300 
301     for (int i = 0; i < drawCount; ++i) {
302         GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
303         GL_CALL(DrawArraysIndirect(glPrimType,
304                                    buffer_offset_to_gl_address(drawIndirectBuffer, offset)));
305         offset += sizeof(GrDrawIndirectCommand);
306     }
307 }
308 
multiDrawArraysANGLEOrWebGL(const GrBuffer * drawIndirectBuffer,size_t offset,int drawCount)309 void GrGLOpsRenderPass::multiDrawArraysANGLEOrWebGL(const GrBuffer* drawIndirectBuffer,
310                                                     size_t offset, int drawCount) {
311     SkASSERT(fGpu->glCaps().multiDrawType() == GrGLCaps::MultiDrawType::kANGLEOrWebGL);
312     SkASSERT(drawIndirectBuffer->isCpuBuffer());
313 
314     constexpr static int kMaxDrawCountPerBatch = 128;
315     GrGLint fFirsts[kMaxDrawCountPerBatch];
316     GrGLsizei fCounts[kMaxDrawCountPerBatch];
317     GrGLsizei fInstanceCounts[kMaxDrawCountPerBatch];
318     GrGLuint fBaseInstances[kMaxDrawCountPerBatch];
319 
320     GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
321     auto* cpuBuffer = static_cast<const GrCpuBuffer*>(drawIndirectBuffer);
322     auto* cmds = reinterpret_cast<const GrDrawIndirectCommand*>(cpuBuffer->data() + offset);
323 
324     while (drawCount) {
325         int countInBatch = std::min(drawCount, kMaxDrawCountPerBatch);
326         for (int i = 0; i < countInBatch; ++i) {
327             auto [vertexCount, instanceCount, baseVertex, baseInstance] = cmds[i];
328             fFirsts[i] = baseVertex;
329             fCounts[i] = vertexCount;
330             fInstanceCounts[i] = instanceCount;
331             fBaseInstances[i] = baseInstance;
332         }
333         if (countInBatch == 1) {
334             GL_CALL(DrawArraysInstancedBaseInstance(glPrimType, fFirsts[0], fCounts[0],
335                                                     fInstanceCounts[0], fBaseInstances[0]));
336         } else {
337             GL_CALL(MultiDrawArraysInstancedBaseInstance(glPrimType, fFirsts, fCounts,
338                                                          fInstanceCounts, fBaseInstances,
339                                                          countInBatch));
340         }
341         drawCount -= countInBatch;
342         cmds += countInBatch;
343     }
344 }
345 
onDrawIndexedIndirect(const GrBuffer * drawIndirectBuffer,size_t offset,int drawCount)346 void GrGLOpsRenderPass::onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffer, size_t offset,
347                                               int drawCount) {
348     using MultiDrawType = GrGLCaps::MultiDrawType;
349 
350     SkASSERT(fGpu->caps()->nativeDrawIndirectSupport());
351     SkASSERT(!fGpu->caps()->nativeDrawIndexedIndirectIsBroken());
352     SkASSERT(fGpu->glCaps().baseVertexBaseInstanceSupport());
353     // The vertex buffer should have already gotten bound (as opposed us stashing it away during
354     // onBindBuffers and not expecting to bind it until this point).
355     SkASSERT(fDidBindVertexBuffer);
356 
357     if (fGpu->glCaps().multiDrawType() == MultiDrawType::kANGLEOrWebGL) {
358         // ANGLE and WebGL don't support glDrawElementsIndirect. We draw everything as a multi draw.
359         this->multiDrawElementsANGLEOrWebGL(drawIndirectBuffer, offset, drawCount);
360         return;
361     }
362 
363     fGpu->bindBuffer(GrGpuBufferType::kDrawIndirect, drawIndirectBuffer);
364 
365     if (drawCount > 1 && fGpu->glCaps().multiDrawType() == MultiDrawType::kMultiDrawIndirect) {
366         GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
367         GL_CALL(MultiDrawElementsIndirect(glPrimType, GR_GL_UNSIGNED_SHORT,
368                                           buffer_offset_to_gl_address(drawIndirectBuffer, offset),
369                                           drawCount, sizeof(GrDrawIndexedIndirectCommand)));
370         return;
371     }
372 
373     for (int i = 0; i < drawCount; ++i) {
374         GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
375         GL_CALL(DrawElementsIndirect(glPrimType, GR_GL_UNSIGNED_SHORT,
376                                      buffer_offset_to_gl_address(drawIndirectBuffer, offset)));
377         offset += sizeof(GrDrawIndexedIndirectCommand);
378     }
379 }
380 
multiDrawElementsANGLEOrWebGL(const GrBuffer * drawIndirectBuffer,size_t offset,int drawCount)381 void GrGLOpsRenderPass::multiDrawElementsANGLEOrWebGL(const GrBuffer* drawIndirectBuffer,
382                                                       size_t offset, int drawCount) {
383     SkASSERT(fGpu->glCaps().multiDrawType() == GrGLCaps::MultiDrawType::kANGLEOrWebGL);
384     SkASSERT(drawIndirectBuffer->isCpuBuffer());
385 
386     constexpr static int kMaxDrawCountPerBatch = 128;
387     GrGLint fCounts[kMaxDrawCountPerBatch];
388     const void* fIndices[kMaxDrawCountPerBatch];
389     GrGLsizei fInstanceCounts[kMaxDrawCountPerBatch];
390     GrGLint fBaseVertices[kMaxDrawCountPerBatch];
391     GrGLuint fBaseInstances[kMaxDrawCountPerBatch];
392 
393     GrGLenum glPrimType = fGpu->prepareToDraw(fPrimitiveType);
394     auto* cpuBuffer = static_cast<const GrCpuBuffer*>(drawIndirectBuffer);
395     auto* cmds = reinterpret_cast<const GrDrawIndexedIndirectCommand*>(cpuBuffer->data() + offset);
396 
397     while (drawCount) {
398         int countInBatch = std::min(drawCount, kMaxDrawCountPerBatch);
399         for (int i = 0; i < countInBatch; ++i) {
400             auto [indexCount, instanceCount, baseIndex, baseVertex, baseInstance] = cmds[i];
401             fCounts[i] = indexCount;
402             fIndices[i] = this->offsetForBaseIndex(baseIndex);
403             fInstanceCounts[i] = instanceCount;
404             fBaseVertices[i] = baseVertex;
405             fBaseInstances[i] = baseInstance;
406         }
407         if (countInBatch == 1) {
408             GL_CALL(DrawElementsInstancedBaseVertexBaseInstance(glPrimType, fCounts[0],
409                                                                 GR_GL_UNSIGNED_SHORT, fIndices[0],
410                                                                 fInstanceCounts[0],
411                                                                 fBaseVertices[0],
412                                                                 fBaseInstances[0]));
413         } else {
414             GL_CALL(MultiDrawElementsInstancedBaseVertexBaseInstance(glPrimType, fCounts,
415                                                                      GR_GL_UNSIGNED_SHORT, fIndices,
416                                                                      fInstanceCounts, fBaseVertices,
417                                                                      fBaseInstances, countInBatch));
418         }
419         drawCount -= countInBatch;
420         cmds += countInBatch;
421     }
422 }
423 
onClear(const GrScissorState & scissor,std::array<float,4> color)424 void GrGLOpsRenderPass::onClear(const GrScissorState& scissor, std::array<float, 4> color) {
425     fGpu->clear(scissor, color, fRenderTarget, fUseMultisampleFBO, fOrigin);
426 }
427 
onClearStencilClip(const GrScissorState & scissor,bool insideStencilMask)428 void GrGLOpsRenderPass::onClearStencilClip(const GrScissorState& scissor, bool insideStencilMask) {
429     fGpu->clearStencilClip(scissor, insideStencilMask, fRenderTarget, fUseMultisampleFBO, fOrigin);
430 }
431