diff options
author | joshualitt <joshualitt@google.com> | 2014-12-04 06:01:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-04 06:01:45 -0800 |
commit | f78c60c92a8c212fc462262f2ce81e584d0f02f8 (patch) | |
tree | 33a43f1d293a54764399846c504d1506d2cbd9e0 /src/gpu/gl | |
parent | 841a6b54c11137e210aa81e8b56e1763c3571cb8 (diff) |
Revert of move program descriptor generation to flush (patchset #7 id:120001 of https://codereview.chromium.org/777673003/)
Reason for revert:
breaking linux build
Original issue's description:
> move program descriptor generation to flush
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/829e1b80b1020b17f2078020c990e079b70c077c
TBR=egdaniel@google.com,bsalomon@google.com,joshualitt@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/776243005
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 19 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.h | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 18 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 10 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.h | 3 |
9 files changed, 44 insertions, 30 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 3b04edb8c8..63cb9da20b 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -123,13 +123,13 @@ void GrGLProgram::bindTextures(const GrGLInstalledProc* ip, const GrProcessor& p /////////////////////////////////////////////////////////////////////////////// -void GrGLProgram::setData(const GrOptDrawState& optState) { +void GrGLProgram::setData(const GrOptDrawState& optState, GrGpu::DrawType drawType) { GrColor color = optState.getColor(); uint8_t coverage = optState.getCoverage(); this->setColor(optState, color); this->setCoverage(optState, coverage); - this->setMatrixAndRenderTargetHeight(optState); + this->setMatrixAndRenderTargetHeight(drawType, optState); const GrDeviceCoordTexture* dstCopy = optState.getDstCopy(); if (dstCopy) { @@ -164,7 +164,7 @@ void GrGLProgram::setData(const GrOptDrawState& optState) { this->setFragmentData(optState); // Some of GrGLProgram subclasses need to update state here - this->didSetData(optState.drawType()); + this->didSetData(drawType); } void GrGLProgram::setFragmentData(const GrOptDrawState& optState) { @@ -241,7 +241,8 @@ void GrGLProgram::setCoverage(const GrOptDrawState& optState, uint8_t coverage) } } -void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { +void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType, + const GrOptDrawState& optState) { // Load the RT height uniform if it is needed to y-flip gl_FragCoord. if (fBuiltinUniformHandles.fRTHeightUni.isValid() && fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->height()) { @@ -250,10 +251,11 @@ void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) } // call subclasses to set the actual view matrix - this->onSetMatrixAndRenderTargetHeight(optState); + this->onSetMatrixAndRenderTargetHeight(drawType, optState); } -void GrGLProgram::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { +void GrGLProgram::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType, + const GrOptDrawState& optState) { const GrRenderTarget* rt = optState.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); @@ -287,8 +289,9 @@ GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu, : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentProcessors) { } -void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) { - SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType())); +void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType, + const GrOptDrawState& optState) { + SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); const GrRenderTarget* rt = optState.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h index 36bf860233..a273a0381e 100644 --- a/src/gpu/gl/GrGLProgram.h +++ b/src/gpu/gl/GrGLProgram.h @@ -129,7 +129,7 @@ public: * GrGpuGL object to bind the textures required by the GrGLProcessors. The color and coverage * stages come from GrGLProgramDesc::Build(). */ - void setData(const GrOptDrawState&); + void setData(const GrOptDrawState&, GrGpu::DrawType); protected: typedef GrGLProgramDataManager::UniformHandle UniformHandle; @@ -167,8 +167,8 @@ protected: virtual void didSetData(GrGpu::DrawType); // Helper for setData() that sets the view matrix and loads the render target height uniform - void setMatrixAndRenderTargetHeight(const GrOptDrawState&); - virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&); + void setMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&); + virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&); // these reflect the current values of uniforms (GL uniform values travel with program) MatrixState fMatrixState; @@ -206,7 +206,7 @@ protected: GrGLuint programID, const UniformInfoArray&, GrGLInstalledFragProcs* fragmentProcessors); - virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&); + virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&); typedef GrGLProgram INHERITED; }; diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index f8dbbc26f9..74f669f2e3 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -196,6 +196,8 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, header->fHasGeometryProcessor = optState.hasGeometryProcessor(); + header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; + bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType); if (gpu->caps()->pathRenderingSupport() && isPathRendering) { header->fUseNvpr = true; diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 383427d9c2..df35d2c78c 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -1894,14 +1894,14 @@ void GrGpuGL::flushStencil(const GrStencilSettings& stencilSettings, DrawType ty } } -void GrGpuGL::flushAAState(const GrOptDrawState& optState) { +void GrGpuGL::flushAAState(const GrOptDrawState& optState, DrawType type) { // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA state is enabled but // the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide. #if 0 // Replace RT_HAS_MSAA with this definition once this driver bug is no longer a relevant concern #define RT_HAS_MSAA rt->isMultisampled() #else - #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == optState.drawType()) + #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type) #endif const GrRenderTarget* rt = optState.getRenderTarget(); diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 8a609884e1..4224ba64fd 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -155,7 +155,7 @@ private: virtual void clearStencil(GrRenderTarget*) SK_OVERRIDE; - virtual bool flushGraphicsState(const GrOptDrawState&) SK_OVERRIDE; + virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRIDE; // GrDrawTarget overrides virtual void didAddGpuTraceMarker() SK_OVERRIDE; @@ -188,7 +188,7 @@ private: ~ProgramCache(); void abandon(); - GrGLProgram* getProgram(const GrOptDrawState&); + GrGLProgram* getProgram(const GrOptDrawState&, DrawType); private: enum { @@ -248,7 +248,7 @@ private: void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds); void flushStencil(const GrStencilSettings&, DrawType); - void flushAAState(const GrOptDrawState&); + void flushAAState(const GrOptDrawState&, DrawType); bool configToGLFormats(GrPixelConfig config, bool getSizedInternal, diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index a808aa8dda..cb8810cc79 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -91,7 +91,7 @@ int GrGpuGL::ProgramCache::search(const GrProgramDesc& desc) const { return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); } -GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState) { +GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, DrawType type) { #ifdef PROGRAM_CACHE_STATS ++fTotalRequests; #endif @@ -126,7 +126,7 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState) { #ifdef PROGRAM_CACHE_STATS ++fCacheMisses; #endif - GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, fGpu); + GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, type, fGpu); if (NULL == program) { return NULL; } @@ -201,11 +201,11 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState) { #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) -bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState) { +bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type) { // GrGpu::setupClipAndFlushState should have already checked this and bailed if not true. SkASSERT(optState.getRenderTarget()); - if (kStencilPath_DrawType == optState.drawType()) { + if (kStencilPath_DrawType == type) { const GrRenderTarget* rt = optState.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); @@ -216,7 +216,7 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState) { GrBlendCoeff srcCoeff = optState.getSrcBlendCoeff(); GrBlendCoeff dstCoeff = optState.getDstBlendCoeff(); - fCurrentProgram.reset(fProgramCache->getProgram(optState)); + fCurrentProgram.reset(fProgramCache->getProgram(optState, type)); if (NULL == fCurrentProgram.get()) { SkDEBUGFAIL("Failed to create program!"); return false; @@ -230,15 +230,15 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState) { fHWProgramID = programID; } - this->flushBlend(optState, kDrawLines_DrawType == optState.drawType(), srcCoeff, dstCoeff); + this->flushBlend(optState, kDrawLines_DrawType == type, srcCoeff, dstCoeff); - fCurrentProgram->setData(optState); + fCurrentProgram->setData(optState, type); } GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget()); - this->flushStencil(optState.getStencil(), optState.drawType()); + this->flushStencil(optState.getStencil(), type); this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin()); - this->flushAAState(optState); + this->flushAAState(optState, type); // This must come after textures are flushed because a texture may need // to be msaa-resolved (which will modify bound FBO state). diff --git a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp index ef8d1a2a35..f35c9ba910 100644 --- a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp +++ b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp @@ -48,7 +48,9 @@ bool GrGLGeometryBuilder::compileAndAttachShaders(GrGLuint programId, geomShaderSrc.append("void main() {\n"); geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n" "\t\tgl_Position = gl_in[i].gl_Position;\n"); - geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n"); + if (fProgramBuilder->desc().header().fEmitsPointSize) { + geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n"); + } SkASSERT(fInputs.count() == fOutputs.count()); for (int i = 0; i < fInputs.count(); ++i) { geomShaderSrc.appendf("\t\t%s = %s[i];\n", diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index aa9e40c3f2..64150a4fda 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -28,10 +28,13 @@ static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar: const int GrGLProgramBuilder::kVarsPerBlock = 8; -GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, GrGpuGL* gpu) { +GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, + GrGpu::DrawType drawType, + GrGpuGL* gpu) { // create a builder. This will be handed off to effects so they can use it to add // uniforms, varyings, textures, etc SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, + drawType, optState.hasGeometryProcessor(), gpu)); @@ -70,6 +73,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, G GrGLProgramBuilder* GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawState& optState, + GrGpu::DrawType drawType, bool hasGeometryProcessor, GrGpuGL* gpu) { const GrProgramDesc& desc = optState.programDesc(); @@ -230,7 +234,9 @@ void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr fVS.setupUniformViewMatrix(); const GrProgramDesc::KeyHeader& header = this->header(); - fVS.codeAppend("gl_PointSize = 1.0;"); + if (header.fEmitsPointSize) { + fVS.codeAppend("gl_PointSize = 1.0;"); + } // Setup position // TODO it'd be possible to remove these from the vertexshader builder and have them diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h index 973ae5e078..76f7ae97c3 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.h +++ b/src/gpu/gl/builders/GrGLProgramBuilder.h @@ -186,7 +186,7 @@ public: * to be used. * @return true if generation was successful. */ - static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpuGL*); + static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpu::DrawType, GrGpuGL*); virtual UniformHandle addUniform(uint32_t visibility, GrSLType type, @@ -246,6 +246,7 @@ protected: typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&, + GrGpu::DrawType, bool hasGeometryProcessor, GrGpuGL*); |