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

Side by Side Diff: include/gpu/GrXferProcessor.h

Issue 1287973003: Check for xfer barriers in GrBatch, auto-issue barriers in GrGpu (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 5 years, 4 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 | « no previous file | src/gpu/GrAAConvexPathRenderer.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 2014 Google Inc. 2 * Copyright 2014 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 GrXferProcessor_DEFINED 8 #ifndef GrXferProcessor_DEFINED
9 #define GrXferProcessor_DEFINED 9 #define GrXferProcessor_DEFINED
10 10
11 #include "GrBlend.h" 11 #include "GrBlend.h"
12 #include "GrColor.h" 12 #include "GrColor.h"
13 #include "GrProcessor.h" 13 #include "GrProcessor.h"
14 #include "GrTexture.h" 14 #include "GrTexture.h"
15 #include "GrTypes.h" 15 #include "GrTypes.h"
16 #include "SkXfermode.h" 16 #include "SkXfermode.h"
17 17
18 class GrShaderCaps; 18 class GrShaderCaps;
19 class GrGLSLCaps; 19 class GrGLSLCaps;
20 class GrGLXferProcessor; 20 class GrGLXferProcessor;
21 class GrProcOptInfo; 21 class GrProcOptInfo;
22 22
23 /** 23 /**
24 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes 24 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes
25 * required after a pixel has been written, before it can be safely read again. 25 * required after a pixel has been written, before it can be safely read again.
26 */ 26 */
27 enum GrXferBarrierType { 27 enum GrXferBarrierType {
28 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders to the same texture. 28 kNone_GrXferBarrierType = 0, //<! No barrier is required
29 kBlend_GrXferBarrierType, //<! Required by certain blend extensions. 29 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders t o the same texture.
30 kBlend_GrXferBarrierType, //<! Required by certain blend extensions.
30 }; 31 };
32 /** Should be able to treat kNone as false in boolean expressions */
33 GR_STATIC_ASSERT(SkToBool(kNone_GrXferBarrierType) == false);
31 34
32 /** 35 /**
33 * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst 36 * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst
34 * color, and for applying any coverage. It does this by emitting fragment shade r code and 37 * color, and for applying any coverage. It does this by emitting fragment shade r code and
35 * controlling the fixed-function blend state. When dual-source blending is avai lable, it may also 38 * controlling the fixed-function blend state. When dual-source blending is avai lable, it may also
36 * write a seconday fragment shader output color. GrXferProcessor has two modes of operation: 39 * write a seconday fragment shader output color. GrXferProcessor has two modes of operation:
37 * 40 *
38 * Dst read: When allowed by the backend API, or when supplied a texture of the destination, the 41 * Dst read: When allowed by the backend API, or when supplied a texture of the destination, the
39 * GrXferProcessor may read the destination color. While operating in this mode, the subclass only 42 * GrXferProcessor may read the destination color. While operating in this mode, the subclass only
40 * provides shader code that blends the src and dst colors, and the base class a pplies coverage. 43 * provides shader code that blends the src and dst colors, and the base class a pplies coverage.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 OptFlags getOptimizations(const GrProcOptInfo& colorPOI, 144 OptFlags getOptimizations(const GrProcOptInfo& colorPOI,
142 const GrProcOptInfo& coveragePOI, 145 const GrProcOptInfo& coveragePOI,
143 bool doesStencilWrite, 146 bool doesStencilWrite,
144 GrColor* overrideColor, 147 GrColor* overrideColor,
145 const GrCaps& caps); 148 const GrCaps& caps);
146 149
147 /** 150 /**
148 * Returns whether this XP will require an Xfer barrier on the given rt. If true, outBarrierType 151 * Returns whether this XP will require an Xfer barrier on the given rt. If true, outBarrierType
149 * is updated to contain the type of barrier needed. 152 * is updated to contain the type of barrier needed.
150 */ 153 */
151 bool willNeedXferBarrier(const GrRenderTarget* rt, 154 GrXferBarrierType xferBarrierType(const GrRenderTarget* rt, const GrCaps& ca ps) const;
152 const GrCaps& caps,
153 GrXferBarrierType* outBarrierType) const;
154 155
155 struct BlendInfo { 156 struct BlendInfo {
156 void reset() { 157 void reset() {
157 fEquation = kAdd_GrBlendEquation; 158 fEquation = kAdd_GrBlendEquation;
158 fSrcBlend = kOne_GrBlendCoeff; 159 fSrcBlend = kOne_GrBlendCoeff;
159 fDstBlend = kZero_GrBlendCoeff; 160 fDstBlend = kZero_GrBlendCoeff;
160 fBlendConstant = 0; 161 fBlendConstant = 0;
161 fWriteColor = true; 162 fWriteColor = true;
162 } 163 }
163 164
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const GrCaps& caps) = 0; 250 const GrCaps& caps) = 0;
250 251
251 /** 252 /**
252 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this xfer 253 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this xfer
253 * processor's GL backend implementation. 254 * processor's GL backend implementation.
254 */ 255 */
255 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, 256 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
256 GrProcessorKeyBuilder* b) const = 0; 257 GrProcessorKeyBuilder* b) const = 0;
257 258
258 /** 259 /**
259 * If not using a texture barrier, retrieves whether the subclass will requi re a different type 260 * Determines the type of barrier (if any) required by the subclass. Note th at the possibility
260 * of barrier. 261 * that a kTexture type barrier is required is handled by the base class and need not be
262 * considered by subclass overrides of this function.
261 */ 263 */
262 virtual bool onWillNeedXferBarrier(const GrRenderTarget*, 264 virtual GrXferBarrierType onXferBarrier(const GrRenderTarget*, const GrCaps& ) const {
263 const GrCaps&, 265 return kNone_GrXferBarrierType;
264 GrXferBarrierType* outBarrierType SK_UNUS ED) const {
265 return false;
266 } 266 }
267 267
268 /** 268 /**
269 * If we are not performing a dst read, returns whether the subclass will se t a secondary 269 * If we are not performing a dst read, returns whether the subclass will se t a secondary
270 * output. When using dst reads, the base class controls the secondary outpu t and this method 270 * output. When using dst reads, the base class controls the secondary outpu t and this method
271 * will not be called. 271 * will not be called.
272 */ 272 */
273 virtual bool onHasSecondaryOutput() const { return false; } 273 virtual bool onHasSecondaryOutput() const { return false; }
274 274
275 /** 275 /**
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 enum { 398 enum {
399 kIllegalXPFClassID = 0, 399 kIllegalXPFClassID = 0,
400 }; 400 };
401 static int32_t gCurrXPFClassID; 401 static int32_t gCurrXPFClassID;
402 402
403 typedef GrProgramElement INHERITED; 403 typedef GrProgramElement INHERITED;
404 }; 404 };
405 405
406 #endif 406 #endif
407 407
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698