Chromium Code Reviews| Index: src/gpu/gl/GrGLGpu.cpp |
| diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
| index f742efe70d1b829fb4135ce4d21b93426cad3dfb..352927b436266b0a27ce52467b0d735df8d0402b 100644 |
| --- a/src/gpu/gl/GrGLGpu.cpp |
| +++ b/src/gpu/gl/GrGLGpu.cpp |
| @@ -2071,15 +2071,14 @@ void GrGLGpu::flushScissor(const GrScissorState& scissorState, |
| this->disableScissor(); |
| } |
| -bool GrGLGpu::flushGLState(const DrawArgs& args) { |
| +bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcessor& primProc) { |
| GrXferProcessor::BlendInfo blendInfo; |
| - const GrPipeline& pipeline = *args.fPipeline; |
| - args.fPipeline->getXferProcessor().getBlendInfo(&blendInfo); |
| + pipeline.getXferProcessor().getBlendInfo(&blendInfo); |
| this->flushColorWrite(blendInfo.fWriteColor); |
| this->flushDrawFace(pipeline.getDrawFace()); |
| - SkAutoTUnref<GrGLProgram> program(fProgramCache->refProgram(args)); |
| + SkAutoTUnref<GrGLProgram> program(fProgramCache->refProgram(this, pipeline, primProc)); |
| if (!program) { |
| GrCapsDebugf(this->caps(), "Failed to create program!\n"); |
| return false; |
| @@ -2094,12 +2093,12 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) { |
| if (blendInfo.fWriteColor) { |
| // Swizzle the blend to match what the shader will output. |
| const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzle( |
| - args.fPipeline->getRenderTarget()->config()); |
| + pipeline.getRenderTarget()->config()); |
| this->flushBlend(blendInfo, swizzle); |
| } |
| SkSTArray<8, const GrTextureAccess*> textureAccesses; |
| - program->setData(*args.fPrimitiveProcessor, pipeline, &textureAccesses); |
| + program->setData(primProc, pipeline, &textureAccesses); |
| int numTextureAccesses = textureAccesses.count(); |
| for (int i = 0; i < numTextureAccesses; i++) { |
| @@ -2170,14 +2169,6 @@ void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
| } |
| } |
| -void GrGLGpu::buildProgramDesc(GrProgramDesc* desc, |
| - const GrPrimitiveProcessor& primProc, |
| - const GrPipeline& pipeline) const { |
| - if (!GrGLProgramDescBuilder::Build(desc, primProc, pipeline, *this->glCaps().glslCaps())) { |
| - SkDEBUGFAIL("Failed to generate GL program descriptor"); |
| - } |
| -} |
| - |
| void GrGLGpu::bindBuffer(GrGLuint id, GrGLenum type) { |
| this->handleDirtyContext(); |
| switch (type) { |
| @@ -2918,55 +2909,73 @@ GrGLenum gPrimitiveType2GLMode[] = { |
| #endif |
| #endif |
| -void GrGLGpu::onDraw(const DrawArgs& args, const GrNonInstancedVertices& vertices) { |
| - if (!this->flushGLState(args)) { |
| +void GrGLGpu::onDraw(const GrPipeline& pipeline, |
| + const GrPrimitiveProcessor& primProc, |
| + GrPrimitiveType primitiveType, |
| + const GrVertices* vertArray, |
| + int drawCount) { |
| + if (!this->flushGLState(pipeline, primProc)) { |
| return; |
| } |
| + GrPixelLocalStorageState plsState = primProc.getPixelLocalStorageState(); |
| - GrPixelLocalStorageState plsState = args.fPrimitiveProcessor->getPixelLocalStorageState(); |
| - if (!fHWPLSEnabled && plsState != |
| - GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) { |
| - GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| - this->setupPixelLocalStorage(args); |
| - fHWPLSEnabled = true; |
| - } |
| - if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) { |
| - GrStencilSettings stencil; |
| - stencil.setDisabled(); |
| - this->flushStencil(stencil); |
| - } |
| - size_t indexOffsetInBytes = 0; |
| - this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes); |
| + for (int i = 0; i < drawCount; ++i) { |
| + if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps())) { |
| + this->xferBarrier(pipeline.getRenderTarget(), barrierType); |
| + } |
| - SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode)); |
| + const GrVertices& vertices = vertArray[i]; |
| + GrVertices::Iterator iter; |
| + const GrNonInstancedVertices* verts = iter.init(vertices); |
| + do { |
| + if (!fHWPLSEnabled && plsState != |
|
egdaniel
2016/03/16 19:55:35
Ethan do you know if all this PLS stuff needs to s
bsalomon
2016/03/16 20:07:22
Seems like it could all move out since all we're d
ethannicholas
2016/03/16 21:14:19
Agreed.
egdaniel
2016/03/17 15:09:36
Done.
|
| + GrPixelLocalStorageState::kDisabled_GrPixelLocalStorageState) { |
| + GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| + this->setupPixelLocalStorage(pipeline, primProc); |
| + fHWPLSEnabled = true; |
| + } |
| + if (plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) { |
| + GrStencilSettings stencil; |
| + stencil.setDisabled(); |
| + this->flushStencil(stencil); |
| + } |
| - if (vertices.isIndexed()) { |
| - GrGLvoid* indices = |
| - reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * |
| - vertices.startIndex()); |
| - // info.startVertex() was accounted for by setupGeometry. |
| - GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], |
| - vertices.indexCount(), |
| - GR_GL_UNSIGNED_SHORT, |
| - indices)); |
| - } else { |
| - // Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account for |
| - // startVertex in the DrawElements case. So we always rely on setupGeometry to have |
| - // accounted for startVertex. |
| - GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, |
| - vertices.vertexCount())); |
| - } |
| + size_t indexOffsetInBytes = 0; |
| + this->setupGeometry(primProc, *verts, &indexOffsetInBytes); |
| + |
| + if (verts->isIndexed()) { |
| + GrGLvoid* indices = |
| + reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * |
| + verts->startIndex()); |
| + // info.startVertex() was accounted for by setupGeometry. |
| + GL_CALL(DrawElements(gPrimitiveType2GLMode[primitiveType], |
| + verts->indexCount(), |
| + GR_GL_UNSIGNED_SHORT, |
| + indices)); |
| + } else { |
| + // Pass 0 for parameter first. We have to adjust glVertexAttribPointer() to account |
| + // for startVertex in the DrawElements case. So we always rely on setupGeometry to |
| + // have accounted for startVertex. |
| + GL_CALL(DrawArrays(gPrimitiveType2GLMode[primitiveType], 0, |
| + verts->vertexCount())); |
| + } |
| - if (fHWPLSEnabled && plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) { |
| - // PLS draws always involve multiple draws, finishing up with a non-PLS |
| - // draw that writes to the color buffer. That draw ends up here; we wait |
| - // until after it is complete to actually disable PLS. |
| - GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| - fHWPLSEnabled = false; |
| - this->disableScissor(); |
| + if (fHWPLSEnabled && |
| + plsState == GrPixelLocalStorageState::kFinish_GrPixelLocalStorageState) { |
| + // PLS draws always involve multiple draws, finishing up with a non-PLS |
| + // draw that writes to the color buffer. That draw ends up here; we wait |
| + // until after it is complete to actually disable PLS. |
| + GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| + fHWPLSEnabled = false; |
| + this->disableScissor(); |
| + } |
| + |
| + fStats.incNumDraws(); |
| + } while ((verts = iter.next())); |
| } |
| + |
| #if SWAP_PER_DRAW |
| glFlush(); |
| #if defined(SK_BUILD_FOR_MAC) |
| @@ -3009,13 +3018,14 @@ void GrGLGpu::stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGL |
| } |
| } |
| -void GrGLGpu::setupPixelLocalStorage(const DrawArgs& args) { |
| +void GrGLGpu::setupPixelLocalStorage(const GrPipeline& pipeline, |
| + const GrPrimitiveProcessor& primProc) { |
| fPLSHasBeenUsed = true; |
| const SkRect& bounds = |
| - static_cast<const GrPLSGeometryProcessor*>(args.fPrimitiveProcessor)->getBounds(); |
| + static_cast<const GrPLSGeometryProcessor&>(primProc).getBounds(); |
| // setup pixel local storage -- this means capturing and storing the current framebuffer color |
| // and initializing the winding counts to zero |
| - GrRenderTarget* rt = args.fPipeline->getRenderTarget(); |
| + GrRenderTarget* rt = pipeline.getRenderTarget(); |
| SkScalar width = SkIntToScalar(rt->width()); |
| SkScalar height = SkIntToScalar(rt->height()); |
| // dst rect edges in NDC (-1 to 1) |