Add immediate mode option for gpu configs in dm

Review URL: https://codereview.chromium.org/1421853002
This commit is contained in:
bsalomon 2015-10-23 09:06:59 -07:00 committed by Commit bot
parent b7f1251775
commit 648c696438
10 changed files with 47 additions and 18 deletions

View File

@ -55,7 +55,9 @@ public:
void dumpGpuStats(SkString*) const {}
};
struct GrContextOptions {};
struct GrContextOptions {
bool fImmediateMode;
};
class GrContextFactory {
public:

View File

@ -917,8 +917,13 @@ int GPUSink::enclave() const {
void PreAbandonGpuContextErrorHandler(SkError, void*) {}
DEFINE_bool(imm, false, "Run gpu configs in immediate mode.");
Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) const {
GrContextOptions options;
if (FLAGS_imm) {
options.fImmediateMode = true;
}
src.modifyGrContextOptions(&options);
GrContextFactory factory(options);

View File

@ -413,7 +413,7 @@ private:
bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
void initMockContext();
void initCommon();
void initCommon(const GrContextOptions& options);
/**
* These functions create premul <-> unpremul effects if it is possible to generate a pair

View File

@ -18,7 +18,8 @@ struct GrContextOptions {
, fMinTextureSizeOverride(0)
, fSuppressDualSourceBlending(false)
, fGeometryBufferMapThreshold(-1)
, fUseDrawInsteadOfPartialRenderTargetWrite(false) {}
, fUseDrawInsteadOfPartialRenderTargetWrite(false)
, fImmediateMode(false) {}
// EXPERIMENTAL
// May be removed in the future, or may become standard depending
@ -43,6 +44,10 @@ struct GrContextOptions {
/** some gpus have problems with partial writes of the rendertarget */
bool fUseDrawInsteadOfPartialRenderTargetWrite;
/** The GrContext operates in immedidate mode. It will issue all draws to the backend API
immediately. Intended to ease debugging. */
bool fImmediateMode;
};
#endif

View File

@ -74,11 +74,11 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
if (!fGpu) {
return false;
}
this->initCommon();
this->initCommon(options);
return true;
}
void GrContext::initCommon() {
void GrContext::initCommon(const GrContextOptions& options) {
fCaps = SkRef(fGpu->caps());
fResourceCache = new GrResourceCache(fCaps);
fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
@ -88,7 +88,9 @@ void GrContext::initCommon() {
fDidTestPMConversions = false;
fDrawingManager.reset(new GrDrawingManager(this));
GrDrawTarget::Options dtOptions;
dtOptions.fImmediateMode = options.fImmediateMode;
fDrawingManager.reset(new GrDrawingManager(this, dtOptions));
// GrBatchFontCache will eventually replace GrFontCache
fBatchFontCache = new GrBatchFontCache(this);

View File

@ -32,13 +32,15 @@
////////////////////////////////////////////////////////////////////////////////
GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
const Options& options)
: fGpu(SkRef(gpu))
, fResourceProvider(resourceProvider)
, fFlushState(fGpu, fResourceProvider, 0)
, fFlushing(false)
, fFirstUnpreparedBatch(0)
, fFlags(0) {
, fFlags(0)
, fOptions(options) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
fClipMaskManager.reset(new GrClipMaskManager(this));
@ -472,6 +474,8 @@ template <class Left, class Right> static bool intersect(const Left& a, const Ri
void GrDrawTarget::recordBatch(GrBatch* batch) {
// A closed drawTarget should never receive new/more batches
SkASSERT(!this->isClosed());
// Should never have batches queued up when in immediate mode.
SkASSERT(!fOptions.fImmediateMode || !fBatches.count());
// Check if there is a Batch Draw we can batch with by linearly searching back until we either
// 1) check every draw
@ -524,6 +528,9 @@ void GrDrawTarget::recordBatch(GrBatch* batch) {
SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1);
fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState);
}
if (fOptions.fImmediateMode) {
this->flush();
}
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -43,9 +43,13 @@ class GrPathRangeDraw;
class GrDrawTarget final : public SkRefCnt {
public:
struct Options {
bool fImmediateMode;
};
// The context may not be fully constructed and should not be used during GrDrawTarget
// construction.
GrDrawTarget(GrGpu* gpu, GrResourceProvider*);
GrDrawTarget(GrGpu* gpu, GrResourceProvider*, const Options& options);
~GrDrawTarget() override;
@ -221,7 +225,6 @@ public:
const CMMAccess cmmAccess() { return CMMAccess(this); }
private:
friend class GrDrawingManager; // for resetFlag & TopoSortTraits
@ -311,6 +314,7 @@ private:
SkDEBUGCODE(int fDebugID;)
uint32_t fFlags;
Options fOptions;
// 'this' drawTarget relies on the output of the drawTargets in 'fDependencies'
SkTDArray<GrDrawTarget*> fDependencies;

View File

@ -105,7 +105,8 @@ GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) {
}
#endif
GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourceProvider());
GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourceProvider(),
fOptions);
*fDrawTargets.append() = dt;

View File

@ -8,6 +8,7 @@
#ifndef GrDrawingManager_DEFINED
#define GrDrawingManager_DEFINED
#include "GrDrawTarget.h"
#include "SkTDArray.h"
class GrContext;
@ -40,9 +41,10 @@ public:
GrContext* getContext() { return fContext; }
private:
GrDrawingManager(GrContext* context)
GrDrawingManager(GrContext* context, GrDrawTarget::Options options)
: fContext(context)
, fAbandoned(false)
, fOptions(options)
, fNVPRTextContext(nullptr) {
sk_bzero(fTextContexts, sizeof(fTextContexts));
}
@ -57,13 +59,14 @@ private:
static const int kNumPixelGeometries = 5; // The different pixel geometries
static const int kNumDFTOptions = 2; // DFT or no DFT
GrContext* fContext;
GrContext* fContext;
bool fAbandoned;
SkTDArray<GrDrawTarget*> fDrawTargets;
bool fAbandoned;
SkTDArray<GrDrawTarget*> fDrawTargets;
GrDrawTarget::Options fOptions;
GrTextContext* fNVPRTextContext;
GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
GrTextContext* fNVPRTextContext;
GrTextContext* fTextContexts[kNumPixelGeometries][kNumDFTOptions];
};
#endif

View File

@ -288,7 +288,7 @@ void GrContext::initMockContext() {
SkASSERT(nullptr == fGpu);
fGpu = new MockGpu(this, options);
SkASSERT(fGpu);
this->initCommon();
this->initCommon(options);
// We delete these because we want to test the cache starting with zero resources. Also, none of
// these objects are required for any of tests that use this context. TODO: make stop allocating