From 040fd8f5670c8a4f73e0fe13f949681a23e6add8 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Fri, 6 Sep 2013 20:00:41 +0000 Subject: [PATCH] Rip out CSAA support R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://chromiumcodereview.appspot.com/23882009 git-svn-id: http://skia.googlecode.com/svn/trunk@11138 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/gpu/gl/GrGLFunctions.h | 1 - include/gpu/gl/GrGLInterface.h | 1 - include/utils/SkWGL.h | 2 - src/gpu/gl/GrGLCaps.cpp | 60 ------------- src/gpu/gl/GrGLCaps.h | 45 ---------- src/gpu/gl/GrGpuGL.cpp | 86 ++++++++----------- .../unix/GrGLCreateNativeInterface_unix.cpp | 3 - .../gl/win/GrGLCreateNativeInterface_win.cpp | 3 - src/utils/win/SkWGL_win.cpp | 50 +++-------- 9 files changed, 46 insertions(+), 205 deletions(-) diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h index b949d1d39a..4908f14a1e 100644 --- a/include/gpu/gl/GrGLFunctions.h +++ b/include/gpu/gl/GrGLFunctions.h @@ -129,7 +129,6 @@ extern "C" { typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); - typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLRenderbufferStorageMultisampleCoverageProc)(GrGLenum target, GrGLsizei coverageSamples, GrGLsizei colorSamples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLResolveMultisampleFramebufferProc)(); typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height); #if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h index de1b29143f..b4d3f793fd 100644 --- a/include/gpu/gl/GrGLInterface.h +++ b/include/gpu/gl/GrGLInterface.h @@ -254,7 +254,6 @@ public: // the standard function in ES3+ or GL 3.0+. GLPtr fRenderbufferStorageMultisample; - GLPtr fRenderbufferStorageMultisampleCoverage; GLPtr fResolveMultisampleFramebuffer; GLPtr fScissor; GLPtr fShaderSource; diff --git a/include/utils/SkWGL.h b/include/utils/SkWGL.h index 3d941742bf..6803e036e5 100644 --- a/include/utils/SkWGL.h +++ b/include/utils/SkWGL.h @@ -43,8 +43,6 @@ #define SK_WGL_FULL_ACCELERATION 0x2027 #define SK_WGL_SAMPLE_BUFFERS 0x2041 #define SK_WGL_SAMPLES 0x2042 -#define SK_WGL_COVERAGE_SAMPLES 0x2042 /* same as SAMPLES */ -#define SK_WGL_COLOR_SAMPLES 0x20B9 #define SK_WGL_CONTEXT_MAJOR_VERSION 0x2091 #define SK_WGL_CONTEXT_MINOR_VERSION 0x2092 #define SK_WGL_CONTEXT_LAYER_PLANE 0x2093 diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 8ca88c14aa..aac97361f8 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -24,7 +24,6 @@ void GrGLCaps::reset() { fStencilFormats.reset(); fStencilVerifiedColorConfigs.reset(); fMSFBOType = kNone_MSFBOType; - fCoverageAAType = kNone_CoverageAAType; fFBFetchType = kNone_FBFetchType; fMaxFragmentUniformVectors = 0; fMaxVertexAttributes = 0; @@ -65,8 +64,6 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) { fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; fMSFBOType = caps.fMSFBOType; - fCoverageAAType = caps.fCoverageAAType; - fMSAACoverageModes = caps.fMSAACoverageModes; fFBFetchType = caps.fFBFetchType; fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; fBGRAFormatSupport = caps.fBGRAFormatSupport; @@ -368,20 +365,6 @@ bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; } -namespace { -bool cov_mode_less(const GrGLCaps::MSAACoverageMode& left, - const GrGLCaps::MSAACoverageMode& right) { - if (left.fCoverageSampleCnt < right.fCoverageSampleCnt) { - return true; - } else if (right.fCoverageSampleCnt < left.fCoverageSampleCnt) { - return false; - } else if (left.fColorSampleCnt < right.fColorSampleCnt) { - return true; - } - return false; -} -} - void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { fMSFBOType = kNone_MSFBOType; @@ -409,49 +392,6 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType; } - // TODO: We could populate fMSAACoverageModes using GetInternalformativ - // on GL 4.2+. It's format-specific, though. See also - // http://code.google.com/p/skia/issues/detail?id=470 about using actual - // rather than requested sample counts in cache key. - if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) { - fCoverageAAType = kNVDesktop_CoverageAAType; - GrGLint count; - GR_GL_GetIntegerv(gli, - GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES, - &count); - fMSAACoverageModes.setCount(count); - GR_GL_GetIntegerv(gli, - GR_GL_MULTISAMPLE_COVERAGE_MODES, - (int*)&fMSAACoverageModes[0]); - // The NV driver seems to return the modes already sorted but the - // spec doesn't require this. So we sort. - typedef SkTLessFunctionToFunctorAdaptor SortFunctor; - SortFunctor sortFunctor; - SkTQSort(fMSAACoverageModes.begin(), - fMSAACoverageModes.end() - 1, - sortFunctor); - } - } -} - -const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampleCount) const { - static const MSAACoverageMode kNoneMode = {0, 0}; - if (0 == fMSAACoverageModes.count()) { - return kNoneMode; - } else { - SkASSERT(kNone_CoverageAAType != fCoverageAAType); - int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt; - desiredSampleCount = GrMin(desiredSampleCount, max); - MSAACoverageMode desiredMode = {desiredSampleCount, 0}; - int idx = SkTSearch(&fMSAACoverageModes[0], - fMSAACoverageModes.count(), - desiredMode, - sizeof(MSAACoverageMode)); - if (idx < 0) { - idx = ~idx; - } - SkASSERT(idx >= 0 && idx < fMSAACoverageModes.count()); - return fMSAACoverageModes[idx]; } } diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 857ebbc101..1eaae2287b 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -27,23 +27,6 @@ public: typedef GrGLStencilBuffer::Format StencilFormat; - /** - * Represents a supported multisampling/coverage-sampling mode. - */ - struct MSAACoverageMode { - // "Coverage samples" includes samples that actually have color, depth, - // stencil, ... as well as those that don't (coverage only). All samples - // are coverage samples. (We're using the word "coverage sample" to - // match the NV extension language.) - int fCoverageSampleCnt; - - // Color samples are samples that store data values (color, stencil, - // depth) rather than just representing coverage. They are a subset - // of coverage samples. (Again the wording was chosen to match the - // extension.) - int fColorSampleCnt; - }; - /** * The type of MSAA for FBOs supported. Different extensions have different * semantics of how / when a resolve is performed. @@ -95,18 +78,6 @@ public: kLast_FBFetchType = kNV_FBFetchType, }; - enum CoverageAAType { - /** - * No coverage sample support - */ - kNone_CoverageAAType, - - /** - * GL_NV_framebuffer_multisample_coverage - */ - kNVDesktop_CoverageAAType, - }; - /** * Creates a GrGLCaps that advertises no support for any extensions, * formats, etc. Call init to initialize from a GrGLContextInfo. @@ -186,20 +157,6 @@ public: kES_EXT_MsToTexture_MSFBOType == fMSFBOType; } - /** - * Reports the type of coverage sample AA support. - */ - CoverageAAType coverageAAType() const { return fCoverageAAType; } - - /** - * Chooses a supported coverage mode based on a desired sample count. The - * desired sample count is rounded up the next supported coverage sample - * count unless a it is larger than the max in which case it is rounded - * down. Once a coverage sample count is decided, the supported mode with - * the fewest color samples is chosen. - */ - const MSAACoverageMode& getMSAACoverageMode(int desiredSampleCount) const; - FBFetchType fbFetchType() const { return fFBFetchType; } /** @@ -348,8 +305,6 @@ private: int fMaxFixedFunctionTextureCoords; MSFBOType fMSFBOType; - CoverageAAType fCoverageAAType; - SkTDArray fMSAACoverageModes; FBFetchType fFBFetchType; diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 75b4191366..bc067e0062 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -768,27 +768,12 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, return succeeded; } -namespace { -bool renderbuffer_storage_msaa(GrGLContext& ctx, - int sampleCount, - GrGLenum format, - int width, int height) { +static bool renderbuffer_storage_msaa(GrGLContext& ctx, + int sampleCount, + GrGLenum format, + int width, int height) { CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.info().caps()->msFBOType()); - bool created = false; - if (GrGLCaps::kNVDesktop_CoverageAAType == - ctx.info().caps()->coverageAAType()) { - const GrGLCaps::MSAACoverageMode& mode = - ctx.info().caps()->getMSAACoverageMode(sampleCount); - GL_ALLOC_CALL(ctx.interface(), - RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER, - mode.fCoverageSampleCnt, - mode.fColorSampleCnt, - format, - width, height)); - created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); - } - if (!created) { #if GR_GL_IGNORE_ES3_MSAA GL_ALLOC_CALL(ctx.interface(), RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, @@ -796,40 +781,37 @@ bool renderbuffer_storage_msaa(GrGLContext& ctx, format, width, height)); #else - switch (ctx.info().caps()->msFBOType()) { - case GrGLCaps::kDesktop_ARB_MSFBOType: - case GrGLCaps::kDesktop_EXT_MSFBOType: - case GrGLCaps::kES_3_0_MSFBOType: - GL_ALLOC_CALL(ctx.interface(), - RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, - sampleCount, - format, - width, height)); - break; - case GrGLCaps::kES_Apple_MSFBOType: - GL_ALLOC_CALL(ctx.interface(), - RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERBUFFER, - sampleCount, - format, - width, height)); - break; - case GrGLCaps::kES_EXT_MsToTexture_MSFBOType: - case GrGLCaps::kES_IMG_MsToTexture_MSFBOType: - GL_ALLOC_CALL(ctx.interface(), - RenderbufferStorageMultisampleES2EXT(GR_GL_RENDERBUFFER, - sampleCount, - format, - width, height)); - break; - case GrGLCaps::kNone_MSFBOType: - GrCrash("Shouldn't be here if we don't support multisampled renderbuffers."); - break; - } -#endif - created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); + switch (ctx.info().caps()->msFBOType()) { + case GrGLCaps::kDesktop_ARB_MSFBOType: + case GrGLCaps::kDesktop_EXT_MSFBOType: + case GrGLCaps::kES_3_0_MSFBOType: + GL_ALLOC_CALL(ctx.interface(), + RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, + sampleCount, + format, + width, height)); + break; + case GrGLCaps::kES_Apple_MSFBOType: + GL_ALLOC_CALL(ctx.interface(), + RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERBUFFER, + sampleCount, + format, + width, height)); + break; + case GrGLCaps::kES_EXT_MsToTexture_MSFBOType: + case GrGLCaps::kES_IMG_MsToTexture_MSFBOType: + GL_ALLOC_CALL(ctx.interface(), + RenderbufferStorageMultisampleES2EXT(GR_GL_RENDERBUFFER, + sampleCount, + format, + width, height)); + break; + case GrGLCaps::kNone_MSFBOType: + GrCrash("Shouldn't be here if we don't support multisampled renderbuffers."); + break; } - return created; -} +#endif + return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; } bool GrGpuGL::createRenderTargetObjects(int width, int height, diff --git a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp index 1b44900b1a..a71922e012 100644 --- a/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp +++ b/src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp @@ -123,9 +123,6 @@ const GrGLInterface* GrGLCreateNativeInterface() { interface->fPixelStorei = glPixelStorei; interface->fReadBuffer = glReadBuffer; interface->fReadPixels = glReadPixels; - if (extensions.has("GL_NV_framebuffer_multisample_coverage")) { - GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisampleCoverage, NV); - } interface->fScissor = glScissor; GR_GL_GET_PROC(ShaderSource); interface->fStencilFunc = glStencilFunc; diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp index e6f1d1f81b..e9207b162a 100644 --- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp +++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp @@ -180,9 +180,6 @@ const GrGLInterface* GrGLCreateNativeInterface() { WGL_SET_PROC(GetStringi) WGL_SET_PROC(GetUniformLocation); WGL_SET_PROC(LinkProgram); - if (extensions.has("GL_NV_framebuffer_multisample_coverage")) { - WGL_SET_PROC_SUFFIX(RenderbufferStorageMultisampleCoverage, NV); - } WGL_SET_PROC(ShaderSource); WGL_SET_PROC(StencilFuncSeparate); WGL_SET_PROC(StencilMaskSeparate); diff --git a/src/utils/win/SkWGL_win.cpp b/src/utils/win/SkWGL_win.cpp index 4b3b3e63ae..ac77c56288 100644 --- a/src/utils/win/SkWGL_win.cpp +++ b/src/utils/win/SkWGL_win.cpp @@ -79,19 +79,14 @@ namespace { struct PixelFormat { int fFormat; - int fCoverageSamples; - int fColorSamples; + int fSampleCnt; int fChoosePixelFormatRank; }; bool pf_less(const PixelFormat& a, const PixelFormat& b) { - if (a.fCoverageSamples < b.fCoverageSamples) { + if (a.fSampleCnt < b.fSampleCnt) { return true; - } else if (b.fCoverageSamples < a.fCoverageSamples) { - return false; - } else if (a.fColorSamples < b.fColorSamples) { - return true; - } else if (b.fColorSamples < a.fColorSamples) { + } else if (b.fSampleCnt < a.fSampleCnt) { return false; } else if (a.fChoosePixelFormatRank < b.fChoosePixelFormatRank) { return true; @@ -108,31 +103,20 @@ int SkWGLExtensions::selectFormat(const int formats[], 0, desiredSampleCount, 0, - 0, }; SkTDArray rankedFormats; rankedFormats.setCount(formatCount); - bool supportsCoverage = this->hasExtension(dc, - "WGL_NV_multisample_coverage"); for (int i = 0; i < formatCount; ++i) { - static const int queryAttrs[] = { - SK_WGL_COVERAGE_SAMPLES, - // Keep COLOR_SAMPLES at the end so it can be skipped - SK_WGL_COLOR_SAMPLES, - }; - int answers[2]; - int queryAttrCnt = supportsCoverage ? - SK_ARRAY_COUNT(queryAttrs) : - SK_ARRAY_COUNT(queryAttrs) - 1; + static const int kQueryAttr = SK_WGL_SAMPLES; + int numSamples; this->getPixelFormatAttribiv(dc, formats[i], 0, - queryAttrCnt, - queryAttrs, - answers); + 1, + &kQueryAttr, + &numSamples); rankedFormats[i].fFormat = formats[i]; - rankedFormats[i].fCoverageSamples = answers[0]; - rankedFormats[i].fColorSamples = answers[supportsCoverage ? 1 : 0]; + rankedFormats[i].fSampleCnt = numSamples; rankedFormats[i].fChoosePixelFormatRank = i; } SkTQSort(rankedFormats.begin(), @@ -289,7 +273,7 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool preferCoreProfile) { if (msaaSampleCount > 0 && extensions.hasExtension(dc, "WGL_ARB_multisample")) { static const int kIAttrsCount = SK_ARRAY_COUNT(iAttrs); - int msaaIAttrs[kIAttrsCount + 6]; + int msaaIAttrs[kIAttrsCount + 4]; memcpy(msaaIAttrs, iAttrs, sizeof(int) * kIAttrsCount); SkASSERT(0 == msaaIAttrs[kIAttrsCount - 2] && 0 == msaaIAttrs[kIAttrsCount - 1]); @@ -297,18 +281,8 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool preferCoreProfile) { msaaIAttrs[kIAttrsCount - 1] = TRUE; msaaIAttrs[kIAttrsCount + 0] = SK_WGL_SAMPLES; msaaIAttrs[kIAttrsCount + 1] = msaaSampleCount; - if (extensions.hasExtension(dc, "WGL_NV_multisample_coverage")) { - msaaIAttrs[kIAttrsCount + 2] = SK_WGL_COLOR_SAMPLES; - // We want the fewest number of color samples possible. - // Passing 0 gives only the formats where all samples are color - // samples. - msaaIAttrs[kIAttrsCount + 3] = 1; - msaaIAttrs[kIAttrsCount + 4] = 0; - msaaIAttrs[kIAttrsCount + 5] = 0; - } else { - msaaIAttrs[kIAttrsCount + 2] = 0; - msaaIAttrs[kIAttrsCount + 3] = 0; - } + msaaIAttrs[kIAttrsCount + 2] = 0; + msaaIAttrs[kIAttrsCount + 3] = 0; unsigned int num; int formats[64]; extensions.choosePixelFormat(dc, msaaIAttrs, fAttrs, 64, formats, &num);