diff options
-rw-r--r-- | expectations/gm/ignored-tests.txt | 16 | ||||
-rw-r--r-- | include/gpu/gl/GrGLConfig.h | 10 | ||||
-rw-r--r-- | include/gpu/gl/GrGLConfig_chrome.h | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrYUVtoRGBEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 114 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.h | 28 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 24 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 25 |
12 files changed, 89 insertions, 141 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt index 1499accc4a..6d10b49b15 100644 --- a/expectations/gm/ignored-tests.txt +++ b/expectations/gm/ignored-tests.txt @@ -43,3 +43,19 @@ dropshadowimagefilter # senorblanco https://codereview.chromium.org/637283009/ # quality improvements to imagemagnifier GM imagemagnifier + +#joshualitt single pixel mismatch in msaa16 +gradients_view_perspective +shadertext2 +complexclip2_rect_aa +bigblurs +simpleaaclip_rect +convexpaths +circles +polygons +ovals +strokes_round +hairmodes +convex_poly_effect +mixed_xfermodes +roundrects diff --git a/include/gpu/gl/GrGLConfig.h b/include/gpu/gl/GrGLConfig.h index 444be00f15..4b3ab8b258 100644 --- a/include/gpu/gl/GrGLConfig.h +++ b/include/gpu/gl/GrGLConfig.h @@ -46,12 +46,6 @@ * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL * when GR_GL_CHECK_ERROR is 1. Defaults to 1. * - * GR_GL_NO_CONSTANT_ATTRIBUTES: if this evaluates to true then the GL backend - * will use uniforms instead of attributes in all cases when there is not - * per-vertex data. This is important when the underlying GL implementation - * doesn't actually support immediate style attribute values (e.g. when - * the GL stream is converted to DX as in ANGLE on Chrome). Defaults to 0. - * * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index * buffer that replaces old data Ganesh can give a hint to the driver that the * previous data will not be used in future draws like this: @@ -126,10 +120,6 @@ #define GR_GL_CHECK_ERROR_START 1 #endif -#if !defined(GR_GL_NO_CONSTANT_ATTRIBUTES) - #define GR_GL_NO_CONSTANT_ATTRIBUTES 0 -#endif - #if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT) #define GR_GL_USE_BUFFER_DATA_NULL_HINT 1 #endif diff --git a/include/gpu/gl/GrGLConfig_chrome.h b/include/gpu/gl/GrGLConfig_chrome.h index acad90450c..ee875b7f22 100644 --- a/include/gpu/gl/GrGLConfig_chrome.h +++ b/include/gpu/gl/GrGLConfig_chrome.h @@ -12,16 +12,12 @@ #define GR_GL_CHECK_ERROR_START 0 #if defined(SK_BUILD_FOR_WIN32) -// ANGLE creates a temp VB for vertex attributes not specified per-vertex. -#define GR_GL_NO_CONSTANT_ATTRIBUTES 1 - // For RGBA teximage/readpixels ANGLE will sw-convert to/from BGRA. #define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 1 // ANGLE can go faster if the entire fbo is read rather than a subrect #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 1 #else -#define GR_GL_NO_CONSTANT_ATTRIBUTES 0 #define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 0 #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0 #endif diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index f02c1b2295..703c672cfd 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -109,7 +109,7 @@ private: virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { // YUV is opaque inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A, - InvariantOutput::kWill_ReadInput); + InvariantOutput::kWillNot_ReadInput); } GrCoordTransform fCoordTransform; diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 2d9b569333..bfa5f3cbc1 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -129,13 +129,12 @@ void GrGLProgram::bindTextures(const GrGLInstalledProc* ip, const GrProcessor& p void GrGLProgram::setData(const GrOptDrawState& optState, GrGpu::DrawType drawType, - const GrDeviceCoordTexture* dstCopy, - SharedGLState* sharedState) { + const GrDeviceCoordTexture* dstCopy) { GrColor color = optState.getColor(); GrColor coverage = optState.getCoverageColor(); - this->setColor(optState, color, sharedState); - this->setCoverage(optState, coverage, sharedState); + this->setColor(optState, color); + this->setCoverage(optState, coverage); this->setMatrixAndRenderTargetHeight(drawType, optState); if (dstCopy) { @@ -201,80 +200,49 @@ void GrGLProgram::didSetData(GrGpu::DrawType drawType) { SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType)); } -void GrGLProgram::setColor(const GrOptDrawState& optState, - GrColor color, - SharedGLState* sharedState) { +void GrGLProgram::setColor(const GrOptDrawState& optState, GrColor color) { const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); - if (!optState.hasColorVertexAttribute()) { - switch (header.fColorInput) { - case GrGLProgramDesc::kAttribute_ColorInput: - SkASSERT(-1 != header.fColorAttributeIndex); - if (sharedState->fConstAttribColor != color || - sharedState->fConstAttribColorIndex != header.fColorAttributeIndex) { - // OpenGL ES only supports the float varieties of glVertexAttrib - GrGLfloat c[4]; - GrColorToRGBAFloat(color, c); - GL_CALL(VertexAttrib4fv(header.fColorAttributeIndex, c)); - sharedState->fConstAttribColor = color; - sharedState->fConstAttribColorIndex = header.fColorAttributeIndex; - } - break; - case GrGLProgramDesc::kUniform_ColorInput: - if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid()) { - // OpenGL ES doesn't support unsigned byte varieties of glUniform - GrGLfloat c[4]; - GrColorToRGBAFloat(color, c); - fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni, 1, c); - fColor = color; - } - sharedState->fConstAttribColorIndex = -1; - break; - case GrGLProgramDesc::kAllOnes_ColorInput: - sharedState->fConstAttribColorIndex = -1; - break; - default: - SkFAIL("Unexpected color type."); - } - } else { - sharedState->fConstAttribColorIndex = -1; + switch (header.fColorInput) { + case GrGLProgramDesc::kAttribute_ColorInput: + // Attribute case is handled in GrGpuGL::setupGeometry + break; + case GrGLProgramDesc::kUniform_ColorInput: + if (fColor != color && fBuiltinUniformHandles.fColorUni.isValid()) { + // OpenGL ES doesn't support unsigned byte varieties of glUniform + GrGLfloat c[4]; + GrColorToRGBAFloat(color, c); + fProgramDataManager.set4fv(fBuiltinUniformHandles.fColorUni, 1, c); + fColor = color; + } + break; + case GrGLProgramDesc::kAllOnes_ColorInput: + // Handled by shader creation + break; + default: + SkFAIL("Unexpected color type."); } } -void GrGLProgram::setCoverage(const GrOptDrawState& optState, - GrColor coverage, - SharedGLState* sharedState) { +void GrGLProgram::setCoverage(const GrOptDrawState& optState, GrColor coverage) { const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); - if (!optState.hasCoverageVertexAttribute()) { - switch (header.fCoverageInput) { - case GrGLProgramDesc::kAttribute_ColorInput: - if (sharedState->fConstAttribCoverage != coverage || - sharedState->fConstAttribCoverageIndex != header.fCoverageAttributeIndex) { - // OpenGL ES only supports the float varieties of glVertexAttrib - GrGLfloat c[4]; - GrColorToRGBAFloat(coverage, c); - GL_CALL(VertexAttrib4fv(header.fCoverageAttributeIndex, c)); - sharedState->fConstAttribCoverage = coverage; - sharedState->fConstAttribCoverageIndex = header.fCoverageAttributeIndex; - } - break; - case GrGLProgramDesc::kUniform_ColorInput: - if (fCoverage != coverage) { - // OpenGL ES doesn't support unsigned byte varieties of glUniform - GrGLfloat c[4]; - GrColorToRGBAFloat(coverage, c); - fProgramDataManager.set4fv(fBuiltinUniformHandles.fCoverageUni, 1, c); - fCoverage = coverage; - } - sharedState->fConstAttribCoverageIndex = -1; - break; - case GrGLProgramDesc::kAllOnes_ColorInput: - sharedState->fConstAttribCoverageIndex = -1; - break; - default: - SkFAIL("Unexpected coverage type."); - } - } else { - sharedState->fConstAttribCoverageIndex = -1; + switch (header.fCoverageInput) { + case GrGLProgramDesc::kAttribute_ColorInput: + // Attribute case is handled in GrGpuGL::setupGeometry + break; + case GrGLProgramDesc::kUniform_ColorInput: + if (fCoverage != coverage) { + // OpenGL ES doesn't support unsigned byte varieties of glUniform + GrGLfloat c[4]; + GrColorToRGBAFloat(coverage, c); + fProgramDataManager.set4fv(fBuiltinUniformHandles.fCoverageUni, 1, c); + fCoverage = coverage; + } + break; + case GrGLProgramDesc::kAllOnes_ColorInput: + // Handled by shader creation + break; + default: + SkFAIL("Unexpected coverage type."); } } diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h index e8aef35f1d..ca75e206f1 100644 --- a/src/gpu/gl/GrGLProgram.h +++ b/src/gpu/gl/GrGLProgram.h @@ -60,27 +60,6 @@ public: virtual bool hasVertexShader() const { return true; } /** - * Some GL state that is relevant to programs is not stored per-program. In particular color - * and coverage attributes can be global state. This struct is read and updated by - * GrGLProgram::setColor and GrGLProgram::setCoverage to allow us to avoid setting this state - * redundantly. - */ - struct SharedGLState { - GrColor fConstAttribColor; - int fConstAttribColorIndex; - GrColor fConstAttribCoverage; - int fConstAttribCoverageIndex; - - SharedGLState() { this->invalidate(); } - void invalidate() { - fConstAttribColor = GrColor_ILLEGAL; - fConstAttribColorIndex = -1; - fConstAttribCoverage = GrColor_ILLEGAL; - fConstAttribCoverageIndex = -1; - } - }; - - /** * The GrDrawState's view matrix along with the aspects of the render target determine the * matrix sent to GL. The size of the render target affects the GL matrix because we must * convert from Skia device coords to GL's normalized coords. Also the origin of the render @@ -152,8 +131,7 @@ public: */ void setData(const GrOptDrawState&, GrGpu::DrawType, - const GrDeviceCoordTexture* dstCopy, // can be NULL - SharedGLState*); + const GrDeviceCoordTexture* dstCopy /* can be NULL*/); protected: typedef GrGLProgramDataManager::UniformHandle UniformHandle; @@ -173,11 +151,11 @@ protected: // Helper for setData(). Makes GL calls to specify the initial color when there is not // per-vertex colors. - void setColor(const GrOptDrawState&, GrColor color, SharedGLState*); + void setColor(const GrOptDrawState&, GrColor color); // Helper for setData(). Makes GL calls to specify the initial coverage when there is not // per-vertex coverages. - void setCoverage(const GrOptDrawState&, GrColor coverage, SharedGLState*); + void setCoverage(const GrOptDrawState&, GrColor coverage); // A templated helper to loop over effects, set the transforms(via subclass) and bind textures void setFragmentData(const GrOptDrawState&); diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 79088137ca..4a274c6bb1 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -257,25 +257,27 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; - if (gpu->caps()->pathRenderingSupport() && - GrGpu::IsPathRenderingDrawType(drawType) && - gpu->glPathRendering()->texturingMode() == GrGLPathRendering::FixedFunction_TexturingMode) { - header->fUseFragShaderOnly = true; + bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType); + if (gpu->caps()->pathRenderingSupport() && isPathRendering) { + header->fUseNvpr = true; SkASSERT(!optState.hasGeometryProcessor()); } else { - header->fUseFragShaderOnly = false; + header->fUseNvpr = false; } - bool defaultToUniformInputs = GrGpu::IsPathRenderingDrawType(drawType) || - GR_GL_NO_CONSTANT_ATTRIBUTES; + bool hasUniformColor = inputColorIsUsed && + (isPathRendering || !optState.hasColorVertexAttribute()); + + bool hasUniformCoverage = inputCoverageIsUsed && + (isPathRendering || !optState.hasCoverageVertexAttribute()); if (!inputColorIsUsed) { header->fColorInput = kAllOnes_ColorInput; - } else if (defaultToUniformInputs && !optState.hasColorVertexAttribute()) { + } else if (hasUniformColor) { header->fColorInput = kUniform_ColorInput; } else { header->fColorInput = kAttribute_ColorInput; - SkASSERT(!header->fUseFragShaderOnly); + SkASSERT(!header->fUseNvpr); } bool covIsSolidWhite = !optState.hasCoverageVertexAttribute() && @@ -283,11 +285,11 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, if (covIsSolidWhite || !inputCoverageIsUsed) { header->fCoverageInput = kAllOnes_ColorInput; - } else if (defaultToUniformInputs && !optState.hasCoverageVertexAttribute()) { + } else if (hasUniformCoverage) { header->fCoverageInput = kUniform_ColorInput; } else { header->fCoverageInput = kAttribute_ColorInput; - SkASSERT(!header->fUseFragShaderOnly); + SkASSERT(!header->fUseNvpr); } if (optState.readsDst()) { diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h index 4e1be5b2f9..d97bdfded5 100644 --- a/src/gpu/gl/GrGLProgramDesc.h +++ b/src/gpu/gl/GrGLProgramDesc.h @@ -94,7 +94,7 @@ private: // effects that read the fragment position. // Otherwise, 0. - SkBool8 fUseFragShaderOnly; + SkBool8 fUseNvpr; SkBool8 fEmitsPointSize; ColorInput fColorInput : 8; diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 7b892913c5..a85548ea64 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -342,7 +342,6 @@ void GrGpuGL::onResetContext(uint32_t resetBits) { if (resetBits & kProgram_GrGLBackendState) { fHWProgramID = 0; - fSharedGLProgramState.invalidate(); } } diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 973a568981..dc0d076a2d 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -288,8 +288,6 @@ private: int fHWActiveTextureUnitIdx; GrGLuint fHWProgramID; - GrGLProgram::SharedGLState fSharedGLProgramState; - enum TriState { kNo_TriState, kYes_TriState, diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index bf73f0059c..a1259c9bf8 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -256,7 +256,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type, this->flushBlend(*optState.get(), kDrawLines_DrawType == type, srcCoeff, dstCoeff); - fCurrentProgram->setData(*optState.get(), type, dstCopy, &fSharedGLProgramState); + fCurrentProgram->setData(*optState.get(), type, dstCopy); } GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState->getRenderTarget()); diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 28d1517423..65a7cdaa63 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -55,7 +55,9 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, // if we have a vertex shader(we don't only if we are using NVPR or NVPR ES), then we may have // to setup a few more things like builtin vertex attributes - bool hasVertexShader = !header.fUseFragShaderOnly; + bool hasVertexShader = !(header.fUseNvpr && + gpu->glPathRendering()->texturingMode() == + GrGLPathRendering::FixedFunction_TexturingMode); if (hasVertexShader) { pb->fVS.setupLocalCoords(); pb->fVS.transformGLToSkiaCoords(); @@ -92,18 +94,15 @@ GrGLProgramBuilder::CreateProgramBuilder(const GrGLProgramDesc& desc, GrGpu::DrawType drawType, bool hasGeometryProcessor, GrGpuGL* gpu) { - if (desc.getHeader().fUseFragShaderOnly) { + if (desc.getHeader().fUseNvpr) { SkASSERT(gpu->glCaps().pathRenderingSupport()); - SkASSERT(gpu->glPathRendering()->texturingMode() == - GrGLPathRendering::FixedFunction_TexturingMode); SkASSERT(!hasGeometryProcessor); - return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc)); - } else if (GrGpu::IsPathRenderingDrawType(drawType)) { - SkASSERT(gpu->glCaps().pathRenderingSupport()); - SkASSERT(gpu->glPathRendering()->texturingMode() == - GrGLPathRendering::SeparableShaders_TexturingMode); - SkASSERT(!hasGeometryProcessor); - return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); + if (gpu->glPathRendering()->texturingMode() == + GrGLPathRendering::FixedFunction_TexturingMode) { + return SkNEW_ARGS(GrGLLegacyNvprProgramBuilder, (gpu, optState, desc)); + } else { + return SkNEW_ARGS(GrGLNvprProgramBuilder, (gpu, optState, desc)); + } } else { return SkNEW_ARGS(GrGLProgramBuilder, (gpu, optState, desc)); } @@ -420,7 +419,9 @@ GrGLProgram* GrGLProgramBuilder::finalize() { this->cleanupProgram(programID, shadersToDelete); return NULL; } - if (!this->header().fUseFragShaderOnly) { + if (!(this->header().fUseNvpr && + fGpu->glPathRendering()->texturingMode() == + GrGLPathRendering::FixedFunction_TexturingMode)) { if (!fVS.compileAndAttachShaders(programID, &shadersToDelete)) { this->cleanupProgram(programID, shadersToDelete); return NULL; |