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

Side by Side Diff: src/gpu/batches/GrDrawBatch.h

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add comments Created 4 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 unified diff | Download patch
« no previous file with comments | « src/gpu/batches/GrDrawAtlasBatch.cpp ('k') | src/gpu/batches/GrDrawVerticesBatch.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrDrawBatch_DEFINED 8 #ifndef GrDrawBatch_DEFINED
9 #define GrDrawBatch_DEFINED 9 #define GrDrawBatch_DEFINED
10 10
11 #include <functional>
11 #include "GrBatch.h" 12 #include "GrBatch.h"
12 #include "GrPipeline.h" 13 #include "GrPipeline.h"
13 14
14 struct GrInitInvariantOutput; 15 struct GrInitInvariantOutput;
15 16
16 /** 17 /**
17 * GrDrawBatches are flushed in two phases (preDraw, and draw). In preDraw uploa ds to GrGpuResources 18 * GrDrawBatches are flushed in two phases (preDraw, and draw). In preDraw uploa ds to GrGpuResources
18 * and draws are determined and scheduled. They are issued in the draw phase. Gr BatchToken is used 19 * and draws are determined and scheduled. They are issued in the draw phase. Gr BatchToken is used
19 * to sequence the uploads relative to each other and to draws. 20 * to sequence the uploads relative to each other and to draws.
20 **/ 21 **/
21 22
22 typedef uint64_t GrBatchToken; 23 class GrBatchDrawToken {
24 public:
25 static GrBatchDrawToken AlreadyFlushedToken() { return GrBatchDrawToken(0); }
23 26
24 class GrBatchUploader : public SkRefCnt { 27 GrBatchDrawToken(const GrBatchDrawToken& that) : fSequenceNumber(that.fSeque nceNumber) {}
25 public: 28 GrBatchDrawToken& operator =(const GrBatchDrawToken& that) {
26 class TextureUploader; 29 fSequenceNumber = that.fSequenceNumber;
27 30 return *this;
28 GrBatchUploader(GrBatchToken lastUploadToken) : fLastUploadToken(lastUploadT oken) {} 31 }
29 GrBatchToken lastUploadToken() const { return fLastUploadToken; } 32 bool operator==(const GrBatchDrawToken& that) const {
30 virtual void upload(TextureUploader*)=0; 33 return fSequenceNumber == that.fSequenceNumber;
34 }
35 bool operator!=(const GrBatchDrawToken& that) const { return !(*this == that ); }
31 36
32 private: 37 private:
33 GrBatchToken fLastUploadToken; 38 GrBatchDrawToken();
39 explicit GrBatchDrawToken(uint64_t sequenceNumber) : fSequenceNumber(sequenc eNumber) {}
40 friend class GrBatchFlushState;
41 uint64_t fSequenceNumber;
34 }; 42 };
35 43
36 /** 44 /**
37 * Base class for GrBatches that draw. These batches have a GrPipeline installed by GrDrawTarget. 45 * Base class for GrBatches that draw. These batches have a GrPipeline installed by GrDrawTarget.
38 */ 46 */
39 class GrDrawBatch : public GrBatch { 47 class GrDrawBatch : public GrBatch {
40 public: 48 public:
49 /** Method that performs an upload on behalf of a DeferredUploadFn. */
50 using WritePixelsFn = std::function<bool(GrSurface* texture,
51 int left, int top, int width, int h eight,
52 GrPixelConfig config, const void* b uffer,
53 size_t rowBytes)>;
54
55 /**
56 * Batches can insert uploads when preparing their draws. The can eithe be i nserted before
egdaniel 2016/03/28 20:05:20 The->They, eithe->either
57 * all the draws (of all batches in a flush), which is called an "asap uploa d", or schedule
58 * them between draws, which is called an "inline upload". ASAP uploads are typically used
egdaniel 2016/03/28 20:05:20 Wouldn't you want inline uploads in the case where
bsalomon 2016/03/28 20:11:02 Yes, mental slip
59 * when the content of the GrSurface must be modified between draws because two draws require
60 * different contents to appear in the surface.
61 */
62 using DeferredUploadFn = std::function<void(WritePixelsFn&)>;
63
41 class Target; 64 class Target;
42 65
43 GrDrawBatch(uint32_t classID); 66 GrDrawBatch(uint32_t classID);
44 ~GrDrawBatch() override; 67 ~GrDrawBatch() override;
45 68
46 /** 69 /**
47 * Fills in a structure informing the XP of overrides to its normal behavior . 70 * Fills in a structure informing the XP of overrides to its normal behavior .
48 */ 71 */
49 void getPipelineOptimizations(GrPipelineOptimizations* override) const; 72 void getPipelineOptimizations(GrPipelineOptimizations* override) const;
50 73
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 GrBatchToXPOverrides* overrides) c onst = 0; 116 GrBatchToXPOverrides* overrides) c onst = 0;
94 117
95 private: 118 private:
96 /** 119 /**
97 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities 120 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities
98 * from the GrXferProcessor. 121 * from the GrXferProcessor.
99 */ 122 */
100 virtual void initBatchTracker(const GrXPOverridesForBatch&) = 0; 123 virtual void initBatchTracker(const GrXPOverridesForBatch&) = 0;
101 124
102 protected: 125 protected:
103 SkTArray<SkAutoTUnref<GrBatchUploader>, true> fInlineUploads; 126 struct QueuedUpload {
127 QueuedUpload(DeferredUploadFn&& upload, GrBatchDrawToken token)
128 : fUpload(std::move(upload))
129 , fUploadBeforeToken(token) {}
130 DeferredUploadFn fUpload;
131 GrBatchDrawToken fUploadBeforeToken;
132 };
133 SkTArray<QueuedUpload> fInlineUploads;
104 134
105 private: 135 private:
106 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage; 136 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage;
107 bool fPipelineInstalled; 137 bool fPipelineInstalled;
108 typedef GrBatch INHERITED; 138 typedef GrBatch INHERITED;
109 }; 139 };
110 140
111 #endif 141 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawAtlasBatch.cpp ('k') | src/gpu/batches/GrDrawVerticesBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698