Clamp requested MSAA sample count to GL_MAX_SAMPLES

Review URL: http://codereview.appspot.com/6135044/



git-svn-id: http://skia.googlecode.com/svn/trunk@3777 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2012-04-27 14:25:44 +00:00
parent e9b087e958
commit f6b070da5e
3 changed files with 15 additions and 0 deletions

View File

@ -20,6 +20,7 @@ void GrGLCaps::reset() {
fStencilFormats.reset();
fStencilVerifiedColorConfigs.reset();
fMSFBOType = kNone_MSFBOType;
fMaxSampleCount = 0;
fCoverageAAType = kNone_CoverageAAType;
fMaxFragmentUniformVectors = 0;
fRGBA8RenderbufferSupport = false;
@ -45,6 +46,7 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
fMSFBOType = caps.fMSFBOType;
fMaxSampleCount = caps.fMaxSampleCount;
fCoverageAAType = caps.fCoverageAAType;
fMSAACoverageModes = caps.fMSAACoverageModes;
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
@ -206,6 +208,11 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
compareProc);
}
}
if (kNone_MSFBOType != fMSFBOType) {
GR_GL_GetIntegerv(ctxInfo.interface(),
GR_GL_MAX_SAMPLES,
&fMaxSampleCount);
}
}
const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(

View File

@ -136,6 +136,11 @@ public:
*/
MSFBOType msFBOType() const { return fMSFBOType; }
/**
* Reports the maximum number of samples supported.
*/
int maxSampleCount() const { return fMaxSampleCount; }
/**
* Reports the type of coverage sample AA support.
*/
@ -257,6 +262,7 @@ private:
int fMaxFragmentUniformVectors;
MSFBOType fMSFBOType;
int fMaxSampleCount;
CoverageAAType fCoverageAAType;
SkTDArray<MSAACoverageMode> fMSAACoverageModes;

View File

@ -866,6 +866,8 @@ bool renderbuffer_storage_msaa(GrGLContextInfo& ctxInfo,
created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
}
if (!created) {
// glRBMS will fail if requested samples is > max samples.
sampleCount = GrMin(sampleCount, ctxInfo.caps().maxSampleCount());
GL_ALLOC_CALL(ctxInfo.interface(),
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
sampleCount,