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

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: GrRenderTarget::BufferBits, BackendRTDesc::fFlags and hasMixedSamplesModulation 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 unified diff | Download patch
« no previous file with comments | « no previous file | include/gpu/GrTypes.h » ('j') | src/gpu/GrContext.cpp » ('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() override { return this; } 29 GrRenderTarget* asRenderTarget() override { return this; }
30 const GrRenderTarget* asRenderTarget() const override { return this; } 30 const GrRenderTarget* asRenderTarget() const 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 buffers. This enum allows the caller to query about
36 * specific buffers in isMultisampled() and numSamples().
35 */ 37 */
36 bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } 38 enum BufferBits {
39 kAny_BufferBits = 0,
40 kColor_BufferBit = 1,
41 kStencil_BufferBit = (1 << 1),
42 kAll_BufferBits = kColor_BufferBit + kStencil_BufferBit
43 };
37 44
38 /** 45 /**
39 * @return the number of samples-per-pixel or zero if non-MSAA. 46 * Enforce only two legal sample configs.
47 * kUnified_SampleConfig signifies multisampling in both color and stencil
48 * buffers and is available across all hardware.
49 * kStencil_SampleConfig means multisampling is present in stencil buffer
50 * only; this config requires hardware support of
51 * NV_framebuffer_mixed_samples.
52 */
53 enum SampleConfig {
54 kUnified_SampleConfig = kColor_BufferBit + kStencil_BufferBit,
55 kStencil_SampleConfig = kStencil_BufferBit
56 };
57
58 /**
59 * @param buffers specifies the buffers for which multisampling is queried
60 * @return true if the surface is multisampled in the specified buffer(s),
Chris Dalton 2015/04/07 23:48:23 Nit picking, but this is maybe ambiguous. How abou
vbuzinov 2015/04/08 12:05:30 Done.
61 * false otherwise
40 */ 62 */
41 int numSamples() const { return fDesc.fSampleCnt; } 63 bool isMultisampled(BufferBits buffers = kAll_BufferBits) const {
64 if (buffers != (fSampleConfig & buffers)) {
65 // One of the buffers is not in our msaa config.
66 return false;
67 }
68 return 0 != fDesc.fSampleCnt;
69 }
70
71 /**
72 * @param buffers specifies the buffers for which multisampling is queried
73 * @return the number of samples-per-pixel, or zero if the render target
74 * is not multisampled in the specified buffer(s)
Chris Dalton 2015/04/07 23:48:23 Here too: "@return the number of samples-per-pixe
vbuzinov 2015/04/08 12:05:30 Done.
75 */
76 int numSamples(BufferBits buffers = kAll_BufferBits) const {
77 return this->isMultisampled(buffers) ? fDesc.fSampleCnt : 0;
78 }
79
80 /**
81 * @return sample config: kUnified_SampleConfig if both color and stencil
82 buffers are MSAA, or kStencil_SampleConfig if only stencil
83 buffer is MSAA.
84 */
85 SampleConfig sampleConfig() const {
86 return fSampleConfig;
87 }
42 88
43 /** 89 /**
44 * Call to indicate the multisample contents were modified such that the 90 * 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 91 * 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 92 * 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 93 * when the render target has been modified outside of Gr. This has no
48 * effect on wrapped backend render targets. 94 * effect on wrapped backend render targets.
49 * 95 *
50 * @param rect a rect bounding the area needing resolve. NULL indicates 96 * @param rect a rect bounding the area needing resolve. NULL indicates
51 * the whole RT needs resolving. 97 * the whole RT needs resolving.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 kAutoResolves_ResolveType, 133 kAutoResolves_ResolveType,
88 kCantResolve_ResolveType, 134 kCantResolve_ResolveType,
89 }; 135 };
90 virtual ResolveType getResolveType() const = 0; 136 virtual ResolveType getResolveType() const = 0;
91 137
92 // Provides access to functions that aren't part of the public API. 138 // Provides access to functions that aren't part of the public API.
93 GrRenderTargetPriv renderTargetPriv(); 139 GrRenderTargetPriv renderTargetPriv();
94 const GrRenderTargetPriv renderTargetPriv() const; 140 const GrRenderTargetPriv renderTargetPriv() const;
95 141
96 protected: 142 protected:
97 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc) 143 GrRenderTarget(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc,
144 SampleConfig sampleConfig)
98 : INHERITED(gpu, lifeCycle, desc) 145 : INHERITED(gpu, lifeCycle, desc)
146 , fSampleConfig(sampleConfig)
99 , fStencilBuffer(NULL) { 147 , fStencilBuffer(NULL) {
100 fResolveRect.setLargestInverted(); 148 fResolveRect.setLargestInverted();
101 } 149 }
102 150
103 // override of GrResource 151 // override of GrResource
104 void onAbandon() override; 152 void onAbandon() override;
105 void onRelease() override; 153 void onRelease() override;
106 154
107 private: 155 private:
108 // Checked when this object is asked to attach a stencil buffer. 156 // Checked when this object is asked to attach a stencil buffer.
109 virtual bool canAttemptStencilAttachment() const = 0; 157 virtual bool canAttemptStencilAttachment() const = 0;
110 158
111 friend class GrRenderTargetPriv; 159 friend class GrRenderTargetPriv;
112 160
161 SampleConfig fSampleConfig;
162
113 GrStencilBuffer* fStencilBuffer; 163 GrStencilBuffer* fStencilBuffer;
114 164
115 SkIRect fResolveRect; 165 SkIRect fResolveRect;
116 166
117 typedef GrSurface INHERITED; 167 typedef GrSurface INHERITED;
118 }; 168 };
119 169
170 GR_MAKE_BITFIELD_OPS(GrRenderTarget::BufferBits)
171
120 #endif 172 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrTypes.h » ('j') | src/gpu/GrContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698