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

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: comments updated 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
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 /** See comments before GrDrawBatch::Target definition on how deferred uploa ders work. */
egdaniel 2016/03/30 15:52:33 Can you comment on where GrDrawBatch::Target defin
bsalomon 2016/03/30 16:59:11 Not crazy about doing that for 3 reasons: 1) Likel
55 using DeferredUploadFn = std::function<void(WritePixelsFn&)>;
56
41 class Target; 57 class Target;
42 58
43 GrDrawBatch(uint32_t classID); 59 GrDrawBatch(uint32_t classID);
44 ~GrDrawBatch() override; 60 ~GrDrawBatch() override;
45 61
46 /** 62 /**
47 * Fills in a structure informing the XP of overrides to its normal behavior . 63 * Fills in a structure informing the XP of overrides to its normal behavior .
48 */ 64 */
49 void getPipelineOptimizations(GrPipelineOptimizations* override) const; 65 void getPipelineOptimizations(GrPipelineOptimizations* override) const;
50 66
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 GrBatchToXPOverrides* overrides) c onst = 0; 109 GrBatchToXPOverrides* overrides) c onst = 0;
94 110
95 private: 111 private:
96 /** 112 /**
97 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities 113 * initBatchTracker is a hook for the some additional overrides / optimizati on possibilities
98 * from the GrXferProcessor. 114 * from the GrXferProcessor.
99 */ 115 */
100 virtual void initBatchTracker(const GrXPOverridesForBatch&) = 0; 116 virtual void initBatchTracker(const GrXPOverridesForBatch&) = 0;
101 117
102 protected: 118 protected:
103 SkTArray<SkAutoTUnref<GrBatchUploader>, true> fInlineUploads; 119 struct QueuedUpload {
120 QueuedUpload(DeferredUploadFn&& upload, GrBatchDrawToken token)
121 : fUpload(std::move(upload))
122 , fUploadBeforeToken(token) {}
123 DeferredUploadFn fUpload;
124 GrBatchDrawToken fUploadBeforeToken;
125 };
126 SkTArray<QueuedUpload> fInlineUploads;
104 127
105 private: 128 private:
106 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage; 129 SkAlignedSTStorage<1, GrPipeline> fPipelineStorage;
107 bool fPipelineInstalled; 130 bool fPipelineInstalled;
108 typedef GrBatch INHERITED; 131 typedef GrBatch INHERITED;
109 }; 132 };
110 133
111 #endif 134 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698