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/src@11138 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/gl/GrGLCaps.cpp b/gpu/gl/GrGLCaps.cpp
index 8ca88c1..aac9736 100644
--- a/gpu/gl/GrGLCaps.cpp
+++ b/gpu/gl/GrGLCaps.cpp
@@ -24,7 +24,6 @@
fStencilFormats.reset();
fStencilVerifiedColorConfigs.reset();
fMSFBOType = kNone_MSFBOType;
- fCoverageAAType = kNone_CoverageAAType;
fFBFetchType = kNone_FBFetchType;
fMaxFragmentUniformVectors = 0;
fMaxVertexAttributes = 0;
@@ -65,8 +64,6 @@
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 @@
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 @@
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<MSAACoverageMode, cov_mode_less> SortFunctor;
- SortFunctor sortFunctor;
- SkTQSort<MSAACoverageMode, SortFunctor>(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<const MSAACoverageMode, cov_mode_less>(&fMSAACoverageModes[0],
- fMSAACoverageModes.count(),
- desiredMode,
- sizeof(MSAACoverageMode));
- if (idx < 0) {
- idx = ~idx;
- }
- SkASSERT(idx >= 0 && idx < fMSAACoverageModes.count());
- return fMSAACoverageModes[idx];
}
}
diff --git a/gpu/gl/GrGLCaps.h b/gpu/gl/GrGLCaps.h
index 857ebbc..1eaae22 100644
--- a/gpu/gl/GrGLCaps.h
+++ b/gpu/gl/GrGLCaps.h
@@ -28,23 +28,6 @@
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 @@
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 @@
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 @@
int fMaxFixedFunctionTextureCoords;
MSFBOType fMSFBOType;
- CoverageAAType fCoverageAAType;
- SkTDArray<MSAACoverageMode> fMSAACoverageModes;
FBFetchType fFBFetchType;
diff --git a/gpu/gl/GrGpuGL.cpp b/gpu/gl/GrGpuGL.cpp
index 75b4191..bc067e0 100644
--- a/gpu/gl/GrGpuGL.cpp
+++ b/gpu/gl/GrGpuGL.cpp
@@ -768,27 +768,12 @@
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 @@
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/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp b/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
index 1b44900..a71922e 100644
--- a/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
+++ b/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp
@@ -123,9 +123,6 @@
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/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
index e6f1d1f..e9207b1 100644
--- a/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
+++ b/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
@@ -180,9 +180,6 @@
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/utils/win/SkWGL_win.cpp b/utils/win/SkWGL_win.cpp
index 4b3b3e6..ac77c56 100644
--- a/utils/win/SkWGL_win.cpp
+++ b/utils/win/SkWGL_win.cpp
@@ -79,19 +79,14 @@
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 @@
0,
desiredSampleCount,
0,
- 0,
};
SkTDArray<PixelFormat> 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 @@
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 @@
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);