Revert of Enable stencil clipping in mixed sampled render targets (patchset #6 id...
authorcdalton <cdalton@nvidia.com>
Wed, 11 Nov 2015 23:16:07 +0000 (15:16 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 11 Nov 2015 23:16:07 +0000 (15:16 -0800)
Reason for revert:
Co-centered sample locations are not needed to do stencil clip with mixed samples

Original issue's description:
> Implement stencil clipping in mixed sampled render targets
>
> This change enables multisampled clipping for mixed sampled
> render targets.  Previously clipping in mixed samples config
> behaved the same as in the gpu config.
>
> In order to retrofit non-MSAA draw methods, programmable sample
> locations are used in order to colocate all samples at (0.5, 0.5).
> Requires support for NV_sample_locations.
>
> BUG=skia:4399
>
> Committed:
> https://skia.googlesource.com/skia/+/3e77ba96d56d15db30ac6d8ccb900e30aafcbb16

BUG=skia:

Review URL: https://codereview.chromium.org/1415873011

13 files changed:
include/gpu/GrCaps.h
include/gpu/gl/GrGLFunctions.h
include/gpu/gl/GrGLInterface.h
src/gpu/GrCaps.cpp
src/gpu/GrClipMaskManager.cpp
src/gpu/gl/GrGLAssembleInterface.cpp
src/gpu/gl/GrGLCaps.cpp
src/gpu/gl/GrGLDefines.h
src/gpu/gl/GrGLGpu.cpp
src/gpu/gl/GrGLGpu.h
src/gpu/gl/GrGLInterface.cpp
src/gpu/gl/GrGLPathRendering.cpp
src/gpu/gl/GrGLRenderTarget.h

index 2ee7a37..6d3b66a 100644 (file)
@@ -62,7 +62,6 @@ public:
     bool pathRenderingSupport() const { return fPathRenderingSupport; }
     bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
     bool dualSourceBlendingSupport() const { return fDualSourceBlendingSupport; }
-    bool programmableSampleLocationsSupport() const { return fProgrammableSampleLocationsSupport; }
 
     /**
     * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a
@@ -92,7 +91,6 @@ protected:
     bool fPathRenderingSupport : 1;
     bool fDstReadInShaderSupport : 1;
     bool fDualSourceBlendingSupport : 1;
-    bool fProgrammableSampleLocationsSupport : 1;
 
     bool fShaderPrecisionVaries;
     PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][kGrSLPrecisionCount];
index 5fbbc2f..6be48bc 100644 (file)
@@ -339,8 +339,6 @@ typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetVertexArrayIntegeri_vProc)(GrGLuin
 typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLGetVertexArrayPointeri_vProc)(GrGLuint vaobj, GrGLuint index, GrGLenum pname, GrGLvoid **param);
 typedef GrGLvoid* (GR_GL_FUNCTION_TYPE* GrGLMapNamedBufferRangeProc)(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length, GrGLbitfield access);
 typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLFlushMappedNamedBufferRangeProc)(GrGLuint buffer, GrGLintptr offset, GrGLsizeiptr length);
-// OpenGL 4.5
-typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLNamedFramebufferParameteriProc)(GrGLuint framebuffer, GrGLenum pname, GrGLint param);
 
 /* KHR_debug */
 typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDebugMessageControlProc)(GrGLenum source, GrGLenum type, GrGLenum severity, GrGLsizei count, const GrGLuint* ids, GrGLboolean enabled);
index 8a7abbf..808a3be 100644 (file)
@@ -489,8 +489,6 @@ public:
         GLPtr<GrGLGetVertexArrayPointeri_vProc> fGetVertexArrayPointeri_v;
         GLPtr<GrGLMapNamedBufferRangeProc> fMapNamedBufferRange;
         GLPtr<GrGLFlushMappedNamedBufferRangeProc> fFlushMappedNamedBufferRange;
-        // OpenGL 4.5
-        GLPtr<GrGLNamedFramebufferParameteriProc> fNamedFramebufferParameteri;
 
         /* KHR_debug */
         GLPtr<GrGLDebugMessageControlProc> fDebugMessageControl;
index e4f81ab..7003cc5 100644 (file)
@@ -15,7 +15,6 @@ GrShaderCaps::GrShaderCaps() {
     fPathRenderingSupport = false;
     fDstReadInShaderSupport = false;
     fDualSourceBlendingSupport = false;
-    fProgrammableSampleLocationsSupport = false;
     fShaderPrecisionVaries = false;
 }
 
@@ -46,14 +45,13 @@ static const char* precision_to_string(GrSLPrecision p) {
 SkString GrShaderCaps::dump() const {
     SkString r;
     static const char* gNY[] = { "NO", "YES" };
-    r.appendf("Shader Derivative Support             : %s\n", gNY[fShaderDerivativeSupport]);
-    r.appendf("Geometry Shader Support               : %s\n", gNY[fGeometryShaderSupport]);
-    r.appendf("Path Rendering Support                : %s\n", gNY[fPathRenderingSupport]);
-    r.appendf("Dst Read In Shader Support            : %s\n", gNY[fDstReadInShaderSupport]);
-    r.appendf("Dual Source Blending Support          : %s\n", gNY[fDualSourceBlendingSupport]);
-    r.appendf("Programmable Sample Locations Support : %s\n", gNY[fProgrammableSampleLocationsSupport]);
-
-    r.appendf("Shader Float Precisions (varies: %s)  :\n", gNY[fShaderPrecisionVaries]);
+    r.appendf("Shader Derivative Support          : %s\n", gNY[fShaderDerivativeSupport]);
+    r.appendf("Geometry Shader Support            : %s\n", gNY[fGeometryShaderSupport]);
+    r.appendf("Path Rendering Support             : %s\n", gNY[fPathRenderingSupport]);
+    r.appendf("Dst Read In Shader Support         : %s\n", gNY[fDstReadInShaderSupport]);
+    r.appendf("Dual Source Blending Support       : %s\n", gNY[fDualSourceBlendingSupport]);
+
+    r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVaries]);
 
     for (int s = 0; s < kGrShaderTypeCount; ++s) {
         GrShaderType shaderType = static_cast<GrShaderType>(s);
index 3e802d7..efd48b9 100644 (file)
@@ -369,7 +369,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
     }
 
     // If MSAA is enabled we can do everything in the stencil buffer.
-    if (0 == rt->numStencilSamples() && requiresAA) {
+    if (0 == rt->numColorSamples() && requiresAA) {
         SkAutoTUnref<GrTexture> result;
 
         // The top-left of the mask corresponds to the top-left corner of the bounds.
@@ -707,7 +707,7 @@ bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
             pipelineBuilder.setDisableColorXPFactory();
 
             // if the target is MSAA then we want MSAA enabled when the clip is soft
-            if (rt->isStencilBufferMultisampled()) {
+            if (rt->isUnifiedMultisampled()) {
                 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, element->isAA());
             }
 
index c4d3e13..1cb721b 100644 (file)
@@ -451,10 +451,6 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
         }
     }
 
-    if (glVer >= GR_GL_VER(4,5)) {
-        GET_PROC(NamedFramebufferParameteri);
-    }
-
     if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_KHR_debug")) {
         // KHR_debug defines these methods to have no suffix in an OpenGL (not ES) context.
         GET_PROC(DebugMessageControl);
index 883a809..28401fe 100644 (file)
@@ -301,10 +301,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
             ctxInfo.hasExtension("GL_OES_standard_derivatives");
     }
 
