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
This commit is contained in:
commit-bot@chromium.org 2013-09-06 20:00:41 +00:00
parent 96a7a9623f
commit 040fd8f567
9 changed files with 46 additions and 205 deletions

View File

@ -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

View File

@ -254,7 +254,6 @@ public:
// the standard function in ES3+ or GL 3.0+.
GLPtr<GrGLRenderbufferStorageMultisampleProc> fRenderbufferStorageMultisample;
GLPtr<GrGLRenderbufferStorageMultisampleCoverageProc> fRenderbufferStorageMultisampleCoverage;
GLPtr<GrGLResolveMultisampleFramebufferProc> fResolveMultisampleFramebuffer;
GLPtr<GrGLScissorProc> fScissor;
GLPtr<GrGLShaderSourceProc> fShaderSource;

View File

@ -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

View File

@ -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<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];
}
}

View File

@ -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<MSAACoverageMode> fMSAACoverageModes;
FBFetchType fFBFetchType;

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -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<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 @@ 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);