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

Side by Side Diff: src/gpu/GrGpu.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/GrBatchFlushState.h ('k') | src/gpu/GrGpu.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 GrGpu_DEFINED 8 #ifndef GrGpu_DEFINED
9 #define GrGpu_DEFINED 9 #define GrGpu_DEFINED
10 10
11 #include "GrPipelineBuilder.h" 11 #include "GrPipelineBuilder.h"
12 #include "GrProgramDesc.h" 12 #include "GrProgramDesc.h"
13 #include "GrStencil.h" 13 #include "GrStencil.h"
14 #include "GrSwizzle.h" 14 #include "GrSwizzle.h"
15 #include "GrAllocator.h" 15 #include "GrAllocator.h"
16 #include "GrTextureParamsAdjuster.h" 16 #include "GrTextureParamsAdjuster.h"
17 #include "GrTypes.h" 17 #include "GrTypes.h"
18 #include "GrXferProcessor.h" 18 #include "GrXferProcessor.h"
19 #include "SkPath.h" 19 #include "SkPath.h"
20 #include "SkTArray.h" 20 #include "SkTArray.h"
21 21
22 class GrBatchTracker; 22 class GrBatchTracker;
23 class GrContext; 23 class GrContext;
24 class GrGLContext; 24 class GrGLContext;
25 class GrIndexBuffer; 25 class GrIndexBuffer;
26 class GrMesh;
26 class GrNonInstancedVertices; 27 class GrNonInstancedVertices;
27 class GrPath; 28 class GrPath;
28 class GrPathRange; 29 class GrPathRange;
29 class GrPathRenderer; 30 class GrPathRenderer;
30 class GrPathRendererChain; 31 class GrPathRendererChain;
31 class GrPathRendering; 32 class GrPathRendering;
32 class GrPipeline; 33 class GrPipeline;
33 class GrPrimitiveProcessor; 34 class GrPrimitiveProcessor;
34 class GrRenderTarget; 35 class GrRenderTarget;
35 class GrStencilAttachment; 36 class GrStencilAttachment;
36 class GrSurface; 37 class GrSurface;
37 class GrTexture; 38 class GrTexture;
38 class GrTransferBuffer; 39 class GrTransferBuffer;
39 class GrVertexBuffer; 40 class GrVertexBuffer;
40 class GrVertices;
41 41
42 class GrGpu : public SkRefCnt { 42 class GrGpu : public SkRefCnt {
43 public: 43 public:
44 /** 44 /**
45 * Create an instance of GrGpu that matches the specified backend. If the re quested backend is 45 * Create an instance of GrGpu that matches the specified backend. If the re quested backend is
46 * not supported (at compile-time or run-time) this returns nullptr. The con text will not be 46 * not supported (at compile-time or run-time) this returns nullptr. The con text will not be
47 * fully constructed and should not be used by GrGpu until after this functi on returns. 47 * fully constructed and should not be used by GrGpu until after this functi on returns.
48 */ 48 */
49 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G rContext* context); 49 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G rContext* context);
50 50
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // a billion years. 346 // a billion years.
347 typedef uint64_t ResetTimestamp; 347 typedef uint64_t ResetTimestamp;
348 348
349 // This timestamp is always older than the current timestamp 349 // This timestamp is always older than the current timestamp
350 static const ResetTimestamp kExpiredTimestamp = 0; 350 static const ResetTimestamp kExpiredTimestamp = 0;
351 // Returns a timestamp based on the number of times the context was reset. 351 // Returns a timestamp based on the number of times the context was reset.
352 // This timestamp can be used to lazily detect when cached 3D context state 352 // This timestamp can be used to lazily detect when cached 3D context state
353 // is dirty. 353 // is dirty.
354 ResetTimestamp getResetTimestamp() const { return fResetTimestamp; } 354 ResetTimestamp getResetTimestamp() const { return fResetTimestamp; }
355 355
356 virtual void buildProgramDesc(GrProgramDesc*,
357 const GrPrimitiveProcessor&,
358 const GrPipeline&) const = 0;
359
360 // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst 356 // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst
361 // take place at the GrDrawTarget level and this function implement faster c opy paths. The rect 357 // take place at the GrDrawTarget level and this function implement faster c opy paths. The rect
362 // and point are pre-clipped. The src rect and implied dst rect are guarante ed to be within the 358 // and point are pre-clipped. The src rect and implied dst rect are guarante ed to be within the
363 // src/dst bounds and non-empty. 359 // src/dst bounds and non-empty.
364 bool copySurface(GrSurface* dst, 360 bool copySurface(GrSurface* dst,
365 GrSurface* src, 361 GrSurface* src,
366 const SkIRect& srcRect, 362 const SkIRect& srcRect,
367 const SkIPoint& dstPoint); 363 const SkIPoint& dstPoint);
368 364
369 struct MultisampleSpecs { 365 struct MultisampleSpecs {
370 // Nonzero ID that uniquely identifies these multisample specs. 366 // Nonzero ID that uniquely identifies these multisample specs.
371 uint8_t fUniqueID; 367 uint8_t fUniqueID;
372 // The actual number of samples the GPU will run. NOTE: this value can b e greater than the 368 // The actual number of samples the GPU will run. NOTE: this value can b e greater than the
373 // the render target's sample count. 369 // the render target's sample count.
374 int fEffectiveSampleCnt; 370 int fEffectiveSampleCnt;
375 // If sample locations are supported, contains the subpixel locations at which the GPU will 371 // If sample locations are supported, contains the subpixel locations at which the GPU will
376 // sample. Pixel center is at (.5, .5) and (0, 0) indicates the top left corner. 372 // sample. Pixel center is at (.5, .5) and (0, 0) indicates the top left corner.
377 SkAutoTDeleteArray<const SkPoint> fSampleLocations; 373 SkAutoTDeleteArray<const SkPoint> fSampleLocations;
378 }; 374 };
379 375
380 // Finds a render target's multisample specs. The stencil settings are only needed to flush the 376 // Finds a render target's multisample specs. The stencil settings are only needed to flush the
381 // draw state prior to querying multisample information; they should not hav e any effect on the 377 // draw state prior to querying multisample information; they should not hav e any effect on the
382 // multisample information itself. 378 // multisample information itself.
383 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil Settings&); 379 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil Settings&);
384 380
385 struct DrawArgs { 381 // We pass in an array of meshCount GrMesh to the draw. The backend should l oop over each
386 DrawArgs(const GrPrimitiveProcessor* primProc, 382 // GrMesh object and emit a draw for it. Each draw will use the same GrPipel ine and
387 const GrPipeline* pipeline, 383 // GrPrimitiveProcessor.
388 const GrProgramDesc* desc) 384 void draw(const GrPipeline&,
389 : fPrimitiveProcessor(primProc) 385 const GrPrimitiveProcessor&,
390 , fPipeline(pipeline) 386 const GrMesh*,
391 , fDesc(desc) { 387 int meshCount);
392 SkASSERT(primProc && pipeline && desc);
393 }
394 const GrPrimitiveProcessor* fPrimitiveProcessor;
395 const GrPipeline* fPipeline;
396 const GrProgramDesc* fDesc;
397 };
398
399 void draw(const DrawArgs&, const GrVertices&);
400 388
401 // Called by drawtarget when flushing. 389 // Called by drawtarget when flushing.
402 // Provides a hook for post-flush actions (e.g. PLS reset and Vulkan command buffer submits). 390 // Provides a hook for post-flush actions (e.g. PLS reset and Vulkan command buffer submits).
403 virtual void finishDrawTarget() {} 391 virtual void finishDrawTarget() {}
404 392
405 /////////////////////////////////////////////////////////////////////////// 393 ///////////////////////////////////////////////////////////////////////////
406 // Debugging and Stats 394 // Debugging and Stats
407 395
408 class Stats { 396 class Stats {
409 public: 397 public:
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 GrWrapOwnership) = 0; 552 GrWrapOwnership) = 0;
565 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&, 553 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe xtureDesc&,
566 GrWrapOwnership) = 0; 554 GrWrapOwnership) = 0;
567 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 555 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0;
568 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; 556 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
569 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t ype) = 0; 557 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t ype) = 0;
570 558
571 // overridden by backend-specific derived class to perform the clear. 559 // overridden by backend-specific derived class to perform the clear.
572 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; 560 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0;
573 561
574
575 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is 562 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is
576 // ONLY used by the the clip target 563 // ONLY used by the the clip target
577 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; 564 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0;
578 565
579 // overridden by backend-specific derived class to perform the draw call. 566 // overridden by backend-specific derived class to perform the draw call.
580 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; 567 virtual void onDraw(const GrPipeline&,
568 const GrPrimitiveProcessor&,
569 const GrMesh*,
570 int meshCount) = 0;
581 571
582 virtual bool onMakeCopyForTextureParams(GrTexture* texture, const GrTextureP arams&, 572 virtual bool onMakeCopyForTextureParams(GrTexture* texture, const GrTextureP arams&,
583 GrTextureProducer::CopyParams*) cons t { return false; } 573 GrTextureProducer::CopyParams*) cons t { return false; }
584 574
585 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r eadHeight, 575 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r eadHeight,
586 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, 576 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*,
587 ReadPixelTempDrawInfo*) = 0; 577 ReadPixelTempDrawInfo*) = 0;
588 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig ht, 578 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig ht,
589 GrPixelConfig srcConfig, DrawPreference*, 579 GrPixelConfig srcConfig, DrawPreference*,
590 WritePixelTempDrawInfo*) = 0; 580 WritePixelTempDrawInfo*) = 0;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 SkTArray<const MultisampleSpecs*, true> fMultisa mpleSpecsMap; 625 SkTArray<const MultisampleSpecs*, true> fMultisa mpleSpecsMap;
636 GrTAllocator<MultisampleSpecs> fMultisa mpleSpecsAllocator; 626 GrTAllocator<MultisampleSpecs> fMultisa mpleSpecsAllocator;
637 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 627 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
638 GrContext* fContext ; 628 GrContext* fContext ;
639 629
640 friend class GrPathRendering; 630 friend class GrPathRendering;
641 typedef SkRefCnt INHERITED; 631 typedef SkRefCnt INHERITED;
642 }; 632 };
643 633
644 #endif 634 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrBatchFlushState.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698