Enhance GL error checking for non-Ganesh GL calls

https://codereview.appspot.com/7312057/



git-svn-id: http://skia.googlecode.com/svn/trunk@7647 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-02-07 19:45:46 +00:00
parent efbe8e9bed
commit fe1b536bb7
7 changed files with 40 additions and 16 deletions

View File

@ -51,9 +51,16 @@ double BenchGpuTimer::endGpu() {
GrGLint available = 0;
while (!available) {
SK_GL(*fContext, GetQueryObjectiv(fQuery,
SK_GL_NOERRCHECK(*fContext, GetQueryObjectiv(fQuery,
GR_GL_QUERY_RESULT_AVAILABLE,
&available));
// If GetQueryObjectiv is erroring out we need some alternative
// means of breaking out of this loop
GrGLenum error;
SK_GL_RET_NOERRCHECK(*fContext, error, GetError());
if (GR_GL_NO_ERROR != error) {
break;
}
}
GrGLuint64 totalGPUTimeElapsed = 0;
SK_GL(*fContext, GetQueryObjectui64v(fQuery,

View File

@ -11,6 +11,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "gl/GrGLDefines.h"
#include "GrRenderTarget.h"
#if SK_ANGLE
#include "gl/SkANGLEGLContext.h"

View File

@ -144,6 +144,15 @@
'images.gyp:images',
'tools.gyp:picture_utils',
],
'conditions': [
['skia_gpu == 1',
{
'include_dirs' : [
'../src/gpu',
],
},
],
],
'export_dependent_settings': [
'images.gyp:images',
],

View File

@ -61,9 +61,14 @@ private:
};
/**
* Helper macro for using the GL context through the GrGLInterface. Example:
* Helper macros for using the GL context through the GrGLInterface. Example:
* SK_GL(glCtx, GenTextures(1, &texID));
*/
#define SK_GL(ctx, X) (ctx).gl()->f ## X
#define SK_GL(ctx, X) (ctx).gl()->f ## X; \
SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
#define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->f ## X; \
SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fGetError())
#define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->f ## X
#define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->f ## X
#endif

View File

@ -40,18 +40,19 @@ bool SkGLContext::init(int width, int height) {
fGL = this->createGLContext();
if (fGL) {
fExtensionString =
reinterpret_cast<const char*>(SK_GL(*this,
GetString(GR_GL_EXTENSIONS)));
const char* versionStr =
reinterpret_cast<const char*>(SK_GL(*this,
GetString(GR_GL_VERSION)));
const GrGLubyte* temp;
SK_GL_RET(*this, temp, GetString(GR_GL_EXTENSIONS));
fExtensionString = reinterpret_cast<const char*>(temp);
SK_GL_RET(*this, temp, GetString(GR_GL_VERSION));
const char* versionStr = reinterpret_cast<const char*>(temp);
GrGLVersion version = GrGLGetVersionFromString(versionStr);
// clear any existing GL erorrs
GrGLenum error;
do {
error = SK_GL(*this, GetError());
SK_GL_RET(*this, error, GetError());
} while (GR_GL_NO_ERROR != error);
GrGLBinding bindingInUse = GrGLGetBindingInUse(this->gl());
@ -118,9 +119,9 @@ bool SkGLContext::init(int width, int height) {
SK_GL(*this, ClearStencil(0));
SK_GL(*this, Clear(GR_GL_STENCIL_BUFFER_BIT));
error = SK_GL(*this, GetError());
GrGLenum status =
SK_GL(*this, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
SK_GL_RET(*this, error, GetError());
GrGLenum status;
SK_GL_RET(*this, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
if (GR_GL_FRAMEBUFFER_COMPLETE != status ||
GR_GL_NO_ERROR != error) {

View File

@ -96,7 +96,7 @@ void PictureBenchmark::run(SkPicture* pict) {
while (tiledRenderer->nextTile(x, y)) {
// There are two timers, which will behave slightly differently:
// 1) longRunningTimer, along with perTileTimerData, will time how long it takes to draw
// one tile fRepeats times, and take the average. As such, it will not respect the
// one tile fRepeats times, and take the average. As such, it will not respect thea
// logPerIter or printMin options, since it does not know the time per iteration. It
// will also be unable to call flush() for each tile.
// The goal of this timer is to make up for a system timer that is not precise enough to
@ -104,10 +104,10 @@ void PictureBenchmark::run(SkPicture* pict) {
//
// 2) perTileTimer, along with perTileTimerData, will record each run separately, and
// then take the average. As such, it supports logPerIter and printMin options.
SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer(false));
SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
TimerData longRunningTimerData(tiledRenderer->getPerIterTimeFormat(),
tiledRenderer->getNormalTimeFormat());
SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false));
SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer());
TimerData perTileTimerData(tiledRenderer->getPerIterTimeFormat(),
tiledRenderer->getNormalTimeFormat());
longRunningTimer->start();

View File

@ -12,6 +12,7 @@
#include "SkDevice.h"
#include "SkGPipe.h"
#if SK_SUPPORT_GPU
#include "gl/GrGLDefines.h"
#include "SkGpuDevice.h"
#endif
#include "SkGraphics.h"