Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: src/gpu/GrTargetCommands.h

Issue 1119353002: Revert of Move state management to GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@batchownsbounds
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTargetCommands.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTargetCommands.h
diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h
index 8c0a3fd0ca204ee6c8aab66e1e7abc4a2a9df6b3..f9259c72b31ef404aba557495683a1bd5aac1ef1 100644
--- a/src/gpu/GrTargetCommands.h
+++ b/src/gpu/GrTargetCommands.h
@@ -24,7 +24,6 @@
class GrIndexBufferAllocPool;
class GrTargetCommands : ::SkNoncopyable {
- struct State;
struct SetState;
public:
@@ -32,6 +31,7 @@
GrVertexBufferAllocPool* vertexPool,
GrIndexBufferAllocPool* indexPool)
: fCmdBuffer(kCmdBufferInitialSizeInBytes)
+ , fPrevState(NULL)
, fBatchTarget(gpu, vertexPool, indexPool) {
}
@@ -51,7 +51,7 @@
Cmd(CmdType type) : fMarkerID(-1), fType(type) {}
virtual ~Cmd() {}
- virtual void execute(GrGpu*) = 0;
+ virtual void execute(GrGpu*, const SetState*) = 0;
CmdType type() const { return fType; }
@@ -68,23 +68,32 @@
void reset();
void flush(GrInOrderDrawBuffer*);
- Cmd* recordClearStencilClip(const SkIRect& rect,
+ Cmd* recordClearStencilClip(GrInOrderDrawBuffer*,
+ const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget);
- Cmd* recordDiscard(GrRenderTarget*);
- Cmd* recordDrawBatch(State*, GrBatch*);
- Cmd* recordStencilPath(const GrPipelineBuilder&,
+ Cmd* recordDiscard(GrInOrderDrawBuffer*, GrRenderTarget*);
+
+ Cmd* recordDraw(GrInOrderDrawBuffer*,
+ const GrGeometryProcessor*,
+ const GrDrawTarget::DrawInfo&,
+ const GrDrawTarget::PipelineInfo&);
+ Cmd* recordDrawBatch(GrInOrderDrawBuffer*,
+ GrBatch*,
+ const GrDrawTarget::PipelineInfo&);
+ Cmd* recordStencilPath(GrInOrderDrawBuffer*,
+ const GrPipelineBuilder&,
const GrPathProcessor*,
const GrPath*,
const GrScissorState&,
const GrStencilSettings&);
- Cmd* recordDrawPath(State*,
+ Cmd* recordDrawPath(GrInOrderDrawBuffer*,
const GrPathProcessor*,
const GrPath*,
- const GrStencilSettings&);
- Cmd* recordDrawPaths(State*,
- GrInOrderDrawBuffer*,
+ const GrStencilSettings&,
+ const GrDrawTarget::PipelineInfo&);
+ Cmd* recordDrawPaths(GrInOrderDrawBuffer*,
const GrPathProcessor*,
const GrPathRange*,
const void*,
@@ -94,7 +103,8 @@
int,
const GrStencilSettings&,
const GrDrawTarget::PipelineInfo&);
- Cmd* recordClear(const SkIRect* rect,
+ Cmd* recordClear(GrInOrderDrawBuffer*,
+ const SkIRect* rect,
GrColor,
bool canIgnoreRect,
GrRenderTarget*);
@@ -108,51 +118,18 @@
typedef GrGpu::DrawArgs DrawArgs;
- void recordXferBarrierIfNecessary(const GrPipeline&, GrInOrderDrawBuffer*);
-
- // TODO: This can be just a pipeline once paths are in batch, and it should live elsewhere
- struct State : public SkRefCnt {
- // TODO get rid of the prim proc parameter when we use batch everywhere
- State(const GrPrimitiveProcessor* primProc = NULL)
- : fPrimitiveProcessor(primProc)
- , fCompiled(false) {}
-
- ~State() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipeline(); }
-
- // This function is only for getting the location in memory where we will create our
- // pipeline object.
- GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fPipeline.get()); }
-
- const GrPipeline* getPipeline() const {
- return reinterpret_cast<const GrPipeline*>(fPipeline.get());
- }
- GrRenderTarget* getRenderTarget() const {
- return this->getPipeline()->getRenderTarget();
- }
- const GrXferProcessor* getXferProcessor() const {
- return this->getPipeline()->getXferProcessor();
- }
-
- void operator delete(void* p) {
- //SkDebugf("destruction\n");
- }
- void* operator new(size_t) {
- SkFAIL("All States are created by placement new.");
- return sk_malloc_throw(0);
- }
-
- void* operator new(size_t, void* p) { return p; }
- void operator delete(void* target, void* placement) {
- ::operator delete(target, placement);
- }
-
- typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
- ProgramPrimitiveProcessor fPrimitiveProcessor;
- SkAlignedSStorage<sizeof(GrPipeline)> fPipeline;
- GrProgramDesc fDesc;
- GrBatchTracker fBatchTracker;
- bool fCompiled;
- };
+ // Attempts to concat instances from info onto the previous draw. info must represent an
+ // instanced draw. The caller must have already recorded a new draw state and clip if necessary.
+ int concatInstancedDraw(GrInOrderDrawBuffer*, const GrDrawTarget::DrawInfo&);
+
+ bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*,
+ const GrPrimitiveProcessor*,
+ const GrDrawTarget::PipelineInfo&);
+ bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*,
+ GrBatch*,
+ const GrDrawTarget::PipelineInfo&);
+
+ void recordXferBarrierIfNecessary(GrInOrderDrawBuffer*, const GrDrawTarget::PipelineInfo&);
struct StencilPath : public Cmd {
StencilPath(const GrPath* path, GrRenderTarget* rt)
@@ -162,7 +139,7 @@
const GrPath* path() const { return fPath.get(); }
- void execute(GrGpu*) override;
+ void execute(GrGpu*, const SetState*) override;
SkMatrix fViewMatrix;
bool fUseHWAA;
@@ -174,32 +151,25 @@
};
struct DrawPath : public Cmd {
- DrawPath(State* state, const GrPath* path)
- : Cmd(kDrawPath_CmdType)
- , fState(SkRef(state))
- , fPath(path) {}
+ DrawPath(const GrPath* path) : Cmd(kDrawPath_CmdType), fPath(path) {}
const GrPath* path() const { return fPath.get(); }
- void execute(GrGpu*) override;
-
- SkAutoTUnref<State> fState;
+ void execute(GrGpu*, const SetState*) override;
+
GrStencilSettings fStencilSettings;
+
private:
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
};
struct DrawPaths : public Cmd {
- DrawPaths(State* state, const GrPathRange* pathRange)
- : Cmd(kDrawPaths_CmdType)
- , fState(SkRef(state))
- , fPathRange(pathRange) {}
+ DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_CmdType), fPathRange(pathRange) {}
const GrPathRange* pathRange() const { return fPathRange.get(); }
- void execute(GrGpu*) override;
-
- SkAutoTUnref<State> fState;
+ void execute(GrGpu*, const SetState*) override;
+
char* fIndices;
GrDrawTarget::PathIndexType fIndexType;
float* fTransforms;
@@ -217,7 +187,7 @@
GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
- void execute(GrGpu*) override;
+ void execute(GrGpu*, const SetState*) override;
SkIRect fRect;
GrColor fColor;
@@ -233,7 +203,7 @@
GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
- void execute(GrGpu*) override;
+ void execute(GrGpu*, const SetState*) override;
SkIRect fRect;
bool fInsideClip;
@@ -252,7 +222,7 @@
GrSurface* dst() const { return fDst.get(); }
GrSurface* src() const { return fSrc.get(); }
- void execute(GrGpu*) override;
+ void execute(GrGpu*, const SetState*) override;
SkIPoint fDstPoint;
SkIRect fSrcRect;
@@ -262,18 +232,49 @@
GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
};
+ // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed
+ struct SetState : public Cmd {
+ // TODO get rid of the prim proc parameter when we use batch everywhere
+ SetState(const GrPrimitiveProcessor* primProc = NULL)
+ : Cmd(kSetState_CmdType)
+ , fPrimitiveProcessor(primProc) {}
+
+ ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipeline(); }
+
+ // This function is only for getting the location in memory where we will create our
+ // pipeline object.
+ GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fPipeline.get()); }
+
+ const GrPipeline* getPipeline() const {
+ return reinterpret_cast<const GrPipeline*>(fPipeline.get());
+ }
+ GrRenderTarget* getRenderTarget() const {
+ return this->getPipeline()->getRenderTarget();
+ }
+ const GrXferProcessor* getXferProcessor() const {
+ return this->getPipeline()->getXferProcessor();
+ }
+
+ void execute(GrGpu*, const SetState*) override;
+
+ typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
+ ProgramPrimitiveProcessor fPrimitiveProcessor;
+ SkAlignedSStorage<sizeof(GrPipeline)> fPipeline;
+ GrProgramDesc fDesc;
+ GrBatchTracker fBatchTracker;
+ };
+
struct DrawBatch : public Cmd {
- DrawBatch(State* state, GrBatch* batch, GrBatchTarget* batchTarget)
+ DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget)
: Cmd(kDrawBatch_CmdType)
- , fState(SkRef(state))
, fBatch(SkRef(batch))
, fBatchTarget(batchTarget) {
SkASSERT(!batch->isUsed());
}
- void execute(GrGpu*) override;
-
- SkAutoTUnref<State> fState;
+ void execute(GrGpu*, const SetState*) override;
+
+ // TODO it wouldn't be too hard to let batches allocate in the cmd buffer
SkAutoTUnref<GrBatch> fBatch;
private:
@@ -283,18 +284,19 @@
struct XferBarrier : public Cmd {
XferBarrier() : Cmd(kXferBarrier_CmdType) {}
- void execute(GrGpu*) override;
+ void execute(GrGpu*, const SetState*) override;
GrXferBarrierType fBarrierType;
};
- static const int kCmdBufferInitialSizeInBytes = 8 * 1024;
-
- typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
- typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
-
- CmdBuffer fCmdBuffer;
- GrBatchTarget fBatchTarget;
+ static const int kCmdBufferInitialSizeInBytes = 8 * 1024;
+
+ typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
+ typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
+
+ CmdBuffer fCmdBuffer;
+ SetState* fPrevState;
+ GrBatchTarget fBatchTarget;
};
#endif
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTargetCommands.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698