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

Side by Side Diff: src/gpu/gl/GrGLRenderTarget.h

Issue 1232103002: Enable stencil clipping in mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 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 8
9 #ifndef GrGLRenderTarget_DEFINED 9 #ifndef GrGLRenderTarget_DEFINED
10 #define GrGLRenderTarget_DEFINED 10 #define GrGLRenderTarget_DEFINED
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 /** When we don't own the FBO ID we don't attempt to modify its attachments. */ 64 /** When we don't own the FBO ID we don't attempt to modify its attachments. */
65 bool canAttemptStencilAttachment() const override { 65 bool canAttemptStencilAttachment() const override {
66 return kCached_LifeCycle == fRTLifecycle || kUncached_LifeCycle == fRTLi fecycle; 66 return kCached_LifeCycle == fRTLifecycle || kUncached_LifeCycle == fRTLi fecycle;
67 } 67 }
68 68
69 // GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture and renderbuffer 69 // GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture and renderbuffer
70 // components seperately. 70 // components seperately.
71 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override ; 71 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override ;
72 72
73 /**
74 * Some hardware allows overriding coordinates of sample locations in multis ampled
75 * render targets.
76 */
77 enum SampleLocationsConfig {
78 kDefault_SampleLocationsConfig = 0,
79 kProgrammable_SampleLocationsConfig = 1
80 };
Chris Dalton 2015/09/22 08:35:25 Just a thought -- we may want to consider putting
81
82 /** Returns sample locations config in use. */
83 SampleLocationsConfig sampleLocationsConfig() { return fSampleLocationsConfi g; }
84
85 /** Set sample locations config in use. */
86 void setSampleLocationsConfig(SampleLocationsConfig sampleLocationsConfig) {
87 fSampleLocationsConfig = sampleLocationsConfig;
88 }
89
90 /** Returns a pointer to default sample locations array. */
91 const float* defaultSampleLocations() { return fDefaultSampleLocations; }
92
93 /** Initializes default sample locations array with 'count' pairs of sample location coordinates. */
94 void setDefaultSampleLocations(int count, const float *sampleLocations) {
95 memcpy(fDefaultSampleLocations, sampleLocations, 2 * count * sizeof(fDef aultSampleLocations[0]));
96 }
97
98 /**
99 * @return true if programmable sample locations have been set for this
100 * render target. Requires support for NV_sample_locations.
101 */
102 bool usesProgrammableSampleLocations() const {
103 return fUsesProgrammableSampleLocations;
104 }
105
106 /**
107 * Flag render target as using or not using programmable sample locations.
108 */
109 void flagAsUsingProgrammableSampleLocations(bool useSampleLocations) {
110 fUsesProgrammableSampleLocations = useSampleLocations;
111 }
112
73 protected: 113 protected:
74 // The public constructor registers this object with the cache. However, onl y the most derived 114 // The public constructor registers this object with the cache. However, onl y the most derived
75 // class should register with the cache. This constructor does not do the re gistration and 115 // class should register with the cache. This constructor does not do the re gistration and
76 // rather moves that burden onto the derived class. 116 // rather moves that burden onto the derived class.
77 enum Derived { kDerived }; 117 enum Derived { kDerived };
78 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived); 118 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, Derived);
79 119
80 void init(const GrSurfaceDesc&, const IDDesc&); 120 void init(const GrSurfaceDesc&, const IDDesc&);
81 121
82 void onAbandon() override; 122 void onAbandon() override;
83 void onRelease() override; 123 void onRelease() override;
84 124
85 // In protected because subclass GrGLTextureRenderTarget calls this version. 125 // In protected because subclass GrGLTextureRenderTarget calls this version.
86 size_t onGpuMemorySize() const override; 126 size_t onGpuMemorySize() const override;
87 127
88 private: 128 private:
89 // This ctor is used only for creating wrapped render targets and is only ca lled for the static 129 // This ctor is used only for creating wrapped render targets and is only ca lled for the static
90 // create function CreateWrapped(...). 130 // create function CreateWrapped(...).
91 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, GrGLStencilA ttachment*); 131 GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, GrGLStencilA ttachment*);
92 132
93 GrGLGpu* getGLGpu() const; 133 GrGLGpu* getGLGpu() const;
94 bool completeStencilAttachment() override; 134 bool completeStencilAttachment() override;
95 135
96 // The total size of the resource (including all pixels) for a single sample . 136 // The total size of the resource (including all pixels) for a single sample .
97 size_t totalBytesPerSample() const; 137 size_t totalBytesPerSample() const;
98 int msaaSamples() const; 138 int msaaSamples() const;
99 // The number total number of samples, including both MSAA and resolve textu re samples. 139 // The number total number of samples, including both MSAA and resolve textu re samples.
100 int totalSamples() const; 140 int totalSamples() const;
101 141
102 GrGLuint fRTFBOID; 142 GrGLuint fRTFBOID;
103 GrGLuint fTexFBOID; 143 GrGLuint fTexFBOID;
104 GrGLuint fMSColorRenderbufferID; 144 GrGLuint fMSColorRenderbufferID;
105 145
106 // We track this separately from GrGpuResource because this may be both a te xture and a render 146 // We track this separately from GrGpuResource because this may be both a te xture and a render
107 // target, and the texture may be wrapped while the render target is not. 147 // target, and the texture may be wrapped while the render target is not.
108 LifeCycle fRTLifecycle; 148 LifeCycle fRTLifecycle;
109 149
110 // when we switch to this render target we want to set the viewport to 150 // when we switch to this render target we want to set the viewport to
111 // only render to content area (as opposed to the whole allocation) and 151 // only render to content area (as opposed to the whole allocation) and
112 // we want the rendering to be at top left (GL has origin in bottom left) 152 // we want the rendering to be at top left (GL has origin in bottom left)
113 GrGLIRect fViewport; 153 GrGLIRect fViewport;
114 154
115 // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However , abandon and 155 // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However , abandon and
116 // release zero out the IDs and the cache needs to know the size even after those actions. 156 // release zero out the IDs and the cache needs to know the size even after those actions.
117 size_t fGpuMemorySize; 157 size_t fGpuMemorySize;
158
159 // Configures sample locations to be either default or programmable, if MSAA .
160 SampleLocationsConfig fSampleLocationsConfig;
161 // Render target's default sample locations array, if MSAA.
162 float fDefaultSampleLocations[32];
163
164 bool fUsesProgrammableSampleLocations;
118 165
119 typedef GrRenderTarget INHERITED; 166 typedef GrRenderTarget INHERITED;
120 }; 167 };
121 168
122 #endif 169 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698