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

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

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 4 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 | « src/gpu/effects/GrDashingEffect.cpp ('k') | src/gpu/gl/GrGLGpu.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 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 GrGLGpu_DEFINED 8 #ifndef GrGLGpu_DEFINED
9 #define GrGLGpu_DEFINED 9 #define GrGLGpu_DEFINED
10 10
11 #include "GrGLContext.h" 11 #include "GrGLContext.h"
12 #include "GrGLIRect.h" 12 #include "GrGLIRect.h"
13 #include "GrGLIndexBuffer.h" 13 #include "GrGLIndexBuffer.h"
14 #include "GrGLPathRendering.h" 14 #include "GrGLPathRendering.h"
15 #include "GrGLProgram.h" 15 #include "GrGLProgram.h"
16 #include "GrGLRenderTarget.h" 16 #include "GrGLRenderTarget.h"
17 #include "GrGLStencilAttachment.h" 17 #include "GrGLStencilAttachment.h"
18 #include "GrGLTexture.h" 18 #include "GrGLTexture.h"
19 #include "GrGLTransferBuffer.h" 19 #include "GrGLTransferBuffer.h"
20 #include "GrGLVertexArray.h" 20 #include "GrGLVertexArray.h"
21 #include "GrGLVertexBuffer.h" 21 #include "GrGLVertexBuffer.h"
22 #include "GrGpu.h" 22 #include "GrGpu.h"
23 #include "GrPipelineBuilder.h" 23 #include "GrPipelineBuilder.h"
24 #include "GrTypes.h" 24 #include "GrTypes.h"
25 #include "GrXferProcessor.h" 25 #include "GrXferProcessor.h"
26 #include "SkTArray.h" 26 #include "SkTArray.h"
27 #include "SkTypes.h" 27 #include "SkTypes.h"
28 28
29 class GrPipeline; 29 class GrPipeline;
30 class GrNonInstancedVertices; 30 class GrNonInstancedMesh;
31 class GrSwizzle; 31 class GrSwizzle;
32 32
33 #ifdef SK_DEVELOPER 33 #ifdef SK_DEVELOPER
34 #define PROGRAM_CACHE_STATS 34 #define PROGRAM_CACHE_STATS
35 #endif 35 #endif
36 36
37 class GrGLGpu : public GrGpu { 37 class GrGLGpu : public GrGpu {
38 public: 38 public:
39 static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions & options, 39 static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions & options,
40 GrContext* context); 40 GrContext* context);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void notifyVertexArrayDelete(GrGLuint id) { 88 void notifyVertexArrayDelete(GrGLuint id) {
89 fHWGeometryState.notifyVertexArrayDelete(id); 89 fHWGeometryState.notifyVertexArrayDelete(id);
90 } 90 }
91 void notifyVertexBufferDelete(GrGLuint id) { 91 void notifyVertexBufferDelete(GrGLuint id) {
92 fHWGeometryState.notifyVertexBufferDelete(id); 92 fHWGeometryState.notifyVertexBufferDelete(id);
93 } 93 }
94 void notifyIndexBufferDelete(GrGLuint id) { 94 void notifyIndexBufferDelete(GrGLuint id) {
95 fHWGeometryState.notifyIndexBufferDelete(id); 95 fHWGeometryState.notifyIndexBufferDelete(id);
96 } 96 }
97 97
98 void buildProgramDesc(GrProgramDesc*,
99 const GrPrimitiveProcessor&,
100 const GrPipeline&) const override;
101
102 // id and type (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc.) of buffer to bind 98 // id and type (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc.) of buffer to bind
103 void bindBuffer(GrGLuint id, GrGLenum type); 99 void bindBuffer(GrGLuint id, GrGLenum type);
104 100
105 void releaseBuffer(GrGLuint id, GrGLenum type); 101 void releaseBuffer(GrGLuint id, GrGLenum type);
106 102
107 // sizes are in bytes 103 // sizes are in bytes
108 void* mapBuffer(GrGLuint id, GrGLenum type, GrGLBufferImpl::Usage usage, siz e_t currentSize, 104 void* mapBuffer(GrGLuint id, GrGLenum type, GrGLBufferImpl::Usage usage, siz e_t currentSize,
109 size_t requestedSize); 105 size_t requestedSize);
110 106
111 void unmapBuffer(GrGLuint id, GrGLenum type, void* mapPtr); 107 void unmapBuffer(GrGLuint id, GrGLenum type, void* mapPtr);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 GrPixelConfig config, 205 GrPixelConfig config,
210 const SkTArray<GrMipLevel>& texels) override; 206 const SkTArray<GrMipLevel>& texels) override;
211 207
212 bool onTransferPixels(GrSurface*, 208 bool onTransferPixels(GrSurface*,
213 int left, int top, int width, int height, 209 int left, int top, int width, int height,
214 GrPixelConfig config, GrTransferBuffer* buffer, 210 GrPixelConfig config, GrTransferBuffer* buffer,
215 size_t offset, size_t rowBytes) override; 211 size_t offset, size_t rowBytes) override;
216 212
217 void onResolveRenderTarget(GrRenderTarget* target) override; 213 void onResolveRenderTarget(GrRenderTarget* target) override;
218 214
219 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; 215 void onDraw(const GrPipeline&,
216 const GrPrimitiveProcessor&,
217 const GrMesh*,
218 int meshCount) override;
220 219
221 bool onCopySurface(GrSurface* dst, 220 bool onCopySurface(GrSurface* dst,
222 GrSurface* src, 221 GrSurface* src,
223 const SkIRect& srcRect, 222 const SkIRect& srcRect,
224 const SkIPoint& dstPoint) override; 223 const SkIPoint& dstPoint) override;
225 224
226 void onGetMultisampleSpecs(GrRenderTarget*, 225 void onGetMultisampleSpecs(GrRenderTarget*,
227 const GrStencilSettings&, 226 const GrStencilSettings&,
228 int* effectiveSampleCnt, 227 int* effectiveSampleCnt,
229 SkAutoTDeleteArray<SkPoint>* sampleLocations) ove rride; 228 SkAutoTDeleteArray<SkPoint>* sampleLocations) ove rride;
230 229
231 // binds texture unit in GL 230 // binds texture unit in GL
232 void setTextureUnit(int unitIdx); 231 void setTextureUnit(int unitIdx);
233 232
234 // Flushes state from GrPipeline to GL. Returns false if the state couldn't be set. 233 // Flushes state from GrPipeline to GL. Returns false if the state couldn't be set.
235 bool flushGLState(const DrawArgs&); 234 bool flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcessor& pr imProc);
236 235
237 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt es gives the offset 236 // Sets up vertex attribute pointers and strides. On return indexOffsetInByt es gives the offset
238 // an into the index buffer. It does not account for vertices.startIndex() b ut rather the start 237 // an into the index buffer. It does not account for vertices.startIndex() b ut rather the start
239 // index is relative to the returned offset. 238 // index is relative to the returned offset.
240 void setupGeometry(const GrPrimitiveProcessor&, 239 void setupGeometry(const GrPrimitiveProcessor&,
241 const GrNonInstancedVertices& vertices, 240 const GrNonInstancedMesh& mesh,
242 size_t* indexOffsetInBytes); 241 size_t* indexOffsetInBytes);
243 242
244 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle &); 243 void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle &);
245 244
246 bool hasExtension(const char* ext) const { return fGLContext->hasExtension(e xt); } 245 bool hasExtension(const char* ext) const { return fGLContext->hasExtension(e xt); }
247 246
248 void copySurfaceAsDraw(GrSurface* dst, 247 void copySurfaceAsDraw(GrSurface* dst,
249 GrSurface* src, 248 GrSurface* src,
250 const SkIRect& srcRect, 249 const SkIRect& srcRect,
251 const SkIPoint& dstPoint); 250 const SkIPoint& dstPoint);
252 void copySurfaceAsCopyTexSubImage(GrSurface* dst, 251 void copySurfaceAsCopyTexSubImage(GrSurface* dst,
253 GrSurface* src, 252 GrSurface* src,
254 const SkIRect& srcRect, 253 const SkIRect& srcRect,
255 const SkIPoint& dstPoint); 254 const SkIPoint& dstPoint);
256 bool copySurfaceAsBlitFramebuffer(GrSurface* dst, 255 bool copySurfaceAsBlitFramebuffer(GrSurface* dst,
257 GrSurface* src, 256 GrSurface* src,
258 const SkIRect& srcRect, 257 const SkIRect& srcRect,
259 const SkIPoint& dstPoint); 258 const SkIPoint& dstPoint);
260 259
261 void stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint p osXformUniform, 260 void stampRectUsingProgram(GrGLuint program, const SkRect& bounds, GrGLint p osXformUniform,
262 GrGLuint arrayBuffer); 261 GrGLuint arrayBuffer);
263 262
264 void setupPixelLocalStorage(const DrawArgs& args); 263 void setupPixelLocalStorage(const GrPipeline&, const GrPrimitiveProcessor&);
265 264
266 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); 265 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
267 266
268 class ProgramCache : public ::SkNoncopyable { 267 class ProgramCache : public ::SkNoncopyable {
269 public: 268 public:
270 ProgramCache(GrGLGpu* gpu); 269 ProgramCache(GrGLGpu* gpu);
271 ~ProgramCache(); 270 ~ProgramCache();
272 271
273 void reset(); 272 void reset();
274 void abandon(); 273 void abandon();
275 GrGLProgram* refProgram(const DrawArgs&); 274 GrGLProgram* refProgram(const GrGLGpu* gpu, const GrPipeline&, const GrP rimitiveProcessor&);
276 275
277 private: 276 private:
278 enum { 277 enum {
279 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new 278 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new
280 // shader before evicting from the cache. 279 // shader before evicting from the cache.
281 kMaxEntries = 128, 280 kMaxEntries = 128,
282 kHashBits = 6, 281 kHashBits = 6,
283 }; 282 };
284 283
285 struct Entry; 284 struct Entry;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } fPLSSetupProgram; 617 } fPLSSetupProgram;
619 618
620 bool fHWPLSEnabled; 619 bool fHWPLSEnabled;
621 bool fPLSHasBeenUsed; 620 bool fPLSHasBeenUsed;
622 621
623 typedef GrGpu INHERITED; 622 typedef GrGpu INHERITED;
624 friend class GrGLPathRendering; // For accessing setTextureUnit. 623 friend class GrGLPathRendering; // For accessing setTextureUnit.
625 }; 624 };
626 625
627 #endif 626 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDashingEffect.cpp ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698