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

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

Issue 1001503002: Implement support for mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@mix1
Patch Set: GrProcOptInfo bug Created 5 years, 9 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 | include/gpu/GrTypes.h » ('j') | include/gpu/GrTypes.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 GrRenderTarget_DEFINED 8 #ifndef GrRenderTarget_DEFINED
9 #define GrRenderTarget_DEFINED 9 #define GrRenderTarget_DEFINED
10 10
(...skipping 13 matching lines...) Expand all
24 class GrRenderTarget : virtual public GrSurface { 24 class GrRenderTarget : virtual public GrSurface {
25 public: 25 public:
26 SK_DECLARE_INST_COUNT(GrRenderTarget) 26 SK_DECLARE_INST_COUNT(GrRenderTarget)
27 27
28 // GrSurface overrides 28 // GrSurface overrides
29 GrRenderTarget* asRenderTarget() SK_OVERRIDE { return this; } 29 GrRenderTarget* asRenderTarget() SK_OVERRIDE { return this; }
30 const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return this; } 30 const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return this; }
31 31
32 // GrRenderTarget 32 // GrRenderTarget
33 /** 33 /**
34 * @return true if the surface is multisampled, false otherwise 34 * On some hardware it is possible for a render target to have multisampling
35 * only in certain stages of the graphics pipeline. This enum allows
36 * the caller to query about specific stages in isMultisampled() and
37 * numSamples().
35 */ 38 */
36 bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } 39 enum PipelineStage {
bsalomon 2015/03/31 16:37:33 I'm not sure about this name... enum BufferType
Chris Dalton 2015/03/31 19:47:30 I'm going to try replying inline. Hopefully it wor
Chris Dalton 2015/03/31 22:24:57 Sorry to pollute your inboxes :) I've thought abou
vbuzinov 2015/04/02 13:10:37 This bitfield implementation is certainly easier t
40 kColorBuffer_PipelineStage,
41 kStencilBuffer_PipelineStage,
42 // We only support two sample configs at the moment, unified and
43 // stencil. So we can query multisample info for everywhere/anywhere
44 // by checking the correct buffer.
45 kEverywhere_PipelineStage = kColorBuffer_PipelineStage,
46 kAnywhere_PipelineStage = kStencilBuffer_PipelineStage
47 };
37 48
38 /** 49 /**
39 * @return the number of samples-per-pixel or zero if non-MSAA. 50 * @param pipelineStage specifies the pipeline stage for which
51 * multisampling is queried
52 * @return true if the surface is multisampled in the specified pipeline
53 * stage(s), false otherwise
40 */ 54 */
41 int numSamples() const { return fDesc.fSampleCnt; } 55 bool isMultisampled(PipelineStage pipelineStage =
56 kEverywhere_PipelineStage) const {
57 if (kStencil_GrSampleConfig == fSampleConfig &&
58 kColorBuffer_PipelineStage == pipelineStage) {
59 return false;
60 }
61 return 0 != fDesc.fSampleCnt;
62 }
63
64 /**
65 * @param pipelineStage specifies the pipeline stage for which
66 * multisampling is queried
67 * @return the number of samples-per-pixel, or zero if the render target
68 * is not multisampled in the specified pipeline stage(s)
69 */
70 int numSamples(PipelineStage pipelineStage =
71 kEverywhere_PipelineStage) const {
72 return this->isMultisampled(pipelineStage) ? fDesc.fSampleCnt : 0;
73 }
74
75 /**
76 * @return sample config: kUnified_GrSampleConfig if both color and stencil
77 buffers are MSAA, or kStencil_GrSampleConfig if only stencil
78 buffer is MSAA.
79 */
80 GrSampleConfig sampleConfig() const {
81 return fSampleConfig;
82 }
42 83
43 /** 84 /**
44 * Call to indicate the multisample contents were modified such that the 85 * Call to indicate the multisample contents were modified such that the
45 * render target needs to be resolved before it can be used as texture. Gr 86 * render target needs to be resolved before it can be used as texture. Gr
46 * tracks this for its own drawing and thus this only needs to be called 87 * tracks this for its own drawing and thus this only needs to be called
47 * when the render target has been modified outside of Gr. This has no 88 * when the render target has been modified outside of Gr. This has no
48 * effect on wrapped backend render targets. 89 * effect on wrapped backend render targets.
49 * 90 *
50 * @param rect a rect bounding the area needing resolve. NULL indicates 91 * @param rect a rect bounding the area needing resolve. NULL indicates
51 * the whole RT needs resolving. 92 * the whole RT needs resolving.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 kAutoResolves_ResolveType, 128 kAutoResolves_ResolveType,
88 kCantResolve_ResolveType, 129 kCantResolve_ResolveType,
89 }; 130 };
90 virtual ResolveType getResolveType() const = 0; 131 virtual ResolveType getResolveType() const = 0;
91 132
92 // Provides access to functions that aren't part of the public API. 133 // Provides access to functions that aren't part of the public API.
93 GrRenderTargetPriv renderTargetPriv(); 134 GrRenderTargetPriv renderTargetPriv();
94 const GrRenderTargetPriv renderTargetPriv() const; 135 const GrRenderTargetPriv renderTargetPriv() const;
95 136
96 protected: 137 protected:
97 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) 138 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc,
139 GrSampleConfig sampleConfig)
98 : INHERITED(gpu, lifeCycle, desc) 140 : INHERITED(gpu, lifeCycle, desc)
141 , fSampleConfig(sampleConfig)
99 , fStencilBuffer(NULL) { 142 , fStencilBuffer(NULL) {
100 fResolveRect.setLargestInverted(); 143 fResolveRect.setLargestInverted();
101 } 144 }
102 145
103 // override of GrResource 146 // override of GrResource
104 void onAbandon() SK_OVERRIDE; 147 void onAbandon() SK_OVERRIDE;
105 void onRelease() SK_OVERRIDE; 148 void onRelease() SK_OVERRIDE;
106 149
107 private: 150 private:
108 // Checked when this object is asked to attach a stencil buffer. 151 // Checked when this object is asked to attach a stencil buffer.
109 virtual bool canAttemptStencilAttachment() const = 0; 152 virtual bool canAttemptStencilAttachment() const = 0;
110 153
111 friend class GrRenderTargetPriv; 154 friend class GrRenderTargetPriv;
112 155
156 GrSampleConfig fSampleConfig;
157
113 GrStencilBuffer* fStencilBuffer; 158 GrStencilBuffer* fStencilBuffer;
114 159
115 SkIRect fResolveRect; 160 SkIRect fResolveRect;
116 161
117 typedef GrSurface INHERITED; 162 typedef GrSurface INHERITED;
118 }; 163 };
119 164
120 #endif 165 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrTypes.h » ('j') | include/gpu/GrTypes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698