Add MSAA configs to bench.
Review URL: https://codereview.chromium.org/12607013 git-svn-id: http://skia.googlecode.com/svn/trunk@8217 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
8c3f84d13f
commit
8a70eef71c
@ -193,7 +193,7 @@ enum Backend {
|
||||
};
|
||||
|
||||
static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
|
||||
Backend backend, GrContext* context) {
|
||||
Backend backend, int sampleCount, GrContext* context) {
|
||||
SkDevice* device = NULL;
|
||||
SkBitmap bitmap;
|
||||
bitmap.setConfig(config, size.fX, size.fY);
|
||||
@ -211,6 +211,7 @@ static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
|
||||
desc.fFlags = kRenderTarget_GrTextureFlagBit;
|
||||
desc.fWidth = size.fX;
|
||||
desc.fHeight = size.fY;
|
||||
desc.fSampleCnt = sampleCount;
|
||||
SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0));
|
||||
if (!texture) {
|
||||
return NULL;
|
||||
@ -238,21 +239,25 @@ static const GLContextType kDontCareGLCtxType = 0;
|
||||
static const struct {
|
||||
SkBitmap::Config fConfig;
|
||||
const char* fName;
|
||||
int fSampleCnt;
|
||||
Backend fBackend;
|
||||
GLContextType fContextType;
|
||||
bool fRunByDefault;
|
||||
} gConfigs[] = {
|
||||
{ SkBitmap::kNo_Config, "NONRENDERING", kNonRendering_Backend, kDontCareGLCtxType },
|
||||
{ SkBitmap::kARGB_8888_Config, "8888", kRaster_Backend, kDontCareGLCtxType },
|
||||
{ SkBitmap::kRGB_565_Config, "565", kRaster_Backend, kDontCareGLCtxType },
|
||||
{ SkBitmap::kNo_Config, "NONRENDERING", 0, kNonRendering_Backend, kDontCareGLCtxType, true },
|
||||
{ SkBitmap::kARGB_8888_Config, "8888", 0, kRaster_Backend, kDontCareGLCtxType, true },
|
||||
{ SkBitmap::kRGB_565_Config, "565", 0, kRaster_Backend, kDontCareGLCtxType, true },
|
||||
#if SK_SUPPORT_GPU
|
||||
{ SkBitmap::kARGB_8888_Config, "GPU", kGPU_Backend, GrContextFactory::kNative_GLContextType },
|
||||
{ SkBitmap::kARGB_8888_Config, "GPU", 0, kGPU_Backend, GrContextFactory::kNative_GLContextType, true },
|
||||
{ SkBitmap::kARGB_8888_Config, "MSAA4", 4, kGPU_Backend, GrContextFactory::kNative_GLContextType, false },
|
||||
{ SkBitmap::kARGB_8888_Config, "MSAA16", 16, kGPU_Backend, GrContextFactory::kNative_GLContextType, false },
|
||||
#if SK_ANGLE
|
||||
{ SkBitmap::kARGB_8888_Config, "ANGLE", kGPU_Backend, GrContextFactory::kANGLE_GLContextType },
|
||||
{ SkBitmap::kARGB_8888_Config, "ANGLE", 0, kGPU_Backend, GrContextFactory::kANGLE_GLContextType, true },
|
||||
#endif // SK_ANGLE
|
||||
#ifdef SK_DEBUG
|
||||
{ SkBitmap::kARGB_8888_Config, "Debug", kGPU_Backend, GrContextFactory::kDebug_GLContextType },
|
||||
{ SkBitmap::kARGB_8888_Config, "Debug", 0, kGPU_Backend, GrContextFactory::kDebug_GLContextType, GR_DEBUG },
|
||||
#endif // SK_DEBUG
|
||||
{ SkBitmap::kARGB_8888_Config, "NULLGPU", kGPU_Backend, GrContextFactory::kNull_GLContextType },
|
||||
{ SkBitmap::kARGB_8888_Config, "NULLGPU", 0, kGPU_Backend, GrContextFactory::kNull_GLContextType, true },
|
||||
#endif // SK_SUPPORT_GPU
|
||||
};
|
||||
|
||||
@ -280,6 +285,12 @@ static bool skip_name(const SkTDArray<const char*> array, const char name[]) {
|
||||
}
|
||||
|
||||
static void help() {
|
||||
SkString configsStr;
|
||||
static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs);
|
||||
for (size_t i = 0; i < kConfigCount; ++i) {
|
||||
configsStr.appendf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ? "" : "|"));
|
||||
}
|
||||
|
||||
SkDebugf("Usage: bench [-o outDir] [--repeat nr] [--logPerIter] "
|
||||
"[--timers [wcgWC]*] [--rotate]\n"
|
||||
" [--scale] [--clip] [--min] [--forceAA 1|0] [--forceFilter 1|0]\n"
|
||||
@ -290,8 +301,9 @@ static void help() {
|
||||
"\n"
|
||||
" [--strokeWidth width] [--match name]\n"
|
||||
" [--mode normal|deferred|deferredSilent|record|picturerecord]\n"
|
||||
" [--config 8888|565|GPU|ANGLE|NULLGPU] [-Dfoo bar] [--logFile filename]\n"
|
||||
" [-h|--help]");
|
||||
" [--config ");
|
||||
SkDebugf("%s]\n", configsStr.c_str());
|
||||
SkDebugf(" [-Dfoo bar] [--logFile filename] [-h|--help]");
|
||||
SkDebugf("\n\n");
|
||||
SkDebugf(" -o outDir : Image of each bench will be put in outDir.\n");
|
||||
SkDebugf(" --repeat nr : Each bench repeats for nr times.\n");
|
||||
@ -327,12 +339,8 @@ static void help() {
|
||||
" picturerecord, Benchmark the time to do record from a \n"
|
||||
" SkPicture to a SkPicture.\n");
|
||||
SkDebugf(" --logFile filename : destination for writing log output, in addition to stdout.\n");
|
||||
SkDebugf(" --config ");
|
||||
static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs);
|
||||
for (size_t i = 0; i < kConfigCount; ++i) {
|
||||
SkDebugf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ? "" : "|"));
|
||||
}
|
||||
SkDebugf(" : Run bench in corresponding config mode.\n");
|
||||
SkDebugf(" --config %s:\n", configsStr.c_str());
|
||||
SkDebugf(" Run bench in corresponding config mode.\n");
|
||||
SkDebugf(" -Dfoo bar : Add extra definition to bench.\n");
|
||||
SkDebugf(" -h|--help : Show this help message.\n");
|
||||
}
|
||||
@ -379,6 +387,7 @@ int tool_main(int argc, char** argv) {
|
||||
SkBitmap::Config outConfig = SkBitmap::kNo_Config;
|
||||
const char* configName = "";
|
||||
Backend backend = kRaster_Backend; // for warning
|
||||
int sampleCount = 0;
|
||||
SkTDArray<int> configs;
|
||||
bool userConfig = false;
|
||||
|
||||
@ -588,9 +597,11 @@ int tool_main(int argc, char** argv) {
|
||||
normalTimeFormat.set("%6.4f");
|
||||
}
|
||||
if (!userConfig) {
|
||||
// if no config is specified by user, we add them all.
|
||||
// if no config is specified by user, add the default configs
|
||||
for (unsigned int i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
|
||||
*configs.append() = i;
|
||||
if (gConfigs[i].fRunByDefault) {
|
||||
*configs.append() = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (kNormal_benchModes != benchMode) {
|
||||
@ -604,6 +615,35 @@ int tool_main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
for (int i = 0; i < configs.count(); ++i) {
|
||||
int configIdx = configs[i];
|
||||
|
||||
if (kGPU_Backend == gConfigs[configIdx].fBackend && gConfigs[configIdx].fSampleCnt > 0) {
|
||||
GrContext* context = gContextFactory.get(gConfigs[configIdx].fContextType);
|
||||
if (NULL == context) {
|
||||
SkString error;
|
||||
error.printf("Error creating GrContext for config %s. Config will be skipped.\n",
|
||||
gConfigs[configIdx].fName);
|
||||
logger.logError(error.c_str());
|
||||
configs.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
if (gConfigs[configIdx].fSampleCnt > context->getMaxSampleCount()){
|
||||
SkString error;
|
||||
error.printf("Sample count (%d) for config %s is unsupported. "
|
||||
"Config will be skipped.\n",
|
||||
gConfigs[configIdx].fSampleCnt, gConfigs[configIdx].fName);
|
||||
logger.logError(error.c_str());
|
||||
configs.remove(i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// report our current settings
|
||||
{
|
||||
SkString str;
|
||||
@ -728,6 +768,7 @@ int tool_main(int argc, char** argv) {
|
||||
outConfig = gConfigs[configIndex].fConfig;
|
||||
configName = gConfigs[configIndex].fName;
|
||||
backend = gConfigs[configIndex].fBackend;
|
||||
sampleCount = gConfigs[configIndex].fSampleCnt;
|
||||
GrContext* context = NULL;
|
||||
BenchTimer* timer = timers[configIndex];
|
||||
|
||||
@ -747,7 +788,7 @@ int tool_main(int argc, char** argv) {
|
||||
SkPicture pictureRecordTo;
|
||||
|
||||
if (kNonRendering_Backend != backend) {
|
||||
device = make_device(outConfig, dim, backend, context);
|
||||
device = make_device(outConfig, dim, backend, sampleCount, context);
|
||||
|
||||
switch(benchMode) {
|
||||
case kDeferredSilent_benchModes:
|
||||
|
@ -251,12 +251,6 @@ public:
|
||||
*/
|
||||
int getMaxTextureSize() const;
|
||||
|
||||
/**
|
||||
* Return the max width or height of a render target supported by the
|
||||
* current GPU.
|
||||
*/
|
||||
int getMaxRenderTargetSize() const;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Render targets
|
||||
|
||||
@ -280,6 +274,18 @@ public:
|
||||
*/
|
||||
bool isConfigRenderable(GrPixelConfig config) const;
|
||||
|
||||
/**
|
||||
* Return the max width or height of a render target supported by the
|
||||
* current GPU.
|
||||
*/
|
||||
int getMaxRenderTargetSize() const;
|
||||
|
||||
/**
|
||||
* Returns the max sample count for a render target. It will be 0 if MSAA
|
||||
* is not supported.
|
||||
*/
|
||||
int getMaxSampleCount() const;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Backend Surfaces
|
||||
|
||||
|
@ -549,6 +549,10 @@ int GrContext::getMaxRenderTargetSize() const {
|
||||
return fGpu->getCaps().maxRenderTargetSize();
|
||||
}
|
||||
|
||||
int GrContext::getMaxSampleCount() const {
|
||||
return fGpu->getCaps().maxSampleCount();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrTexture* GrContext::wrapBackendTexture(const GrBackendTextureDesc& desc) {
|
||||
|
@ -45,8 +45,10 @@ protected:
|
||||
bool fDualSourceBlendingSupport : 1;
|
||||
bool fBufferLockSupport : 1;
|
||||
bool fPathStencilingSupport : 1;
|
||||
|
||||
int fMaxRenderTargetSize;
|
||||
int fMaxTextureSize;
|
||||
int fMaxSampleCount;
|
||||
};
|
||||
|
||||
class DrawInfo;
|
||||
@ -81,6 +83,8 @@ public:
|
||||
|
||||
int maxRenderTargetSize() const { return fInternals.fMaxRenderTargetSize; }
|
||||
int maxTextureSize() const { return fInternals.fMaxTextureSize; }
|
||||
// Will be 0 if MSAA is not supported
|
||||
int maxSampleCount() const { return fInternals.fMaxSampleCount; }
|
||||
private:
|
||||
CapsInternals fInternals;
|
||||
friend class GrDrawTarget; // to set values of fInternals
|
||||
|
@ -19,7 +19,6 @@ void GrGLCaps::reset() {
|
||||
fStencilFormats.reset();
|
||||
fStencilVerifiedColorConfigs.reset();
|
||||
fMSFBOType = kNone_MSFBOType;
|
||||
fMaxSampleCount = 0;
|
||||
fCoverageAAType = kNone_CoverageAAType;
|
||||
fMaxFragmentUniformVectors = 0;
|
||||
fMaxVertexAttributes = 0;
|
||||
@ -53,7 +52,6 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
|
||||
fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
|
||||
fMaxVertexAttributes = caps.fMaxVertexAttributes;
|
||||
fMSFBOType = caps.fMSFBOType;
|
||||
fMaxSampleCount = caps.fMaxSampleCount;
|
||||
fCoverageAAType = caps.fCoverageAAType;
|
||||
fMSAACoverageModes = caps.fMSAACoverageModes;
|
||||
fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
|
||||
@ -284,13 +282,9 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
||||
SkCastForQSort(coverage_mode_compare));
|
||||
}
|
||||
}
|
||||
if (kNone_MSFBOType != fMSFBOType) {
|
||||
GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
|
||||
}
|
||||
}
|
||||
|
||||
const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(
|
||||
int desiredSampleCount) const {
|
||||
const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampleCount) const {
|
||||
static const MSAACoverageMode kNoneMode = {0, 0};
|
||||
if (0 == fMSAACoverageModes.count()) {
|
||||
return kNoneMode;
|
||||
|
@ -137,11 +137,6 @@ 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.
|
||||
*/
|
||||
@ -289,7 +284,6 @@ private:
|
||||
int fMaxVertexAttributes;
|
||||
|
||||
MSFBOType fMSFBOType;
|
||||
int fMaxSampleCount;
|
||||
CoverageAAType fCoverageAAType;
|
||||
SkTDArray<MSAACoverageMode> fMSAACoverageModes;
|
||||
|
||||
|
@ -278,18 +278,20 @@ void GrGpuGL::initCaps() {
|
||||
|
||||
// Enable supported shader-related caps
|
||||
if (kDesktop_GrGLBinding == this->glBinding()) {
|
||||
caps->fDualSourceBlendingSupport =
|
||||
this->glVersion() >= GR_GL_VER(3,3) ||
|
||||
this->hasExtension("GL_ARB_blend_func_extended");
|
||||
caps->fDualSourceBlendingSupport = this->glVersion() >= GR_GL_VER(3,3) ||
|
||||
this->hasExtension("GL_ARB_blend_func_extended");
|
||||
caps->fShaderDerivativeSupport = true;
|
||||
// we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
|
||||
caps->fGeometryShaderSupport =
|
||||
this->glVersion() >= GR_GL_VER(3,2) &&
|
||||
this->glslGeneration() >= k150_GrGLSLGeneration;
|
||||
caps->fGeometryShaderSupport = this->glVersion() >= GR_GL_VER(3,2) &&
|
||||
this->glslGeneration() >= k150_GrGLSLGeneration;
|
||||
} else {
|
||||
caps->fShaderDerivativeSupport =
|
||||
this->hasExtension("GL_OES_standard_derivatives");
|
||||
}
|
||||
|
||||
if (GrGLCaps::kNone_MSFBOType != this->glCaps().msFBOType()) {
|
||||
GR_GL_GetIntegerv(this->glInterface(), GR_GL_MAX_SAMPLES, &caps->fMaxSampleCount);
|
||||
}
|
||||
}
|
||||
|
||||
void GrGpuGL::fillInConfigRenderableTable() {
|
||||
@ -316,8 +318,7 @@ void GrGpuGL::fillInConfigRenderableTable() {
|
||||
// color renderable: RGBA4, RGB5_A1, RGB565
|
||||
// GL_EXT_texture_rg adds support for R8 as a color render target
|
||||
// GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
|
||||
// GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888
|
||||
// added BGRA support
|
||||
// GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
|
||||
|
||||
if (kDesktop_GrGLBinding == this->glBinding()) {
|
||||
// Post 3.0 we will get R8
|
||||
@ -849,8 +850,6 @@ bool renderbuffer_storage_msaa(GrGLContext& ctx,
|
||||
created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
|
||||
}
|
||||
if (!created) {
|
||||
// glRBMS will fail if requested samples is > max samples.
|
||||
sampleCount = GrMin(sampleCount, ctx.info().caps().maxSampleCount());
|
||||
GL_ALLOC_CALL(ctx.interface(),
|
||||
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
|
||||
sampleCount,
|
||||
@ -976,12 +975,18 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc,
|
||||
|
||||
// Attempt to catch un- or wrongly initialized sample counts;
|
||||
GrAssert(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64);
|
||||
// We fail if the MSAA was requested and is not available.
|
||||
if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleCnt) {
|
||||
//GrPrintf("MSAA RT requested but not supported on this platform.");
|
||||
return return_null_texture();
|
||||
}
|
||||
// If the sample count exceeds the max then we clamp it.
|
||||
glTexDesc.fSampleCnt = GrMin(desc.fSampleCnt, this->getCaps().maxSampleCount());
|
||||
|
||||
glTexDesc.fFlags = desc.fFlags;
|
||||
glTexDesc.fWidth = desc.fWidth;
|
||||
glTexDesc.fHeight = desc.fHeight;
|
||||
glTexDesc.fConfig = desc.fConfig;
|
||||
glTexDesc.fSampleCnt = desc.fSampleCnt;
|
||||
glTexDesc.fIsWrapped = false;
|
||||
|
||||
glRTDesc.fMSColorRenderbufferID = 0;
|
||||
@ -997,7 +1002,7 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc,
|
||||
glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
|
||||
glRTDesc.fOrigin = glTexDesc.fOrigin;
|
||||
|
||||
glRTDesc.fSampleCnt = desc.fSampleCnt;
|
||||
glRTDesc.fSampleCnt = glTexDesc.fSampleCnt;
|
||||
if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() &&
|
||||
desc.fSampleCnt) {
|
||||
//GrPrintf("MSAA RT requested but not supported on this platform.");
|
||||
|
Loading…
Reference in New Issue
Block a user