xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrCaps.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Worker 
2*c8dee2aaSAndroid Build Coastguard Worker /*
3*c8dee2aaSAndroid Build Coastguard Worker  * Copyright 2013 Google Inc.
4*c8dee2aaSAndroid Build Coastguard Worker  *
5*c8dee2aaSAndroid Build Coastguard Worker  * Use of this source code is governed by a BSD-style license that can be
6*c8dee2aaSAndroid Build Coastguard Worker  * found in the LICENSE file.
7*c8dee2aaSAndroid Build Coastguard Worker  */
8*c8dee2aaSAndroid Build Coastguard Worker #ifndef GrCaps_DEFINED
9*c8dee2aaSAndroid Build Coastguard Worker #define GrCaps_DEFINED
10*c8dee2aaSAndroid Build Coastguard Worker 
11*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkCapabilities.h"
12*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkRefCnt.h"
13*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkTypes.h"
14*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/GpuTypes.h"
15*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrDriverBugWorkarounds.h"
16*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrTypes.h"
17*c8dee2aaSAndroid Build Coastguard Worker #include "include/private/base/SkMacros.h"
18*c8dee2aaSAndroid Build Coastguard Worker #include "include/private/base/SkTo.h"
19*c8dee2aaSAndroid Build Coastguard Worker #include "include/private/gpu/ganesh/GrTypesPriv.h"
20*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/Blend.h"
21*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/Swizzle.h"
22*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/ganesh/GrSamplerState.h"
23*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/ganesh/GrShaderCaps.h"
24*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/ganesh/GrSurfaceProxy.h"
25*c8dee2aaSAndroid Build Coastguard Worker 
26*c8dee2aaSAndroid Build Coastguard Worker #include <algorithm>
27*c8dee2aaSAndroid Build Coastguard Worker #include <cstddef>
28*c8dee2aaSAndroid Build Coastguard Worker #include <cstdint>
29*c8dee2aaSAndroid Build Coastguard Worker #include <memory>
30*c8dee2aaSAndroid Build Coastguard Worker #include <string>
31*c8dee2aaSAndroid Build Coastguard Worker #include <string_view>
32*c8dee2aaSAndroid Build Coastguard Worker #include <tuple>
33*c8dee2aaSAndroid Build Coastguard Worker #include <vector>
34*c8dee2aaSAndroid Build Coastguard Worker 
35*c8dee2aaSAndroid Build Coastguard Worker class GrBackendFormat;
36*c8dee2aaSAndroid Build Coastguard Worker class GrBackendRenderTarget;
37*c8dee2aaSAndroid Build Coastguard Worker class GrProgramDesc;
38*c8dee2aaSAndroid Build Coastguard Worker class GrProgramInfo;
39*c8dee2aaSAndroid Build Coastguard Worker class GrRenderTarget;
40*c8dee2aaSAndroid Build Coastguard Worker class GrRenderTargetProxy;
41*c8dee2aaSAndroid Build Coastguard Worker class GrSurface;
42*c8dee2aaSAndroid Build Coastguard Worker class SkJSONWriter;
43*c8dee2aaSAndroid Build Coastguard Worker enum class SkTextureCompressionType;
44*c8dee2aaSAndroid Build Coastguard Worker struct GrContextOptions;
45*c8dee2aaSAndroid Build Coastguard Worker struct SkIRect;
46*c8dee2aaSAndroid Build Coastguard Worker struct SkISize;
47*c8dee2aaSAndroid Build Coastguard Worker 
48*c8dee2aaSAndroid Build Coastguard Worker namespace skgpu {
49*c8dee2aaSAndroid Build Coastguard Worker     class KeyBuilder;
50*c8dee2aaSAndroid Build Coastguard Worker }
51*c8dee2aaSAndroid Build Coastguard Worker namespace GrTest {
52*c8dee2aaSAndroid Build Coastguard Worker     struct TestFormatColorTypeCombination;
53*c8dee2aaSAndroid Build Coastguard Worker }
54*c8dee2aaSAndroid Build Coastguard Worker 
55*c8dee2aaSAndroid Build Coastguard Worker /**
56*c8dee2aaSAndroid Build Coastguard Worker  * Represents the capabilities of a GrContext.
57*c8dee2aaSAndroid Build Coastguard Worker  */
58*c8dee2aaSAndroid Build Coastguard Worker class GrCaps : public SkCapabilities {
59*c8dee2aaSAndroid Build Coastguard Worker public:
60*c8dee2aaSAndroid Build Coastguard Worker     GrCaps(const GrContextOptions&);
61*c8dee2aaSAndroid Build Coastguard Worker 
62*c8dee2aaSAndroid Build Coastguard Worker     void dumpJSON(SkJSONWriter*) const;
63*c8dee2aaSAndroid Build Coastguard Worker 
shaderCaps()64*c8dee2aaSAndroid Build Coastguard Worker     const GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); }
65*c8dee2aaSAndroid Build Coastguard Worker 
66*c8dee2aaSAndroid Build Coastguard Worker #if defined(GPU_TEST_UTILS)
deviceName()67*c8dee2aaSAndroid Build Coastguard Worker     std::string_view deviceName() const { return fDeviceName; }
68*c8dee2aaSAndroid Build Coastguard Worker #endif
69*c8dee2aaSAndroid Build Coastguard Worker 
npotTextureTileSupport()70*c8dee2aaSAndroid Build Coastguard Worker     bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
71*c8dee2aaSAndroid Build Coastguard Worker     /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
72*c8dee2aaSAndroid Build Coastguard Worker         only for POT textures) */
mipmapSupport()73*c8dee2aaSAndroid Build Coastguard Worker     bool mipmapSupport() const { return fMipmapSupport; }
74*c8dee2aaSAndroid Build Coastguard Worker     /** Is anisotropic filtering supported. */
anisoSupport()75*c8dee2aaSAndroid Build Coastguard Worker     bool anisoSupport() const { return fAnisoSupport; }
76*c8dee2aaSAndroid Build Coastguard Worker 
gpuTracingSupport()77*c8dee2aaSAndroid Build Coastguard Worker     bool gpuTracingSupport() const { return fGpuTracingSupport; }
oversizedStencilSupport()78*c8dee2aaSAndroid Build Coastguard Worker     bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
textureBarrierSupport()79*c8dee2aaSAndroid Build Coastguard Worker     bool textureBarrierSupport() const { return fTextureBarrierSupport; }
sampleLocationsSupport()80*c8dee2aaSAndroid Build Coastguard Worker     bool sampleLocationsSupport() const { return fSampleLocationsSupport; }
drawInstancedSupport()81*c8dee2aaSAndroid Build Coastguard Worker     bool drawInstancedSupport() const { return fDrawInstancedSupport; }
82*c8dee2aaSAndroid Build Coastguard Worker     // Is there hardware support for indirect draws? (Ganesh always supports indirect draws as long
83*c8dee2aaSAndroid Build Coastguard Worker     // as it can polyfill them with instanced calls, but this cap tells us if they are supported
84*c8dee2aaSAndroid Build Coastguard Worker     // natively.)
nativeDrawIndirectSupport()85*c8dee2aaSAndroid Build Coastguard Worker     bool nativeDrawIndirectSupport() const { return fNativeDrawIndirectSupport; }
useClientSideIndirectBuffers()86*c8dee2aaSAndroid Build Coastguard Worker     bool useClientSideIndirectBuffers() const {
87*c8dee2aaSAndroid Build Coastguard Worker #ifdef SK_DEBUG
88*c8dee2aaSAndroid Build Coastguard Worker         if (!fNativeDrawIndirectSupport || fNativeDrawIndexedIndirectIsBroken) {
89*c8dee2aaSAndroid Build Coastguard Worker             // We might implement indirect draws with a polyfill, so the commands need to reside in
90*c8dee2aaSAndroid Build Coastguard Worker             // CPU memory.
91*c8dee2aaSAndroid Build Coastguard Worker             SkASSERT(fUseClientSideIndirectBuffers);
92*c8dee2aaSAndroid Build Coastguard Worker         }
93*c8dee2aaSAndroid Build Coastguard Worker #endif
94*c8dee2aaSAndroid Build Coastguard Worker         return fUseClientSideIndirectBuffers;
95*c8dee2aaSAndroid Build Coastguard Worker     }
conservativeRasterSupport()96*c8dee2aaSAndroid Build Coastguard Worker     bool conservativeRasterSupport() const { return fConservativeRasterSupport; }
wireframeSupport()97*c8dee2aaSAndroid Build Coastguard Worker     bool wireframeSupport() const { return fWireframeSupport; }
98*c8dee2aaSAndroid Build Coastguard Worker     // This flag indicates that we never have to resolve MSAA. In practice, it means that we have
99*c8dee2aaSAndroid Build Coastguard Worker     // an MSAA-render-to-texture extension: Any render target we create internally will use the
100*c8dee2aaSAndroid Build Coastguard Worker     // extension, and any wrapped render target is the client's responsibility.
msaaResolvesAutomatically()101*c8dee2aaSAndroid Build Coastguard Worker     bool msaaResolvesAutomatically() const { return fMSAAResolvesAutomatically; }
102*c8dee2aaSAndroid Build Coastguard Worker     // If true then when doing MSAA draws, we will prefer to discard the msaa attachment on load
103*c8dee2aaSAndroid Build Coastguard Worker     // and stores. The use of this feature for specific draws depends on the render target having a
104*c8dee2aaSAndroid Build Coastguard Worker     // resolve attachment, and if we need to load previous data the resolve attachment must be
105*c8dee2aaSAndroid Build Coastguard Worker     // usable as an input attachment/texture. Otherwise we will just write out and store the msaa
106*c8dee2aaSAndroid Build Coastguard Worker     // attachment like normal.
107*c8dee2aaSAndroid Build Coastguard Worker     // This flag is similar to enabling gl render to texture for msaa rendering.
preferDiscardableMSAAAttachment()108*c8dee2aaSAndroid Build Coastguard Worker     bool preferDiscardableMSAAAttachment() const { return fPreferDiscardableMSAAAttachment; }
halfFloatVertexAttributeSupport()109*c8dee2aaSAndroid Build Coastguard Worker     bool halfFloatVertexAttributeSupport() const { return fHalfFloatVertexAttributeSupport; }
110*c8dee2aaSAndroid Build Coastguard Worker 
111*c8dee2aaSAndroid Build Coastguard Worker     // Primitive restart functionality is core in ES 3.0, but using it will cause slowdowns on some
112*c8dee2aaSAndroid Build Coastguard Worker     // systems. This cap is only set if primitive restart will improve performance.
usePrimitiveRestart()113*c8dee2aaSAndroid Build Coastguard Worker     bool usePrimitiveRestart() const { return fUsePrimitiveRestart; }
114*c8dee2aaSAndroid Build Coastguard Worker 
preferClientSideDynamicBuffers()115*c8dee2aaSAndroid Build Coastguard Worker     bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; }
116*c8dee2aaSAndroid Build Coastguard Worker 
117*c8dee2aaSAndroid Build Coastguard Worker     // On tilers, an initial fullscreen clear is an OPTIMIZATION. It allows the hardware to
118*c8dee2aaSAndroid Build Coastguard Worker     // initialize each tile with a constant value rather than loading each pixel from memory.
preferFullscreenClears()119*c8dee2aaSAndroid Build Coastguard Worker     bool preferFullscreenClears() const { return fPreferFullscreenClears; }
120*c8dee2aaSAndroid Build Coastguard Worker 
121*c8dee2aaSAndroid Build Coastguard Worker     // Should we discard stencil values after a render pass? (Tilers get better performance if we
122*c8dee2aaSAndroid Build Coastguard Worker     // always load stencil buffers with a "clear" op, and then discard the content when finished.)
discardStencilValuesAfterRenderPass()123*c8dee2aaSAndroid Build Coastguard Worker     bool discardStencilValuesAfterRenderPass() const {
124*c8dee2aaSAndroid Build Coastguard Worker         // b/160958008
125*c8dee2aaSAndroid Build Coastguard Worker         return false;
126*c8dee2aaSAndroid Build Coastguard Worker #if 0
127*c8dee2aaSAndroid Build Coastguard Worker         // This method is actually just a duplicate of preferFullscreenClears(), with a descriptive
128*c8dee2aaSAndroid Build Coastguard Worker         // name for the sake of readability.
129*c8dee2aaSAndroid Build Coastguard Worker         return this->preferFullscreenClears();
130*c8dee2aaSAndroid Build Coastguard Worker #endif
131*c8dee2aaSAndroid Build Coastguard Worker     }
132*c8dee2aaSAndroid Build Coastguard Worker 
133*c8dee2aaSAndroid Build Coastguard Worker     // D3D does not allow the refs or masks to differ on a two-sided stencil draw.
twoSidedStencilRefsAndMasksMustMatch()134*c8dee2aaSAndroid Build Coastguard Worker     bool twoSidedStencilRefsAndMasksMustMatch() const {
135*c8dee2aaSAndroid Build Coastguard Worker         return fTwoSidedStencilRefsAndMasksMustMatch;
136*c8dee2aaSAndroid Build Coastguard Worker     }
137*c8dee2aaSAndroid Build Coastguard Worker 
preferVRAMUseOverFlushes()138*c8dee2aaSAndroid Build Coastguard Worker     bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; }
139*c8dee2aaSAndroid Build Coastguard Worker 
avoidStencilBuffers()140*c8dee2aaSAndroid Build Coastguard Worker     bool avoidStencilBuffers() const { return fAvoidStencilBuffers; }
141*c8dee2aaSAndroid Build Coastguard Worker 
avoidWritePixelsFastPath()142*c8dee2aaSAndroid Build Coastguard Worker     bool avoidWritePixelsFastPath() const { return fAvoidWritePixelsFastPath; }
143*c8dee2aaSAndroid Build Coastguard Worker 
144*c8dee2aaSAndroid Build Coastguard Worker     // glDrawElementsIndirect fails GrMeshTest on every Win10 Intel bot.
nativeDrawIndexedIndirectIsBroken()145*c8dee2aaSAndroid Build Coastguard Worker     bool nativeDrawIndexedIndirectIsBroken() const { return fNativeDrawIndexedIndirectIsBroken; }
146*c8dee2aaSAndroid Build Coastguard Worker 
147*c8dee2aaSAndroid Build Coastguard Worker     /**
148*c8dee2aaSAndroid Build Coastguard Worker      * Indicates the capabilities of the fixed function blend unit.
149*c8dee2aaSAndroid Build Coastguard Worker      */
150*c8dee2aaSAndroid Build Coastguard Worker     enum BlendEquationSupport {
151*c8dee2aaSAndroid Build Coastguard Worker         kBasic_BlendEquationSupport,             //<! Support to select the operator that
152*c8dee2aaSAndroid Build Coastguard Worker                                                  //   combines src and dst terms.
153*c8dee2aaSAndroid Build Coastguard Worker         kAdvanced_BlendEquationSupport,          //<! Additional fixed function support for specific
154*c8dee2aaSAndroid Build Coastguard Worker                                                  //   SVG/PDF blend modes. Requires blend barriers.
155*c8dee2aaSAndroid Build Coastguard Worker         kAdvancedCoherent_BlendEquationSupport,  //<! Advanced blend equation support that does not
156*c8dee2aaSAndroid Build Coastguard Worker                                                  //   require blend barriers, and permits overlap.
157*c8dee2aaSAndroid Build Coastguard Worker 
158*c8dee2aaSAndroid Build Coastguard Worker         kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport
159*c8dee2aaSAndroid Build Coastguard Worker     };
160*c8dee2aaSAndroid Build Coastguard Worker 
blendEquationSupport()161*c8dee2aaSAndroid Build Coastguard Worker     BlendEquationSupport blendEquationSupport() const { return fBlendEquationSupport; }
162*c8dee2aaSAndroid Build Coastguard Worker 
advancedBlendEquationSupport()163*c8dee2aaSAndroid Build Coastguard Worker     bool advancedBlendEquationSupport() const {
164*c8dee2aaSAndroid Build Coastguard Worker         return fBlendEquationSupport >= kAdvanced_BlendEquationSupport;
165*c8dee2aaSAndroid Build Coastguard Worker     }
166*c8dee2aaSAndroid Build Coastguard Worker 
advancedCoherentBlendEquationSupport()167*c8dee2aaSAndroid Build Coastguard Worker     bool advancedCoherentBlendEquationSupport() const {
168*c8dee2aaSAndroid Build Coastguard Worker         return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport;
169*c8dee2aaSAndroid Build Coastguard Worker     }
170*c8dee2aaSAndroid Build Coastguard Worker 
isAdvancedBlendEquationDisabled(skgpu::BlendEquation equation)171*c8dee2aaSAndroid Build Coastguard Worker     bool isAdvancedBlendEquationDisabled(skgpu::BlendEquation equation) const {
172*c8dee2aaSAndroid Build Coastguard Worker         SkASSERT(skgpu::BlendEquationIsAdvanced(equation));
173*c8dee2aaSAndroid Build Coastguard Worker         SkASSERT(this->advancedBlendEquationSupport());
174*c8dee2aaSAndroid Build Coastguard Worker         return SkToBool(fAdvBlendEqDisableFlags & (1 << static_cast<int>(equation)));
175*c8dee2aaSAndroid Build Coastguard Worker     }
176*c8dee2aaSAndroid Build Coastguard Worker 
177*c8dee2aaSAndroid Build Coastguard Worker     // On some GPUs it is a performance win to disable blending instead of doing src-over with a src
178*c8dee2aaSAndroid Build Coastguard Worker     // alpha equal to 1. To disable blending we collapse src-over to src and the backends will
179*c8dee2aaSAndroid Build Coastguard Worker     // handle the disabling of blending.
shouldCollapseSrcOverToSrcWhenAble()180*c8dee2aaSAndroid Build Coastguard Worker     bool shouldCollapseSrcOverToSrcWhenAble() const {
181*c8dee2aaSAndroid Build Coastguard Worker         return fShouldCollapseSrcOverToSrcWhenAble;
182*c8dee2aaSAndroid Build Coastguard Worker     }
183*c8dee2aaSAndroid Build Coastguard Worker 
184*c8dee2aaSAndroid Build Coastguard Worker     // When abandoning the GrDirectContext do we need to sync the GPU before we start abandoning
185*c8dee2aaSAndroid Build Coastguard Worker     // resources.
mustSyncGpuDuringAbandon()186*c8dee2aaSAndroid Build Coastguard Worker     bool mustSyncGpuDuringAbandon() const {
187*c8dee2aaSAndroid Build Coastguard Worker         return fMustSyncGpuDuringAbandon;
188*c8dee2aaSAndroid Build Coastguard Worker     }
189*c8dee2aaSAndroid Build Coastguard Worker 
190*c8dee2aaSAndroid Build Coastguard Worker     // Shortcut for shaderCaps()->fReducedShaderMode.
reducedShaderMode()191*c8dee2aaSAndroid Build Coastguard Worker     bool reducedShaderMode() const { return this->shaderCaps()->fReducedShaderMode; }
192*c8dee2aaSAndroid Build Coastguard Worker 
193*c8dee2aaSAndroid Build Coastguard Worker     /**
194*c8dee2aaSAndroid Build Coastguard Worker      * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
195*c8dee2aaSAndroid Build Coastguard Worker      * textures allows partial mappings or full mappings.
196*c8dee2aaSAndroid Build Coastguard Worker      */
197*c8dee2aaSAndroid Build Coastguard Worker     enum MapFlags {
198*c8dee2aaSAndroid Build Coastguard Worker         kNone_MapFlags      = 0x0,   //<! Cannot map the resource.
199*c8dee2aaSAndroid Build Coastguard Worker 
200*c8dee2aaSAndroid Build Coastguard Worker         kCanMap_MapFlag     = 0x1,   //<! The resource can be mapped. Must be set for any of
201*c8dee2aaSAndroid Build Coastguard Worker                                      //   the other flags to have meaning.
202*c8dee2aaSAndroid Build Coastguard Worker         kSubset_MapFlag     = 0x2,   //<! The resource can be partially mapped.
203*c8dee2aaSAndroid Build Coastguard Worker         kAsyncRead_MapFlag  = 0x4,   //<! Are maps for reading asynchronous WRT GrOpsRenderPass
204*c8dee2aaSAndroid Build Coastguard Worker                                      //   submitted to GrGpu.
205*c8dee2aaSAndroid Build Coastguard Worker     };
206*c8dee2aaSAndroid Build Coastguard Worker 
207*c8dee2aaSAndroid Build Coastguard Worker     // This returns the general mapping support for the GPU. However, even if this returns a flag
208*c8dee2aaSAndroid Build Coastguard Worker     // that says buffers can be mapped, it does NOT mean that every buffer will be mappable. Thus
209*c8dee2aaSAndroid Build Coastguard Worker     // calls of map should still check to see if a valid pointer was returned from the map call and
210*c8dee2aaSAndroid Build Coastguard Worker     // handle fallbacks appropriately. If this does return kNone_MapFlags then all calls to map() on
211*c8dee2aaSAndroid Build Coastguard Worker     // any buffer will fail.
mapBufferFlags()212*c8dee2aaSAndroid Build Coastguard Worker     uint32_t mapBufferFlags() const { return fMapBufferFlags; }
213*c8dee2aaSAndroid Build Coastguard Worker 
214*c8dee2aaSAndroid Build Coastguard Worker     // Scratch textures not being reused means that those scratch textures
215*c8dee2aaSAndroid Build Coastguard Worker     // that we upload to (i.e., don't have a render target) will not be
216*c8dee2aaSAndroid Build Coastguard Worker     // recycled in the texture cache. This is to prevent ghosting by drivers
217*c8dee2aaSAndroid Build Coastguard Worker     // (in particular for deferred architectures).
reuseScratchTextures()218*c8dee2aaSAndroid Build Coastguard Worker     bool reuseScratchTextures() const { return fReuseScratchTextures; }
reuseScratchBuffers()219*c8dee2aaSAndroid Build Coastguard Worker     bool reuseScratchBuffers() const { return fReuseScratchBuffers; }
220*c8dee2aaSAndroid Build Coastguard Worker 
221*c8dee2aaSAndroid Build Coastguard Worker     /// maximum number of attribute values per vertex
maxVertexAttributes()222*c8dee2aaSAndroid Build Coastguard Worker     int maxVertexAttributes() const { return fMaxVertexAttributes; }
223*c8dee2aaSAndroid Build Coastguard Worker 
maxRenderTargetSize()224*c8dee2aaSAndroid Build Coastguard Worker     int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
225*c8dee2aaSAndroid Build Coastguard Worker 
226*c8dee2aaSAndroid Build Coastguard Worker     /** This is the largest render target size that can be used without incurring extra perfomance
227*c8dee2aaSAndroid Build Coastguard Worker         cost. It is usually the max RT size, unless larger render targets are known to be slower. */
maxPreferredRenderTargetSize()228*c8dee2aaSAndroid Build Coastguard Worker     int maxPreferredRenderTargetSize() const { return fMaxPreferredRenderTargetSize; }
229*c8dee2aaSAndroid Build Coastguard Worker 
maxTextureSize()230*c8dee2aaSAndroid Build Coastguard Worker     int maxTextureSize() const { return fMaxTextureSize; }
231*c8dee2aaSAndroid Build Coastguard Worker 
maxWindowRectangles()232*c8dee2aaSAndroid Build Coastguard Worker     int maxWindowRectangles() const { return fMaxWindowRectangles; }
233*c8dee2aaSAndroid Build Coastguard Worker 
234*c8dee2aaSAndroid Build Coastguard Worker     // Returns whether window rectangles are supported for the given backend render target.
isWindowRectanglesSupportedForRT(const GrBackendRenderTarget & rt)235*c8dee2aaSAndroid Build Coastguard Worker     bool isWindowRectanglesSupportedForRT(const GrBackendRenderTarget& rt) const {
236*c8dee2aaSAndroid Build Coastguard Worker         return this->maxWindowRectangles() > 0 && this->onIsWindowRectanglesSupportedForRT(rt);
237*c8dee2aaSAndroid Build Coastguard Worker     }
238*c8dee2aaSAndroid Build Coastguard Worker 
maxPushConstantsSize()239*c8dee2aaSAndroid Build Coastguard Worker     uint32_t maxPushConstantsSize() const { return fMaxPushConstantsSize; }
240*c8dee2aaSAndroid Build Coastguard Worker 
241*c8dee2aaSAndroid Build Coastguard Worker     // Alignment requirement for row bytes in buffer<->texture transfers.
transferBufferRowBytesAlignment()242*c8dee2aaSAndroid Build Coastguard Worker     size_t transferBufferRowBytesAlignment() const { return fTransferBufferRowBytesAlignment; }
243*c8dee2aaSAndroid Build Coastguard Worker 
244*c8dee2aaSAndroid Build Coastguard Worker     // Alignment requirement for offsets and size in buffer->buffer transfers.
transferFromBufferToBufferAlignment()245*c8dee2aaSAndroid Build Coastguard Worker     size_t transferFromBufferToBufferAlignment() const {
246*c8dee2aaSAndroid Build Coastguard Worker         return fTransferFromBufferToBufferAlignment;
247*c8dee2aaSAndroid Build Coastguard Worker     }
248*c8dee2aaSAndroid Build Coastguard Worker 
249*c8dee2aaSAndroid Build Coastguard Worker     // Alignment requirement for offset and size passed to in GrGpuBuffer::updateData when the
250*c8dee2aaSAndroid Build Coastguard Worker     // preserve param is true.
bufferUpdateDataPreserveAlignment()251*c8dee2aaSAndroid Build Coastguard Worker     size_t bufferUpdateDataPreserveAlignment() const {
252*c8dee2aaSAndroid Build Coastguard Worker         return fBufferUpdateDataPreserveAlignment;
253*c8dee2aaSAndroid Build Coastguard Worker     }
254*c8dee2aaSAndroid Build Coastguard Worker 
255*c8dee2aaSAndroid Build Coastguard Worker     virtual bool isFormatSRGB(const GrBackendFormat&) const = 0;
256*c8dee2aaSAndroid Build Coastguard Worker 
257*c8dee2aaSAndroid Build Coastguard Worker     bool isFormatCompressed(const GrBackendFormat& format) const;
258*c8dee2aaSAndroid Build Coastguard Worker 
259*c8dee2aaSAndroid Build Coastguard Worker     // Can a texture be made with the GrBackendFormat and texture type, and then be bound and
260*c8dee2aaSAndroid Build Coastguard Worker     // sampled in a shader.
261*c8dee2aaSAndroid Build Coastguard Worker     virtual bool isFormatTexturable(const GrBackendFormat&, GrTextureType) const = 0;
262*c8dee2aaSAndroid Build Coastguard Worker 
263*c8dee2aaSAndroid Build Coastguard Worker     // Returns whether a texture of the given format can be copied to a texture of the same format.
264*c8dee2aaSAndroid Build Coastguard Worker     virtual bool isFormatCopyable(const GrBackendFormat&) const = 0;
265*c8dee2aaSAndroid Build Coastguard Worker 
266*c8dee2aaSAndroid Build Coastguard Worker     // Returns the maximum supported sample count for a format. 0 means the format is not renderable
267*c8dee2aaSAndroid Build Coastguard Worker     // 1 means the format is renderable but doesn't support MSAA.
268*c8dee2aaSAndroid Build Coastguard Worker     virtual int maxRenderTargetSampleCount(const GrBackendFormat&) const = 0;
269*c8dee2aaSAndroid Build Coastguard Worker 
270*c8dee2aaSAndroid Build Coastguard Worker     // Returns the number of samples to use when performing draws to the given config with internal
271*c8dee2aaSAndroid Build Coastguard Worker     // MSAA. If 0, Ganesh should not attempt to use internal multisampling.
internalMultisampleCount(const GrBackendFormat & format)272*c8dee2aaSAndroid Build Coastguard Worker     int internalMultisampleCount(const GrBackendFormat& format) const {
273*c8dee2aaSAndroid Build Coastguard Worker         return std::min(fInternalMultisampleCount, this->maxRenderTargetSampleCount(format));
274*c8dee2aaSAndroid Build Coastguard Worker     }
275*c8dee2aaSAndroid Build Coastguard Worker 
276*c8dee2aaSAndroid Build Coastguard Worker     virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat& format,
277*c8dee2aaSAndroid Build Coastguard Worker                                                int sampleCount = 1) const = 0;
278*c8dee2aaSAndroid Build Coastguard Worker 
279*c8dee2aaSAndroid Build Coastguard Worker     virtual bool isFormatRenderable(const GrBackendFormat& format, int sampleCount) const = 0;
280*c8dee2aaSAndroid Build Coastguard Worker 
281*c8dee2aaSAndroid Build Coastguard Worker     // Find a sample count greater than or equal to the requested count which is supported for a
282*c8dee2aaSAndroid Build Coastguard Worker     // render target of the given format or 0 if no such sample count is supported. If the requested
283*c8dee2aaSAndroid Build Coastguard Worker     // sample count is 1 then 1 will be returned if non-MSAA rendering is supported, otherwise 0.
284*c8dee2aaSAndroid Build Coastguard Worker     // For historical reasons requestedCount==0 is handled identically to requestedCount==1.
285*c8dee2aaSAndroid Build Coastguard Worker     virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat&) const = 0;
286*c8dee2aaSAndroid Build Coastguard Worker 
287*c8dee2aaSAndroid Build Coastguard Worker     /**
288*c8dee2aaSAndroid Build Coastguard Worker      * Backends may have restrictions on what types of surfaces support GrGpu::writePixels().
289*c8dee2aaSAndroid Build Coastguard Worker      * If this returns false then the caller should implement a fallback where a temporary texture
290*c8dee2aaSAndroid Build Coastguard Worker      * is created, pixels are written to it, and then that is copied or drawn into the the surface.
291*c8dee2aaSAndroid Build Coastguard Worker      */
292*c8dee2aaSAndroid Build Coastguard Worker     bool surfaceSupportsWritePixels(const GrSurface*) const;
293*c8dee2aaSAndroid Build Coastguard Worker 
294*c8dee2aaSAndroid Build Coastguard Worker     /**
295*c8dee2aaSAndroid Build Coastguard Worker      * Indicates whether surface supports GrGpu::readPixels, must be copied, or cannot be read.
296*c8dee2aaSAndroid Build Coastguard Worker      */
297*c8dee2aaSAndroid Build Coastguard Worker     enum class SurfaceReadPixelsSupport {
298*c8dee2aaSAndroid Build Coastguard Worker         /** GrGpu::readPixels is supported by the surface. */
299*c8dee2aaSAndroid Build Coastguard Worker         kSupported,
300*c8dee2aaSAndroid Build Coastguard Worker         /**
301*c8dee2aaSAndroid Build Coastguard Worker          * GrGpu::readPixels is not supported by this surface but this surface can be drawn
302*c8dee2aaSAndroid Build Coastguard Worker          * or copied to a Ganesh-created GrTextureType::kTexture2D and then that surface will be
303*c8dee2aaSAndroid Build Coastguard Worker          * readable.
304*c8dee2aaSAndroid Build Coastguard Worker          */
305*c8dee2aaSAndroid Build Coastguard Worker         kCopyToTexture2D,
306*c8dee2aaSAndroid Build Coastguard Worker         /**
307*c8dee2aaSAndroid Build Coastguard Worker          * Not supported
308*c8dee2aaSAndroid Build Coastguard Worker          */
309*c8dee2aaSAndroid Build Coastguard Worker         kUnsupported,
310*c8dee2aaSAndroid Build Coastguard Worker     };
311*c8dee2aaSAndroid Build Coastguard Worker     /**
312*c8dee2aaSAndroid Build Coastguard Worker      * Backends may have restrictions on what types of surfaces support GrGpu::readPixels(). We may
313*c8dee2aaSAndroid Build Coastguard Worker      * either be able to read directly from the surface, read from a copy of the surface, or not
314*c8dee2aaSAndroid Build Coastguard Worker      * read at all.
315*c8dee2aaSAndroid Build Coastguard Worker      */
316*c8dee2aaSAndroid Build Coastguard Worker     virtual SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const = 0;
317*c8dee2aaSAndroid Build Coastguard Worker 
318*c8dee2aaSAndroid Build Coastguard Worker     struct SupportedWrite {
319*c8dee2aaSAndroid Build Coastguard Worker         GrColorType fColorType;
320*c8dee2aaSAndroid Build Coastguard Worker         // If the write is occurring using GrGpu::transferPixelsTo then this provides the
321*c8dee2aaSAndroid Build Coastguard Worker         // minimum alignment of the offset into the transfer buffer.
322*c8dee2aaSAndroid Build Coastguard Worker         size_t fOffsetAlignmentForTransferBuffer;
323*c8dee2aaSAndroid Build Coastguard Worker     };
324*c8dee2aaSAndroid Build Coastguard Worker 
325*c8dee2aaSAndroid Build Coastguard Worker     /**
326*c8dee2aaSAndroid Build Coastguard Worker      * Given a dst pixel config and a src color type what color type must the caller coax the
327*c8dee2aaSAndroid Build Coastguard Worker      * the data into in order to use GrGpu::writePixels().
328*c8dee2aaSAndroid Build Coastguard Worker      */
329*c8dee2aaSAndroid Build Coastguard Worker     virtual SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType,
330*c8dee2aaSAndroid Build Coastguard Worker                                                          const GrBackendFormat& surfaceFormat,
331*c8dee2aaSAndroid Build Coastguard Worker                                                          GrColorType srcColorType) const = 0;
332*c8dee2aaSAndroid Build Coastguard Worker 
333*c8dee2aaSAndroid Build Coastguard Worker     struct SupportedRead {
334*c8dee2aaSAndroid Build Coastguard Worker         GrColorType fColorType;
335*c8dee2aaSAndroid Build Coastguard Worker         // If the read is occurring using GrGpu::transferPixelsFrom then this provides the
336*c8dee2aaSAndroid Build Coastguard Worker         // minimum alignment of the offset into the transfer buffer.
337*c8dee2aaSAndroid Build Coastguard Worker         size_t fOffsetAlignmentForTransferBuffer;
338*c8dee2aaSAndroid Build Coastguard Worker     };
339*c8dee2aaSAndroid Build Coastguard Worker 
340*c8dee2aaSAndroid Build Coastguard Worker     /**
341*c8dee2aaSAndroid Build Coastguard Worker      * Given a src surface's color type and its backend format as well as a color type the caller
342*c8dee2aaSAndroid Build Coastguard Worker      * would like read into, this provides a legal color type that the caller may pass to
343*c8dee2aaSAndroid Build Coastguard Worker      * GrGpu::readPixels(). The returned color type may differ from the passed dstColorType, in
344*c8dee2aaSAndroid Build Coastguard Worker      * which case the caller must convert the read pixel data (see GrConvertPixels). When converting
345*c8dee2aaSAndroid Build Coastguard Worker      * to dstColorType the swizzle in the returned struct should be applied. The caller must check
346*c8dee2aaSAndroid Build Coastguard Worker      * the returned color type for kUnknown.
347*c8dee2aaSAndroid Build Coastguard Worker      */
348*c8dee2aaSAndroid Build Coastguard Worker     SupportedRead supportedReadPixelsColorType(GrColorType srcColorType,
349*c8dee2aaSAndroid Build Coastguard Worker                                                const GrBackendFormat& srcFormat,
350*c8dee2aaSAndroid Build Coastguard Worker                                                GrColorType dstColorType) const;
351*c8dee2aaSAndroid Build Coastguard Worker 
352*c8dee2aaSAndroid Build Coastguard Worker     /**
353*c8dee2aaSAndroid Build Coastguard Worker      * Does GrGpu::writePixels() support a src buffer where the row bytes is not equal to bpp * w?
354*c8dee2aaSAndroid Build Coastguard Worker      */
writePixelsRowBytesSupport()355*c8dee2aaSAndroid Build Coastguard Worker     bool writePixelsRowBytesSupport() const { return fWritePixelsRowBytesSupport; }
356*c8dee2aaSAndroid Build Coastguard Worker 
357*c8dee2aaSAndroid Build Coastguard Worker     /**
358*c8dee2aaSAndroid Build Coastguard Worker      * Does GrGpu::transferPixelsTo() support a src buffer where the row bytes is not equal to
359*c8dee2aaSAndroid Build Coastguard Worker      * bpp * w?
360*c8dee2aaSAndroid Build Coastguard Worker      */
transferPixelsToRowBytesSupport()361*c8dee2aaSAndroid Build Coastguard Worker     bool transferPixelsToRowBytesSupport() const { return fTransferPixelsToRowBytesSupport; }
362*c8dee2aaSAndroid Build Coastguard Worker 
363*c8dee2aaSAndroid Build Coastguard Worker     /**
364*c8dee2aaSAndroid Build Coastguard Worker      * Does GrGpu::readPixels() support a dst buffer where the row bytes is not equal to bpp * w?
365*c8dee2aaSAndroid Build Coastguard Worker      */
readPixelsRowBytesSupport()366*c8dee2aaSAndroid Build Coastguard Worker     bool readPixelsRowBytesSupport() const { return fReadPixelsRowBytesSupport; }
367*c8dee2aaSAndroid Build Coastguard Worker 
transferFromSurfaceToBufferSupport()368*c8dee2aaSAndroid Build Coastguard Worker     bool transferFromSurfaceToBufferSupport() const { return fTransferFromSurfaceToBufferSupport; }
transferFromBufferToTextureSupport()369*c8dee2aaSAndroid Build Coastguard Worker     bool transferFromBufferToTextureSupport() const { return fTransferFromBufferToTextureSupport; }
transferFromBufferToBufferSupport()370*c8dee2aaSAndroid Build Coastguard Worker     bool transferFromBufferToBufferSupport()  const { return fTransferFromBufferToBufferSupport;  }
371*c8dee2aaSAndroid Build Coastguard Worker 
suppressPrints()372*c8dee2aaSAndroid Build Coastguard Worker     bool suppressPrints() const { return fSuppressPrints; }
373*c8dee2aaSAndroid Build Coastguard Worker 
bufferMapThreshold()374*c8dee2aaSAndroid Build Coastguard Worker     size_t bufferMapThreshold() const {
375*c8dee2aaSAndroid Build Coastguard Worker         SkASSERT(fBufferMapThreshold >= 0);
376*c8dee2aaSAndroid Build Coastguard Worker         return static_cast<size_t>(fBufferMapThreshold);
377*c8dee2aaSAndroid Build Coastguard Worker     }
378*c8dee2aaSAndroid Build Coastguard Worker 
379*c8dee2aaSAndroid Build Coastguard Worker     /** True in environments that will issue errors if memory uploaded to buffers
380*c8dee2aaSAndroid Build Coastguard Worker         is not initialized (even if not read by draw calls). */
mustClearUploadedBufferData()381*c8dee2aaSAndroid Build Coastguard Worker     bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; }
382*c8dee2aaSAndroid Build Coastguard Worker 
383*c8dee2aaSAndroid Build Coastguard Worker     /** For some environments, there is a performance or safety concern to not
384*c8dee2aaSAndroid Build Coastguard Worker         initializing textures. For example, with WebGL and Firefox, there is a large
385*c8dee2aaSAndroid Build Coastguard Worker         performance hit to not doing it.
386*c8dee2aaSAndroid Build Coastguard Worker      */
shouldInitializeTextures()387*c8dee2aaSAndroid Build Coastguard Worker     bool shouldInitializeTextures() const { return fShouldInitializeTextures; }
388*c8dee2aaSAndroid Build Coastguard Worker 
389*c8dee2aaSAndroid Build Coastguard Worker     /**
390*c8dee2aaSAndroid Build Coastguard Worker      * When a new GrGpuBuffer is created is it known to contain all zero bytes?
391*c8dee2aaSAndroid Build Coastguard Worker      */
buffersAreInitiallyZero()392*c8dee2aaSAndroid Build Coastguard Worker     bool buffersAreInitiallyZero() const { return fBuffersAreInitiallyZero; }
393*c8dee2aaSAndroid Build Coastguard Worker 
394*c8dee2aaSAndroid Build Coastguard Worker     /** Returns true if the given backend supports importing AHardwareBuffers via the
395*c8dee2aaSAndroid Build Coastguard Worker      * GrAHardwarebufferImageGenerator. This will only ever be supported on Android devices with API
396*c8dee2aaSAndroid Build Coastguard Worker      * level >= 26.
397*c8dee2aaSAndroid Build Coastguard Worker      * */
supportsAHardwareBufferImages()398*c8dee2aaSAndroid Build Coastguard Worker     bool supportsAHardwareBufferImages() const { return fSupportsAHardwareBufferImages; }
399*c8dee2aaSAndroid Build Coastguard Worker 
wireframeMode()400*c8dee2aaSAndroid Build Coastguard Worker     bool wireframeMode() const { return fWireframeMode; }
401*c8dee2aaSAndroid Build Coastguard Worker 
402*c8dee2aaSAndroid Build Coastguard Worker     /** Supports using GrSemaphores. */
semaphoreSupport()403*c8dee2aaSAndroid Build Coastguard Worker     bool semaphoreSupport() const { return fSemaphoreSupport; }
404*c8dee2aaSAndroid Build Coastguard Worker 
405*c8dee2aaSAndroid Build Coastguard Worker     /** Supports using GrBackendSemaphore as "signal" semaphores or for waiting. See also
406*c8dee2aaSAndroid Build Coastguard Worker      *  GrFlushInfo and GrDirectContext. */
backendSemaphoreSupport()407*c8dee2aaSAndroid Build Coastguard Worker     bool backendSemaphoreSupport() const { return fBackendSemaphoreSupport; }
408*c8dee2aaSAndroid Build Coastguard Worker 
409*c8dee2aaSAndroid Build Coastguard Worker     /** Supports async callback for finishedProcs */
finishedProcAsyncCallbackSupport()410*c8dee2aaSAndroid Build Coastguard Worker     bool finishedProcAsyncCallbackSupport() const { return fFinishedProcAsyncCallbackSupport; }
411*c8dee2aaSAndroid Build Coastguard Worker 
crossContextTextureSupport()412*c8dee2aaSAndroid Build Coastguard Worker     bool crossContextTextureSupport() const { return fCrossContextTextureSupport; }
413*c8dee2aaSAndroid Build Coastguard Worker     /**
414*c8dee2aaSAndroid Build Coastguard Worker      * Returns whether or not we will be able to do a copy given the passed in params
415*c8dee2aaSAndroid Build Coastguard Worker      */
416*c8dee2aaSAndroid Build Coastguard Worker     bool canCopySurface(const GrSurfaceProxy* dst, const SkIRect& dstRect,
417*c8dee2aaSAndroid Build Coastguard Worker                         const GrSurfaceProxy* src, const SkIRect& srcRect) const;
418*c8dee2aaSAndroid Build Coastguard Worker 
dynamicStateArrayGeometryProcessorTextureSupport()419*c8dee2aaSAndroid Build Coastguard Worker     bool dynamicStateArrayGeometryProcessorTextureSupport() const {
420*c8dee2aaSAndroid Build Coastguard Worker         return fDynamicStateArrayGeometryProcessorTextureSupport;
421*c8dee2aaSAndroid Build Coastguard Worker     }
422*c8dee2aaSAndroid Build Coastguard Worker 
supportsProtectedContent()423*c8dee2aaSAndroid Build Coastguard Worker     bool supportsProtectedContent() const { return fSupportsProtectedContent; }
424*c8dee2aaSAndroid Build Coastguard Worker 
425*c8dee2aaSAndroid Build Coastguard Worker     // Not all backends support clearing with a scissor test (e.g. Metal), this will always
426*c8dee2aaSAndroid Build Coastguard Worker     // return true if performColorClearsAsDraws() returns true.
performPartialClearsAsDraws()427*c8dee2aaSAndroid Build Coastguard Worker     bool performPartialClearsAsDraws() const {
428*c8dee2aaSAndroid Build Coastguard Worker         return fPerformColorClearsAsDraws || fPerformPartialClearsAsDraws;
429*c8dee2aaSAndroid Build Coastguard Worker     }
430*c8dee2aaSAndroid Build Coastguard Worker 
431*c8dee2aaSAndroid Build Coastguard Worker     // Many drivers have issues with color clears.
performColorClearsAsDraws()432*c8dee2aaSAndroid Build Coastguard Worker     bool performColorClearsAsDraws() const { return fPerformColorClearsAsDraws; }
433*c8dee2aaSAndroid Build Coastguard Worker 
avoidLargeIndexBufferDraws()434*c8dee2aaSAndroid Build Coastguard Worker     bool avoidLargeIndexBufferDraws() const { return fAvoidLargeIndexBufferDraws; }
435*c8dee2aaSAndroid Build Coastguard Worker 
436*c8dee2aaSAndroid Build Coastguard Worker     /// Adreno 4xx devices experience an issue when there are a large number of stencil clip bit
437*c8dee2aaSAndroid Build Coastguard Worker     /// clears. The minimal repro steps are not precisely known but drawing a rect with a stencil
438*c8dee2aaSAndroid Build Coastguard Worker     /// op instead of using glClear seems to resolve the issue.
performStencilClearsAsDraws()439*c8dee2aaSAndroid Build Coastguard Worker     bool performStencilClearsAsDraws() const { return fPerformStencilClearsAsDraws; }
440*c8dee2aaSAndroid Build Coastguard Worker 
441*c8dee2aaSAndroid Build Coastguard Worker     // Should we disable TessellationPathRenderer due to a faulty driver?
disableTessellationPathRenderer()442*c8dee2aaSAndroid Build Coastguard Worker     bool disableTessellationPathRenderer() const { return fDisableTessellationPathRenderer; }
443*c8dee2aaSAndroid Build Coastguard Worker 
444*c8dee2aaSAndroid Build Coastguard Worker     // Returns how to sample the dst values for the passed in GrRenderTargetProxy.
445*c8dee2aaSAndroid Build Coastguard Worker     GrDstSampleFlags getDstSampleFlagsForProxy(const GrRenderTargetProxy*, bool drawUsesMSAA) const;
446*c8dee2aaSAndroid Build Coastguard Worker 
447*c8dee2aaSAndroid Build Coastguard Worker     /**
448*c8dee2aaSAndroid Build Coastguard Worker      * This is used to try to ensure a successful copy a dst in order to perform shader-based
449*c8dee2aaSAndroid Build Coastguard Worker      * blending.
450*c8dee2aaSAndroid Build Coastguard Worker      *
451*c8dee2aaSAndroid Build Coastguard Worker      * fRectsMustMatch will be set to true if the copy operation must ensure that the src and dest
452*c8dee2aaSAndroid Build Coastguard Worker      * rects are identical.
453*c8dee2aaSAndroid Build Coastguard Worker      *
454*c8dee2aaSAndroid Build Coastguard Worker      * fMustCopyWholeSrc will be set to true if copy rect must equal src's bounds.
455*c8dee2aaSAndroid Build Coastguard Worker      *
456*c8dee2aaSAndroid Build Coastguard Worker      * Caller will detect cases when copy cannot succeed and try copy-as-draw as a fallback.
457*c8dee2aaSAndroid Build Coastguard Worker      */
458*c8dee2aaSAndroid Build Coastguard Worker     struct DstCopyRestrictions {
459*c8dee2aaSAndroid Build Coastguard Worker         GrSurfaceProxy::RectsMustMatch fRectsMustMatch = GrSurfaceProxy::RectsMustMatch::kNo;
460*c8dee2aaSAndroid Build Coastguard Worker         bool fMustCopyWholeSrc = false;
461*c8dee2aaSAndroid Build Coastguard Worker     };
getDstCopyRestrictions(const GrRenderTargetProxy * src,GrColorType ct)462*c8dee2aaSAndroid Build Coastguard Worker     virtual DstCopyRestrictions getDstCopyRestrictions(const GrRenderTargetProxy* src,
463*c8dee2aaSAndroid Build Coastguard Worker                                                        GrColorType ct) const {
464*c8dee2aaSAndroid Build Coastguard Worker         return {};
465*c8dee2aaSAndroid Build Coastguard Worker     }
466*c8dee2aaSAndroid Build Coastguard Worker 
467*c8dee2aaSAndroid Build Coastguard Worker     bool validateSurfaceParams(const SkISize&,
468*c8dee2aaSAndroid Build Coastguard Worker                                const GrBackendFormat&,
469*c8dee2aaSAndroid Build Coastguard Worker                                GrRenderable renderable,
470*c8dee2aaSAndroid Build Coastguard Worker                                int renderTargetSampleCnt,
471*c8dee2aaSAndroid Build Coastguard Worker                                skgpu::Mipmapped,
472*c8dee2aaSAndroid Build Coastguard Worker                                GrTextureType) const;
473*c8dee2aaSAndroid Build Coastguard Worker 
474*c8dee2aaSAndroid Build Coastguard Worker     bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat& format) const;
475*c8dee2aaSAndroid Build Coastguard Worker 
476*c8dee2aaSAndroid Build Coastguard Worker     /** These are used when creating a new texture internally. */
477*c8dee2aaSAndroid Build Coastguard Worker     GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const;
478*c8dee2aaSAndroid Build Coastguard Worker 
479*c8dee2aaSAndroid Build Coastguard Worker     virtual GrBackendFormat getBackendFormatFromCompressionType(SkTextureCompressionType) const = 0;
480*c8dee2aaSAndroid Build Coastguard Worker 
481*c8dee2aaSAndroid Build Coastguard Worker     /**
482*c8dee2aaSAndroid Build Coastguard Worker      * The CLAMP_TO_BORDER wrap mode for texture coordinates was added to desktop GL in 1.3, and
483*c8dee2aaSAndroid Build Coastguard Worker      * GLES 3.2, but is also available in extensions. Vulkan and Metal always have support.
484*c8dee2aaSAndroid Build Coastguard Worker      */
clampToBorderSupport()485*c8dee2aaSAndroid Build Coastguard Worker     bool clampToBorderSupport() const { return fClampToBorderSupport; }
486*c8dee2aaSAndroid Build Coastguard Worker 
487*c8dee2aaSAndroid Build Coastguard Worker     /**
488*c8dee2aaSAndroid Build Coastguard Worker      * Returns the skgpu::Swizzle to use when sampling or reading back from a texture with the
489*c8dee2aaSAndroid Build Coastguard Worker      * passed in GrBackendFormat and GrColorType.
490*c8dee2aaSAndroid Build Coastguard Worker      */
491*c8dee2aaSAndroid Build Coastguard Worker     skgpu::Swizzle getReadSwizzle(const GrBackendFormat& format, GrColorType colorType) const;
492*c8dee2aaSAndroid Build Coastguard Worker 
493*c8dee2aaSAndroid Build Coastguard Worker     /**
494*c8dee2aaSAndroid Build Coastguard Worker      * Returns the skgpu::Swizzle to use when writing colors to a surface with the passed in
495*c8dee2aaSAndroid Build Coastguard Worker      * GrBackendFormat and GrColorType.
496*c8dee2aaSAndroid Build Coastguard Worker      */
497*c8dee2aaSAndroid Build Coastguard Worker     virtual skgpu::Swizzle getWriteSwizzle(const GrBackendFormat&, GrColorType) const = 0;
498*c8dee2aaSAndroid Build Coastguard Worker 
499*c8dee2aaSAndroid Build Coastguard Worker     virtual uint64_t computeFormatKey(const GrBackendFormat&) const = 0;
500*c8dee2aaSAndroid Build Coastguard Worker 
supportedGpuStats()501*c8dee2aaSAndroid Build Coastguard Worker     skgpu::GpuStatsFlags supportedGpuStats() const { return fSupportedGpuStats; }
502*c8dee2aaSAndroid Build Coastguard Worker 
workarounds()503*c8dee2aaSAndroid Build Coastguard Worker     const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; }
504*c8dee2aaSAndroid Build Coastguard Worker 
505*c8dee2aaSAndroid Build Coastguard Worker     /**
506*c8dee2aaSAndroid Build Coastguard Worker      * Adds fields to the key to represent the sampler that will be created for the passed
507*c8dee2aaSAndroid Build Coastguard Worker      * in parameters. Currently this extra keying is only needed when building a vulkan pipeline
508*c8dee2aaSAndroid Build Coastguard Worker      * with immutable samplers.
509*c8dee2aaSAndroid Build Coastguard Worker      */
addExtraSamplerKey(skgpu::KeyBuilder *,GrSamplerState,const GrBackendFormat &)510*c8dee2aaSAndroid Build Coastguard Worker     virtual void addExtraSamplerKey(skgpu::KeyBuilder*,
511*c8dee2aaSAndroid Build Coastguard Worker                                     GrSamplerState,
512*c8dee2aaSAndroid Build Coastguard Worker                                     const GrBackendFormat&) const {}
513*c8dee2aaSAndroid Build Coastguard Worker 
514*c8dee2aaSAndroid Build Coastguard Worker     enum class ProgramDescOverrideFlags {
515*c8dee2aaSAndroid Build Coastguard Worker         kNone = 0,
516*c8dee2aaSAndroid Build Coastguard Worker         // If using discardable msaa surfaces in vulkan, when we break up a render pass for an
517*c8dee2aaSAndroid Build Coastguard Worker         // inline upload, we must do a load msaa subpass for the second render pass. However, if the
518*c8dee2aaSAndroid Build Coastguard Worker         // original render pass did not have this load subpass (e.g. clear or discard load op), then
519*c8dee2aaSAndroid Build Coastguard Worker         // all the GrProgramInfos for draws that end up in the second render pass will have been
520*c8dee2aaSAndroid Build Coastguard Worker         // recorded thinking they will be in a render pass with only 1 subpass. Thus we add an
521*c8dee2aaSAndroid Build Coastguard Worker         // override flag to the makeDesc call to force the actually VkPipeline that gets created to
522*c8dee2aaSAndroid Build Coastguard Worker         // be created using a render pass with 2 subpasses. We do miss on the pre-compile with this
523*c8dee2aaSAndroid Build Coastguard Worker         // approach, but inline uploads are very rare and already slow.
524*c8dee2aaSAndroid Build Coastguard Worker         kVulkanHasResolveLoadSubpass = 0x1,
525*c8dee2aaSAndroid Build Coastguard Worker     };
526*c8dee2aaSAndroid Build Coastguard Worker     SK_DECL_BITFIELD_CLASS_OPS_FRIENDS(ProgramDescOverrideFlags);
527*c8dee2aaSAndroid Build Coastguard Worker 
528*c8dee2aaSAndroid Build Coastguard Worker 
529*c8dee2aaSAndroid Build Coastguard Worker     virtual GrProgramDesc makeDesc(
530*c8dee2aaSAndroid Build Coastguard Worker             GrRenderTarget*, const GrProgramInfo&,
531*c8dee2aaSAndroid Build Coastguard Worker             ProgramDescOverrideFlags overrideFlags = ProgramDescOverrideFlags::kNone) const = 0;
532*c8dee2aaSAndroid Build Coastguard Worker 
533*c8dee2aaSAndroid Build Coastguard Worker     // This method specifies, for each backend, the extra properties of a RT when Ganesh creates one
534*c8dee2aaSAndroid Build Coastguard Worker     // internally. For example, for Vulkan, Ganesh always creates RTs that can be used as input
535*c8dee2aaSAndroid Build Coastguard Worker     // attachments.
getExtraSurfaceFlagsForDeferredRT()536*c8dee2aaSAndroid Build Coastguard Worker     virtual GrInternalSurfaceFlags getExtraSurfaceFlagsForDeferredRT() const {
537*c8dee2aaSAndroid Build Coastguard Worker         return GrInternalSurfaceFlags::kNone;
538*c8dee2aaSAndroid Build Coastguard Worker     }
539*c8dee2aaSAndroid Build Coastguard Worker 
540*c8dee2aaSAndroid Build Coastguard Worker     bool supportsDynamicMSAA(const GrRenderTargetProxy*) const;
541*c8dee2aaSAndroid Build Coastguard Worker 
dmsaaResolveCanBeUsedAsTextureInSameRenderPass()542*c8dee2aaSAndroid Build Coastguard Worker     virtual bool dmsaaResolveCanBeUsedAsTextureInSameRenderPass() const { return true; }
543*c8dee2aaSAndroid Build Coastguard Worker 
544*c8dee2aaSAndroid Build Coastguard Worker     // skbug.com/11935. Task reordering is disabled for some GPUs on GL due to driver bugs.
avoidReorderingRenderTasks()545*c8dee2aaSAndroid Build Coastguard Worker     bool avoidReorderingRenderTasks() const {
546*c8dee2aaSAndroid Build Coastguard Worker         return fAvoidReorderingRenderTasks;
547*c8dee2aaSAndroid Build Coastguard Worker     }
548*c8dee2aaSAndroid Build Coastguard Worker 
avoidDithering()549*c8dee2aaSAndroid Build Coastguard Worker     bool avoidDithering() const {
550*c8dee2aaSAndroid Build Coastguard Worker         return fAvoidDithering;
551*c8dee2aaSAndroid Build Coastguard Worker     }
552*c8dee2aaSAndroid Build Coastguard Worker 
disablePerspectiveSDFText()553*c8dee2aaSAndroid Build Coastguard Worker     bool disablePerspectiveSDFText() const {
554*c8dee2aaSAndroid Build Coastguard Worker         return fDisablePerspectiveSDFText;
555*c8dee2aaSAndroid Build Coastguard Worker     }
556*c8dee2aaSAndroid Build Coastguard Worker 
557*c8dee2aaSAndroid Build Coastguard Worker     // anglebug.com/7796
avoidLineDraws()558*c8dee2aaSAndroid Build Coastguard Worker     bool avoidLineDraws() const { return fAvoidLineDraws; }
559*c8dee2aaSAndroid Build Coastguard Worker 
560*c8dee2aaSAndroid Build Coastguard Worker     /**
561*c8dee2aaSAndroid Build Coastguard Worker      * Checks whether the passed color type is renderable. If so, the same color type is passed
562*c8dee2aaSAndroid Build Coastguard Worker      * back along with the default format used for the color type. If not, provides an alternative
563*c8dee2aaSAndroid Build Coastguard Worker      * (perhaps lower bit depth and/or unorm instead of float) color type that is supported
564*c8dee2aaSAndroid Build Coastguard Worker      * along with it's default format or kUnknown if there no renderable fallback format.
565*c8dee2aaSAndroid Build Coastguard Worker      */
566*c8dee2aaSAndroid Build Coastguard Worker     std::tuple<GrColorType, GrBackendFormat> getFallbackColorTypeAndFormat(GrColorType,
567*c8dee2aaSAndroid Build Coastguard Worker                                                                            int sampleCount) const;
568*c8dee2aaSAndroid Build Coastguard Worker 
569*c8dee2aaSAndroid Build Coastguard Worker #if defined(GPU_TEST_UTILS)
570*c8dee2aaSAndroid Build Coastguard Worker     virtual std::vector<GrTest::TestFormatColorTypeCombination> getTestingCombinations() const = 0;
571*c8dee2aaSAndroid Build Coastguard Worker #endif
572*c8dee2aaSAndroid Build Coastguard Worker 
573*c8dee2aaSAndroid Build Coastguard Worker protected:
574*c8dee2aaSAndroid Build Coastguard Worker     // Subclasses must call this at the end of their init method in order to do final processing on
575*c8dee2aaSAndroid Build Coastguard Worker     // the caps (including overrides requested by the client).
576*c8dee2aaSAndroid Build Coastguard Worker     // NOTE: this method will only reduce the caps, never expand them.
577*c8dee2aaSAndroid Build Coastguard Worker     void finishInitialization(const GrContextOptions& options);
578*c8dee2aaSAndroid Build Coastguard Worker 
579*c8dee2aaSAndroid Build Coastguard Worker #if defined(GPU_TEST_UTILS)
setDeviceName(const char * n)580*c8dee2aaSAndroid Build Coastguard Worker     void setDeviceName(const char* n) {
581*c8dee2aaSAndroid Build Coastguard Worker         fDeviceName = n;
582*c8dee2aaSAndroid Build Coastguard Worker     }
583*c8dee2aaSAndroid Build Coastguard Worker #endif
584*c8dee2aaSAndroid Build Coastguard Worker 
onSupportsDynamicMSAA(const GrRenderTargetProxy *)585*c8dee2aaSAndroid Build Coastguard Worker     virtual bool onSupportsDynamicMSAA(const GrRenderTargetProxy*) const { return false; }
586*c8dee2aaSAndroid Build Coastguard Worker 
587*c8dee2aaSAndroid Build Coastguard Worker     std::unique_ptr<GrShaderCaps> fShaderCaps;
588*c8dee2aaSAndroid Build Coastguard Worker 
589*c8dee2aaSAndroid Build Coastguard Worker     bool fNPOTTextureTileSupport                     : 1;
590*c8dee2aaSAndroid Build Coastguard Worker     bool fMipmapSupport                              : 1;
591*c8dee2aaSAndroid Build Coastguard Worker     bool fAnisoSupport                               : 1;
592*c8dee2aaSAndroid Build Coastguard Worker     bool fReuseScratchTextures                       : 1;
593*c8dee2aaSAndroid Build Coastguard Worker     bool fReuseScratchBuffers                        : 1;
594*c8dee2aaSAndroid Build Coastguard Worker     bool fGpuTracingSupport                          : 1;
595*c8dee2aaSAndroid Build Coastguard Worker     bool fOversizedStencilSupport                    : 1;
596*c8dee2aaSAndroid Build Coastguard Worker     bool fTextureBarrierSupport                      : 1;
597*c8dee2aaSAndroid Build Coastguard Worker     bool fSampleLocationsSupport                     : 1;
598*c8dee2aaSAndroid Build Coastguard Worker     bool fDrawInstancedSupport                       : 1;
599*c8dee2aaSAndroid Build Coastguard Worker     bool fNativeDrawIndirectSupport                  : 1;
600*c8dee2aaSAndroid Build Coastguard Worker     bool fUseClientSideIndirectBuffers               : 1;
601*c8dee2aaSAndroid Build Coastguard Worker     bool fConservativeRasterSupport                  : 1;
602*c8dee2aaSAndroid Build Coastguard Worker     bool fWireframeSupport                           : 1;
603*c8dee2aaSAndroid Build Coastguard Worker     bool fMSAAResolvesAutomatically                  : 1;
604*c8dee2aaSAndroid Build Coastguard Worker     bool fPreferDiscardableMSAAAttachment            : 1;
605*c8dee2aaSAndroid Build Coastguard Worker     bool fUsePrimitiveRestart                        : 1;
606*c8dee2aaSAndroid Build Coastguard Worker     bool fPreferClientSideDynamicBuffers             : 1;
607*c8dee2aaSAndroid Build Coastguard Worker     bool fPreferFullscreenClears                     : 1;
608*c8dee2aaSAndroid Build Coastguard Worker     bool fTwoSidedStencilRefsAndMasksMustMatch       : 1;
609*c8dee2aaSAndroid Build Coastguard Worker     bool fMustClearUploadedBufferData                : 1;
610*c8dee2aaSAndroid Build Coastguard Worker     bool fBuffersAreInitiallyZero                    : 1;
611*c8dee2aaSAndroid Build Coastguard Worker     bool fShouldInitializeTextures                   : 1;
612*c8dee2aaSAndroid Build Coastguard Worker     bool fSupportsAHardwareBufferImages              : 1;
613*c8dee2aaSAndroid Build Coastguard Worker     bool fHalfFloatVertexAttributeSupport            : 1;
614*c8dee2aaSAndroid Build Coastguard Worker     bool fClampToBorderSupport                       : 1;
615*c8dee2aaSAndroid Build Coastguard Worker     bool fPerformPartialClearsAsDraws                : 1;
616*c8dee2aaSAndroid Build Coastguard Worker     bool fPerformColorClearsAsDraws                  : 1;
617*c8dee2aaSAndroid Build Coastguard Worker     bool fAvoidLargeIndexBufferDraws                 : 1;
618*c8dee2aaSAndroid Build Coastguard Worker     bool fPerformStencilClearsAsDraws                : 1;
619*c8dee2aaSAndroid Build Coastguard Worker     bool fTransferFromBufferToTextureSupport         : 1;
620*c8dee2aaSAndroid Build Coastguard Worker     bool fTransferFromSurfaceToBufferSupport         : 1;
621*c8dee2aaSAndroid Build Coastguard Worker     bool fTransferFromBufferToBufferSupport          : 1;
622*c8dee2aaSAndroid Build Coastguard Worker     bool fWritePixelsRowBytesSupport                 : 1;
623*c8dee2aaSAndroid Build Coastguard Worker     bool fTransferPixelsToRowBytesSupport            : 1;
624*c8dee2aaSAndroid Build Coastguard Worker     bool fReadPixelsRowBytesSupport                  : 1;
625*c8dee2aaSAndroid Build Coastguard Worker     bool fShouldCollapseSrcOverToSrcWhenAble         : 1;
626*c8dee2aaSAndroid Build Coastguard Worker     bool fMustSyncGpuDuringAbandon                   : 1;
627*c8dee2aaSAndroid Build Coastguard Worker 
628*c8dee2aaSAndroid Build Coastguard Worker     // Driver workaround
629*c8dee2aaSAndroid Build Coastguard Worker     bool fDisableTessellationPathRenderer            : 1;
630*c8dee2aaSAndroid Build Coastguard Worker     bool fAvoidStencilBuffers                        : 1;
631*c8dee2aaSAndroid Build Coastguard Worker     bool fAvoidWritePixelsFastPath                   : 1;
632*c8dee2aaSAndroid Build Coastguard Worker     bool fNativeDrawIndexedIndirectIsBroken          : 1;
633*c8dee2aaSAndroid Build Coastguard Worker     bool fAvoidReorderingRenderTasks                 : 1;
634*c8dee2aaSAndroid Build Coastguard Worker     bool fAvoidDithering                             : 1;
635*c8dee2aaSAndroid Build Coastguard Worker     bool fDisablePerspectiveSDFText                  : 1;
636*c8dee2aaSAndroid Build Coastguard Worker     bool fAvoidLineDraws                             : 1;
637*c8dee2aaSAndroid Build Coastguard Worker 
638*c8dee2aaSAndroid Build Coastguard Worker     // ANGLE performance workaround
639*c8dee2aaSAndroid Build Coastguard Worker     bool fPreferVRAMUseOverFlushes                   : 1;
640*c8dee2aaSAndroid Build Coastguard Worker 
641*c8dee2aaSAndroid Build Coastguard Worker     bool fSemaphoreSupport                           : 1;
642*c8dee2aaSAndroid Build Coastguard Worker     bool fBackendSemaphoreSupport                    : 1;
643*c8dee2aaSAndroid Build Coastguard Worker     bool fFinishedProcAsyncCallbackSupport           : 1;
644*c8dee2aaSAndroid Build Coastguard Worker 
645*c8dee2aaSAndroid Build Coastguard Worker     // Requires fence sync support in GL.
646*c8dee2aaSAndroid Build Coastguard Worker     bool fCrossContextTextureSupport                 : 1;
647*c8dee2aaSAndroid Build Coastguard Worker 
648*c8dee2aaSAndroid Build Coastguard Worker     // Not (yet) implemented in VK backend.
649*c8dee2aaSAndroid Build Coastguard Worker     bool fDynamicStateArrayGeometryProcessorTextureSupport : 1;
650*c8dee2aaSAndroid Build Coastguard Worker 
651*c8dee2aaSAndroid Build Coastguard Worker     bool fSupportsProtectedContent                   : 1;
652*c8dee2aaSAndroid Build Coastguard Worker 
653*c8dee2aaSAndroid Build Coastguard Worker     BlendEquationSupport fBlendEquationSupport;
654*c8dee2aaSAndroid Build Coastguard Worker     uint32_t fAdvBlendEqDisableFlags;
655*c8dee2aaSAndroid Build Coastguard Worker     static_assert(static_cast<int>(skgpu::BlendEquation::kLast) < 32);
656*c8dee2aaSAndroid Build Coastguard Worker 
657*c8dee2aaSAndroid Build Coastguard Worker     uint32_t fMapBufferFlags;
658*c8dee2aaSAndroid Build Coastguard Worker     int fBufferMapThreshold;
659*c8dee2aaSAndroid Build Coastguard Worker 
660*c8dee2aaSAndroid Build Coastguard Worker     int fMaxRenderTargetSize;
661*c8dee2aaSAndroid Build Coastguard Worker     int fMaxPreferredRenderTargetSize;
662*c8dee2aaSAndroid Build Coastguard Worker     int fMaxVertexAttributes;
663*c8dee2aaSAndroid Build Coastguard Worker     int fMaxTextureSize;
664*c8dee2aaSAndroid Build Coastguard Worker     int fMaxWindowRectangles;
665*c8dee2aaSAndroid Build Coastguard Worker     int fInternalMultisampleCount;
666*c8dee2aaSAndroid Build Coastguard Worker     uint32_t fMaxPushConstantsSize = 0;
667*c8dee2aaSAndroid Build Coastguard Worker     size_t fTransferBufferRowBytesAlignment = 1;
668*c8dee2aaSAndroid Build Coastguard Worker     size_t fTransferFromBufferToBufferAlignment = 1;
669*c8dee2aaSAndroid Build Coastguard Worker     size_t fBufferUpdateDataPreserveAlignment = 1;
670*c8dee2aaSAndroid Build Coastguard Worker 
671*c8dee2aaSAndroid Build Coastguard Worker     skgpu::GpuStatsFlags fSupportedGpuStats = skgpu::GpuStatsFlags::kNone;
672*c8dee2aaSAndroid Build Coastguard Worker 
673*c8dee2aaSAndroid Build Coastguard Worker     GrDriverBugWorkarounds fDriverBugWorkarounds;
674*c8dee2aaSAndroid Build Coastguard Worker 
675*c8dee2aaSAndroid Build Coastguard Worker #if defined(GPU_TEST_UTILS)
676*c8dee2aaSAndroid Build Coastguard Worker     std::string fDeviceName;
677*c8dee2aaSAndroid Build Coastguard Worker #endif
678*c8dee2aaSAndroid Build Coastguard Worker 
679*c8dee2aaSAndroid Build Coastguard Worker private:
680*c8dee2aaSAndroid Build Coastguard Worker     void applyOptionsOverrides(const GrContextOptions& options);
681*c8dee2aaSAndroid Build Coastguard Worker 
onApplyOptionsOverrides(const GrContextOptions &)682*c8dee2aaSAndroid Build Coastguard Worker     virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
onDumpJSON(SkJSONWriter *)683*c8dee2aaSAndroid Build Coastguard Worker     virtual void onDumpJSON(SkJSONWriter*) const {}
684*c8dee2aaSAndroid Build Coastguard Worker     virtual bool onSurfaceSupportsWritePixels(const GrSurface*) const = 0;
685*c8dee2aaSAndroid Build Coastguard Worker     virtual bool onCanCopySurface(const GrSurfaceProxy* dst, const SkIRect& dstRect,
686*c8dee2aaSAndroid Build Coastguard Worker                                   const GrSurfaceProxy* src, const SkIRect& srcRect) const = 0;
687*c8dee2aaSAndroid Build Coastguard Worker     virtual GrBackendFormat onGetDefaultBackendFormat(GrColorType) const = 0;
688*c8dee2aaSAndroid Build Coastguard Worker 
689*c8dee2aaSAndroid Build Coastguard Worker     // Backends should implement this if they have any extra requirements for use of window
690*c8dee2aaSAndroid Build Coastguard Worker     // rectangles for a specific GrBackendRenderTarget outside of basic support.
onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget &)691*c8dee2aaSAndroid Build Coastguard Worker     virtual bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const {
692*c8dee2aaSAndroid Build Coastguard Worker         return true;
693*c8dee2aaSAndroid Build Coastguard Worker     }
694*c8dee2aaSAndroid Build Coastguard Worker 
695*c8dee2aaSAndroid Build Coastguard Worker     virtual bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const = 0;
696*c8dee2aaSAndroid Build Coastguard Worker 
697*c8dee2aaSAndroid Build Coastguard Worker     virtual SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType,
698*c8dee2aaSAndroid Build Coastguard Worker                                                          const GrBackendFormat& srcFormat,
699*c8dee2aaSAndroid Build Coastguard Worker                                                          GrColorType dstColorType) const = 0;
700*c8dee2aaSAndroid Build Coastguard Worker 
701*c8dee2aaSAndroid Build Coastguard Worker     virtual skgpu::Swizzle onGetReadSwizzle(const GrBackendFormat&, GrColorType) const = 0;
702*c8dee2aaSAndroid Build Coastguard Worker 
onGetDstSampleFlagsForProxy(const GrRenderTargetProxy *)703*c8dee2aaSAndroid Build Coastguard Worker     virtual GrDstSampleFlags onGetDstSampleFlagsForProxy(const GrRenderTargetProxy*) const {
704*c8dee2aaSAndroid Build Coastguard Worker         return GrDstSampleFlags::kNone;
705*c8dee2aaSAndroid Build Coastguard Worker     }
706*c8dee2aaSAndroid Build Coastguard Worker 
707*c8dee2aaSAndroid Build Coastguard Worker     bool fSuppressPrints : 1;
708*c8dee2aaSAndroid Build Coastguard Worker     bool fWireframeMode  : 1;
709*c8dee2aaSAndroid Build Coastguard Worker 
710*c8dee2aaSAndroid Build Coastguard Worker     using INHERITED = SkRefCnt;
711*c8dee2aaSAndroid Build Coastguard Worker };
712*c8dee2aaSAndroid Build Coastguard Worker 
713*c8dee2aaSAndroid Build Coastguard Worker SK_MAKE_BITFIELD_CLASS_OPS(GrCaps::ProgramDescOverrideFlags)
714*c8dee2aaSAndroid Build Coastguard Worker 
715*c8dee2aaSAndroid Build Coastguard Worker #endif
716