-    glslCaps->fProgrammableSampleLocationsSupport =
-        ctxInfo.hasExtension("GL_NV_sample_locations") ||
-        ctxInfo.hasExtension("GL_ARB_sample_locations");
-
     /**************************************************************************
      * GrCaps fields
      **************************************************************************/
index 89ff56b..cc588b9 100644 (file)
 #define GR_GL_MULTISAMPLE_RASTERIZATION_ALLOWED             0x932B
 #define GR_GL_EFFECTIVE_RASTER_SAMPLES                      0x932C
 
-/* GL_NV_sample_locations and GL_ARB_sample_locations */
-#define GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS     0x9342
-
 /* GL_KHR_debug */
 #define GR_GL_DEBUG_OUTPUT                                  0x92E0
 #define GR_GL_DEBUG_OUTPUT_SYNCHRONOUS                      0x8242
index babc966..2bd36b6 100644 (file)
@@ -1500,7 +1500,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) {
     GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
     this->flushStencil(pipeline.getStencil());
     this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin());
-    this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled());
+    this->flushHWAAState(glRT, pipeline.isHWAntialiasState());
 
     // This must come after textures are flushed because a texture may need
     // to be msaa-resolved (which will modify bound FBO state).
@@ -2034,22 +2034,6 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
     return true;
 }
 
-void GrGLGpu::setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedSampleLocations) {
-    GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt->asRenderTarget());
-    SkASSERT(0 != target->renderFBOID());
-
-    if (!rt->isStencilBufferMultisampled() ||
-        useColocatedSampleLocations == target->usesColocatedSampleLocations()) {
-        return;
-    }
-
-    GL_CALL(NamedFramebufferParameteri(target->renderFBOID(),
-                                       GR_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS,
-                                       useColocatedSampleLocations));
-
-    target->flagAsUsingColocatedSampleLocations(useColocatedSampleLocations);
-}
-
 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound) {
 
     SkASSERT(target);
@@ -2297,19 +2281,9 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) {
     }
 }
 
-void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled) {
+void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
     SkASSERT(!useHWAA || rt->isStencilBufferMultisampled());
 
-    if (rt->hasMixedSamples() && stencilEnabled &&
-        this->glCaps().glslCaps()->programmableSampleLocationsSupport()) {
-        if (useHWAA) {
-            this->setColocatedSampleLocations(rt, false);
-        } else {
-            this->setColocatedSampleLocations(rt, true);
-        }
-        useHWAA = true;
-    }
-
     if (this->glCaps().multisampleDisableSupport()) {
         if (useHWAA) {
             if (kYes_TriState != fMSAAEnabled) {
@@ -3111,7 +3085,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
     this->flushBlend(blendInfo);
     this->flushColorWrite(true);
     this->flushDrawFace(GrPipelineBuilder::kBoth_DrawFace);
-    this->flushHWAAState(dstRT, false, false);
+    this->flushHWAAState(dstRT, false);
     this->disableScissor();
     GrStencilSettings stencil;
     stencil.setDisabled();
index e1db430..c8da150 100644 (file)
@@ -269,16 +269,12 @@ private:
     // ensures that such operations don't negatively interact with tracking bound textures.
     void setScratchTextureUnit();
 
-    // colocates all samples at pixel center for render target, if MSAA.
-    // allows drawing coverage based AA shapes in MSAA mode.
-    void setColocatedSampleLocations(GrRenderTarget* rt, bool useColocatedSampleLocations);
-
     // bounds is region that may be modified and therefore has to be resolved.
     // nullptr means whole target. Can be an empty rect.
     void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds);
 
     void flushStencil(const GrStencilSettings&);
-    void flushHWAAState(GrRenderTarget* rt, bool useHWAA, bool stencilEnabled);
+    void flushHWAAState(GrRenderTarget* rt, bool useHWAA);
 
     bool configToGLFormats(GrPixelConfig config,
                            bool getSizedInternal,
index 71de952..7ffa6a1 100644 (file)
@@ -713,12 +713,6 @@ bool GrGLInterface::validate() const {
         }
     }
 
-    if (kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,5)) {
-        if (nullptr == fFunctions.fNamedFramebufferParameteri) {
-            RETURN_FALSE_INTERFACE
-        }
-    }
-
     if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
         fExtensions.has("GL_KHR_debug")) {
         if (nullptr == fFunctions.fDebugMessageControl ||
index f18a4c6..4c9ef86 100644 (file)
@@ -100,7 +100,7 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath*
     SkISize size = SkISize::Make(rt->width(), rt->height());
     this->setProjectionMatrix(*args.fViewMatrix, size, rt->origin());
     gpu->flushScissor(*args.fScissor, rt->getViewport(), rt->origin());
-    gpu->flushHWAAState(rt, args.fUseHWAA, true);
+    gpu->flushHWAAState(rt, args.fUseHWAA);
     gpu->flushRenderTarget(rt, nullptr);
 
     const GrGLPath* glPath = static_cast<const GrGLPath*>(path);
index ce04ae0..d1365ef 100644 (file)
@@ -70,21 +70,6 @@ public:
     // components seperately.
     void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
 
-    /**
-     * @return true if sample locations colocated at pixel center have been set for this
-     *         render target.  Requires support for NV_sample_locations.
-     */
-    bool usesColocatedSampleLocations() const {
-        return fUsesColocatedSampleLocations;
-    }
-
-    /**
-     * Flag render target as using or not using sample locations colocated at pixel center.
-     */
-    void flagAsUsingColocatedSampleLocations(bool useColocatedSampleLocations) {
-        fUsesColocatedSampleLocations = useColocatedSampleLocations;
-    }
-
 protected:
     // The public constructor registers this object with the cache. However, only the most derived
     // class should register with the cache. This constructor does not do the registration and
@@ -131,10 +116,6 @@ private:
     // release zero out the IDs and the cache needs to know the size even after those actions.
     size_t      fGpuMemorySize;
 
-    // True if sample locations colocated at pixel center are currently in use, false if default
-    // sample locations are currently in use.
-    bool        fUsesColocatedSampleLocations;
-
     typedef GrRenderTarget INHERITED;
 };