1 | |
2 | /* |
3 | * Copyright 2013 Google Inc. |
4 | * |
5 | * Use of this source code is governed by a BSD-style license that can be |
6 | * found in the LICENSE file. |
7 | */ |
8 | #ifndef GrCaps_DEFINED |
9 | #define GrCaps_DEFINED |
10 | |
11 | #include "include/core/SkImageInfo.h" |
12 | #include "include/core/SkRefCnt.h" |
13 | #include "include/core/SkString.h" |
14 | #include "include/gpu/GrDriverBugWorkarounds.h" |
15 | #include "include/private/GrTypesPriv.h" |
16 | #include "src/gpu/GrBlend.h" |
17 | #include "src/gpu/GrSamplerState.h" |
18 | #include "src/gpu/GrShaderCaps.h" |
19 | #include "src/gpu/GrSurfaceProxy.h" |
20 | |
21 | class GrBackendFormat; |
22 | class GrBackendRenderTarget; |
23 | class GrBackendTexture; |
24 | struct GrContextOptions; |
25 | class GrProcessorKeyBuilder; |
26 | class GrProgramDesc; |
27 | class GrProgramInfo; |
28 | class GrRenderTargetProxy; |
29 | class GrSurface; |
30 | class SkJSONWriter; |
31 | |
32 | /** |
33 | * Represents the capabilities of a GrContext. |
34 | */ |
35 | class GrCaps : public SkRefCnt { |
36 | public: |
37 | GrCaps(const GrContextOptions&); |
38 | |
39 | void dumpJSON(SkJSONWriter*) const; |
40 | |
41 | const GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); } |
42 | sk_sp<const GrShaderCaps> refShaderCaps() const { return fShaderCaps; } |
43 | |
44 | bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } |
45 | /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g. |
46 | only for POT textures) */ |
47 | bool mipMapSupport() const { return fMipMapSupport; } |
48 | |
49 | bool gpuTracingSupport() const { return fGpuTracingSupport; } |
50 | bool oversizedStencilSupport() const { return fOversizedStencilSupport; } |
51 | bool textureBarrierSupport() const { return fTextureBarrierSupport; } |
52 | bool sampleLocationsSupport() const { return fSampleLocationsSupport; } |
53 | bool multisampleDisableSupport() const { return fMultisampleDisableSupport; } |
54 | bool drawInstancedSupport() const { return fDrawInstancedSupport; } |
55 | // Is there hardware support for indirect draws? (Ganesh always supports indirect draws as long |
56 | // as it can polyfill them with instanced calls, but this cap tells us if they are supported |
57 | // natively.) |
58 | bool nativeDrawIndirectSupport() const { return fNativeDrawIndirectSupport; } |
59 | bool mixedSamplesSupport() const { return fMixedSamplesSupport; } |
60 | bool conservativeRasterSupport() const { return fConservativeRasterSupport; } |
61 | bool wireframeSupport() const { return fWireframeSupport; } |
62 | // This flag indicates that we never have to resolve MSAA. In practice, it means that we have |
63 | // an MSAA-render-to-texture extension: Any render target we create internally will use the |
64 | // extension, and any wrapped render target is the client's responsibility. |
65 | bool msaaResolvesAutomatically() const { return fMSAAResolvesAutomatically; } |
66 | bool halfFloatVertexAttributeSupport() const { return fHalfFloatVertexAttributeSupport; } |
67 | |
68 | // Primitive restart functionality is core in ES 3.0, but using it will cause slowdowns on some |
69 | // systems. This cap is only set if primitive restart will improve performance. |
70 | bool usePrimitiveRestart() const { return fUsePrimitiveRestart; } |
71 | |
72 | bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; } |
73 | |
74 | // On tilers, an initial fullscreen clear is an OPTIMIZATION. It allows the hardware to |
75 | // initialize each tile with a constant value rather than loading each pixel from memory. |
76 | bool preferFullscreenClears() const { return fPreferFullscreenClears; } |
77 | |
78 | // Should we discard stencil values after a render pass? (Tilers get better performance if we |
79 | // always load stencil buffers with a "clear" op, and then discard the content when finished.) |
80 | bool discardStencilValuesAfterRenderPass() const { |
81 | // This method is actually just a duplicate of preferFullscreenClears(), with a descriptive |
82 | // name for the sake of readability. |
83 | return this->preferFullscreenClears(); |
84 | } |
85 | |
86 | bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; } |
87 | |
88 | bool preferTrianglesOverSampleMask() const { return fPreferTrianglesOverSampleMask; } |
89 | |
90 | bool avoidStencilBuffers() const { return fAvoidStencilBuffers; } |
91 | |
92 | bool avoidWritePixelsFastPath() const { return fAvoidWritePixelsFastPath; } |
93 | |
94 | // http://skbug.com/9739 |
95 | bool requiresManualFBBarrierAfterTessellatedStencilDraw() const { |
96 | return fRequiresManualFBBarrierAfterTessellatedStencilDraw; |
97 | } |
98 | |
99 | // glDrawElementsIndirect fails GrMeshTest on every Win10 Intel bot. |
100 | bool nativeDrawIndexedIndirectIsBroken() const { return fNativeDrawIndexedIndirectIsBroken; } |
101 | |
102 | /** |
103 | * Indicates the capabilities of the fixed function blend unit. |
104 | */ |
105 | enum BlendEquationSupport { |
106 | kBasic_BlendEquationSupport, //<! Support to select the operator that |
107 | // combines src and dst terms. |
108 | kAdvanced_BlendEquationSupport, //<! Additional fixed function support for specific |
109 | // SVG/PDF blend modes. Requires blend barriers. |
110 | kAdvancedCoherent_BlendEquationSupport, //<! Advanced blend equation support that does not |
111 | // require blend barriers, and permits overlap. |
112 | |
113 | kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport |
114 | }; |
115 | |
116 | BlendEquationSupport blendEquationSupport() const { return fBlendEquationSupport; } |
117 | |
118 | bool advancedBlendEquationSupport() const { |
119 | return fBlendEquationSupport >= kAdvanced_BlendEquationSupport; |
120 | } |
121 | |
122 | bool advancedCoherentBlendEquationSupport() const { |
123 | return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport; |
124 | } |
125 | |
126 | bool isAdvancedBlendEquationBlacklisted(GrBlendEquation equation) const { |
127 | SkASSERT(GrBlendEquationIsAdvanced(equation)); |
128 | SkASSERT(this->advancedBlendEquationSupport()); |
129 | return SkToBool(fAdvBlendEqBlacklist & (1 << equation)); |
130 | } |
131 | |
132 | // On some GPUs it is a performance win to disable blending instead of doing src-over with a src |
133 | // alpha equal to 1. To disable blending we collapse src-over to src and the backends will |
134 | // handle the disabling of blending. |
135 | bool shouldCollapseSrcOverToSrcWhenAble() const { |
136 | return fShouldCollapseSrcOverToSrcWhenAble; |
137 | } |
138 | |
139 | /** |
140 | * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and |
141 | * textures allows partial mappings or full mappings. |
142 | */ |
143 | enum MapFlags { |
144 | kNone_MapFlags = 0x0, //<! Cannot map the resource. |
145 | |
146 | kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be set for any of |
147 | // the other flags to have meaning. |
148 | kSubset_MapFlag = 0x2, //<! The resource can be partially mapped. |
149 | kAsyncRead_MapFlag = 0x4, //<! Are maps for reading asynchronous WRT GrOpsRenderPass |
150 | // submitted to GrGpu. |
151 | }; |
152 | |
153 | uint32_t mapBufferFlags() const { return fMapBufferFlags; } |
154 | |
155 | // Scratch textures not being reused means that those scratch textures |
156 | // that we upload to (i.e., don't have a render target) will not be |
157 | // recycled in the texture cache. This is to prevent ghosting by drivers |
158 | // (in particular for deferred architectures). |
159 | bool reuseScratchTextures() const { return fReuseScratchTextures; } |
160 | bool reuseScratchBuffers() const { return fReuseScratchBuffers; } |
161 | |
162 | /// maximum number of attribute values per vertex |
163 | int maxVertexAttributes() const { return fMaxVertexAttributes; } |
164 | |
165 | int maxRenderTargetSize() const { return fMaxRenderTargetSize; } |
166 | |
167 | /** This is the largest render target size that can be used without incurring extra perfomance |
168 | cost. It is usually the max RT size, unless larger render targets are known to be slower. */ |
169 | int maxPreferredRenderTargetSize() const { return fMaxPreferredRenderTargetSize; } |
170 | |
171 | int maxTextureSize() const { return fMaxTextureSize; } |
172 | |
173 | /** This is the maximum tile size to use by GPU devices for rendering sw-backed images/bitmaps. |
174 | It is usually the max texture size, unless we're overriding it for testing. */ |
175 | int maxTileSize() const { |
176 | SkASSERT(fMaxTileSize <= fMaxTextureSize); |
177 | return fMaxTileSize; |
178 | } |
179 | |
180 | int maxWindowRectangles() const { return fMaxWindowRectangles; } |
181 | |
182 | // Returns whether mixed samples is supported for the given backend render target. |
183 | bool isWindowRectanglesSupportedForRT(const GrBackendRenderTarget& rt) const { |
184 | return this->maxWindowRectangles() > 0 && this->onIsWindowRectanglesSupportedForRT(rt); |
185 | } |
186 | |
187 | virtual bool isFormatSRGB(const GrBackendFormat&) const = 0; |
188 | |
189 | // This will return SkImage::CompressionType::kNone if the backend format is not compressed. |
190 | virtual SkImage::CompressionType compressionType(const GrBackendFormat&) const = 0; |
191 | |
192 | bool isFormatCompressed(const GrBackendFormat& format) const { |
193 | return this->compressionType(format) != SkImage::CompressionType::kNone; |
194 | } |
195 | |
196 | // Can a texture be made with the GrBackendFormat, and then be bound and sampled in a shader. |
197 | virtual bool isFormatTexturable(const GrBackendFormat&) const = 0; |
198 | |
199 | // Returns whether a texture of the given format can be copied to a texture of the same format. |
200 | virtual bool isFormatCopyable(const GrBackendFormat&) const = 0; |
201 | |
202 | // Returns the maximum supported sample count for a format. 0 means the format is not renderable |
203 | // 1 means the format is renderable but doesn't support MSAA. |
204 | virtual int maxRenderTargetSampleCount(const GrBackendFormat&) const = 0; |
205 | |
206 | // Returns the number of samples to use when performing internal draws to the given config with |
207 | // MSAA or mixed samples. If 0, Ganesh should not attempt to use internal multisampling. |
208 | int internalMultisampleCount(const GrBackendFormat& format) const { |
209 | return std::min(fInternalMultisampleCount, this->maxRenderTargetSampleCount(format)); |
210 | } |
211 | |
212 | virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat& format, |
213 | int sampleCount = 1) const = 0; |
214 | |
215 | virtual bool isFormatRenderable(const GrBackendFormat& format, int sampleCount) const = 0; |
216 | |
217 | // Find a sample count greater than or equal to the requested count which is supported for a |
218 | // render target of the given format or 0 if no such sample count is supported. If the requested |
219 | // sample count is 1 then 1 will be returned if non-MSAA rendering is supported, otherwise 0. |
220 | // For historical reasons requestedCount==0 is handled identically to requestedCount==1. |
221 | virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat&) const = 0; |
222 | |
223 | // Returns the number of bytes per pixel for the given GrBackendFormat. This is only supported |
224 | // for "normal" formats. For compressed formats this will return 0. |
225 | virtual size_t bytesPerPixel(const GrBackendFormat&) const = 0; |
226 | |
227 | /** |
228 | * Backends may have restrictions on what types of surfaces support GrGpu::writePixels(). |
229 | * If this returns false then the caller should implement a fallback where a temporary texture |
230 | * is created, pixels are written to it, and then that is copied or drawn into the the surface. |
231 | */ |
232 | bool surfaceSupportsWritePixels(const GrSurface*) const; |
233 | |
234 | /** |
235 | * Indicates whether surface supports GrGpu::readPixels, must be copied, or cannot be read. |
236 | */ |
237 | enum class SurfaceReadPixelsSupport { |
238 | /** GrGpu::readPixels is supported by the surface. */ |
239 | kSupported, |
240 | /** |
241 | * GrGpu::readPixels is not supported by this surface but this surface can be drawn |
242 | * or copied to a Ganesh-created GrTextureType::kTexture2D and then that surface will be |
243 | * readable. |
244 | */ |
245 | kCopyToTexture2D, |
246 | /** |
247 | * Not supported |
248 | */ |
249 | kUnsupported, |
250 | }; |
251 | /** |
252 | * Backends may have restrictions on what types of surfaces support GrGpu::readPixels(). We may |
253 | * either be able to read directly from the surface, read from a copy of the surface, or not |
254 | * read at all. |
255 | */ |
256 | virtual SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const = 0; |
257 | |
258 | struct SupportedWrite { |
259 | GrColorType fColorType; |
260 | // If the write is occurring using GrGpu::transferPixelsTo then this provides the |
261 | // minimum alignment of the offset into the transfer buffer. |
262 | size_t fOffsetAlignmentForTransferBuffer; |
263 | }; |
264 | |
265 | /** |
266 | * Given a dst pixel config and a src color type what color type must the caller coax the |
267 | * the data into in order to use GrGpu::writePixels(). |
268 | */ |
269 | virtual SupportedWrite supportedWritePixelsColorType(GrColorType surfaceColorType, |
270 | const GrBackendFormat& surfaceFormat, |
271 | GrColorType srcColorType) const = 0; |
272 | |
273 | struct SupportedRead { |
274 | GrColorType fColorType; |
275 | // If the read is occurring using GrGpu::transferPixelsFrom then this provides the |
276 | // minimum alignment of the offset into the transfer buffer. |
277 | size_t fOffsetAlignmentForTransferBuffer; |
278 | }; |
279 | |
280 | /** |
281 | * Given a src surface's color type and its backend format as well as a color type the caller |
282 | * would like read into, this provides a legal color type that the caller may pass to |
283 | * GrGpu::readPixels(). The returned color type may differ from the passed dstColorType, in |
284 | * which case the caller must convert the read pixel data (see GrConvertPixels). When converting |
285 | * to dstColorType the swizzle in the returned struct should be applied. The caller must check |
286 | * the returned color type for kUnknown. |
287 | */ |
288 | SupportedRead supportedReadPixelsColorType(GrColorType srcColorType, |
289 | const GrBackendFormat& srcFormat, |
290 | GrColorType dstColorType) const; |
291 | |
292 | /** |
293 | * Do GrGpu::writePixels() and GrGpu::transferPixelsTo() support a src buffer where the row |
294 | * bytes is not equal to bpp * w? |
295 | */ |
296 | bool writePixelsRowBytesSupport() const { return fWritePixelsRowBytesSupport; } |
297 | /** |
298 | * Does GrGpu::readPixels() support a dst buffer where the row bytes is not equal to bpp * w? |
299 | */ |
300 | bool readPixelsRowBytesSupport() const { return fReadPixelsRowBytesSupport; } |
301 | |
302 | bool transferFromSurfaceToBufferSupport() const { return fTransferFromSurfaceToBufferSupport; } |
303 | bool transferFromBufferToTextureSupport() const { return fTransferFromBufferToTextureSupport; } |
304 | |
305 | bool suppressPrints() const { return fSuppressPrints; } |
306 | |
307 | size_t bufferMapThreshold() const { |
308 | SkASSERT(fBufferMapThreshold >= 0); |
309 | return fBufferMapThreshold; |
310 | } |
311 | |
312 | /** True in environments that will issue errors if memory uploaded to buffers |
313 | is not initialized (even if not read by draw calls). */ |
314 | bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; } |
315 | |
316 | /** For some environments, there is a performance or safety concern to not |
317 | initializing textures. For example, with WebGL and Firefox, there is a large |
318 | performance hit to not doing it. |
319 | */ |
320 | bool shouldInitializeTextures() const { return fShouldInitializeTextures; } |
321 | |
322 | /** Returns true if the given backend supports importing AHardwareBuffers via the |
323 | * GrAHardwarebufferImageGenerator. This will only ever be supported on Android devices with API |
324 | * level >= 26. |
325 | * */ |
326 | bool supportsAHardwareBufferImages() const { return fSupportsAHardwareBufferImages; } |
327 | |
328 | bool wireframeMode() const { return fWireframeMode; } |
329 | |
330 | /** Supports using GrFence. */ |
331 | bool fenceSyncSupport() const { return fFenceSyncSupport; } |
332 | |
333 | /** Supports using GrSemaphore. */ |
334 | bool semaphoreSupport() const { return fSemaphoreSupport; } |
335 | |
336 | bool crossContextTextureSupport() const { return fCrossContextTextureSupport; } |
337 | /** |
338 | * Returns whether or not we will be able to do a copy given the passed in params |
339 | */ |
340 | bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src, |
341 | const SkIRect& srcRect, const SkIPoint& dstPoint) const; |
342 | |
343 | bool dynamicStateArrayGeometryProcessorTextureSupport() const { |
344 | return fDynamicStateArrayGeometryProcessorTextureSupport; |
345 | } |
346 | |
347 | // Not all backends support clearing with a scissor test (e.g. Metal), this will always |
348 | // return true if performColorClearsAsDraws() returns true. |
349 | bool performPartialClearsAsDraws() const { |
350 | return fPerformColorClearsAsDraws || fPerformPartialClearsAsDraws; |
351 | } |
352 | |
353 | // Many drivers have issues with color clears. |
354 | bool performColorClearsAsDraws() const { return fPerformColorClearsAsDraws; } |
355 | |
356 | bool avoidLargeIndexBufferDraws() const { return fAvoidLargeIndexBufferDraws; } |
357 | |
358 | /// Adreno 4xx devices experience an issue when there are a large number of stencil clip bit |
359 | /// clears. The minimal repro steps are not precisely known but drawing a rect with a stencil |
360 | /// op instead of using glClear seems to resolve the issue. |
361 | bool performStencilClearsAsDraws() const { return fPerformStencilClearsAsDraws; } |
362 | |
363 | // Can we use coverage counting shortcuts to render paths? Coverage counting can cause artifacts |
364 | // along shared edges if care isn't taken to ensure both contours wind in the same direction. |
365 | bool allowCoverageCounting() const { return fAllowCoverageCounting; } |
366 | |
367 | // Should we disable the CCPR code due to a faulty driver? |
368 | bool driverBlacklistCCPR() const { return fDriverBlacklistCCPR; } |
369 | bool driverBlacklistMSAACCPR() const { return fDriverBlacklistMSAACCPR; } |
370 | |
371 | /** |
372 | * This is used to try to ensure a successful copy a dst in order to perform shader-based |
373 | * blending. |
374 | * |
375 | * fRectsMustMatch will be set to true if the copy operation must ensure that the src and dest |
376 | * rects are identical. |
377 | * |
378 | * fMustCopyWholeSrc will be set to true if copy rect must equal src's bounds. |
379 | * |
380 | * Caller will detect cases when copy cannot succeed and try copy-as-draw as a fallback. |
381 | */ |
382 | struct DstCopyRestrictions { |
383 | GrSurfaceProxy::RectsMustMatch fRectsMustMatch = GrSurfaceProxy::RectsMustMatch::kNo; |
384 | bool fMustCopyWholeSrc = false; |
385 | }; |
386 | virtual DstCopyRestrictions getDstCopyRestrictions(const GrRenderTargetProxy* src, |
387 | GrColorType ct) const { |
388 | return {}; |
389 | } |
390 | |
391 | bool validateSurfaceParams(const SkISize&, const GrBackendFormat&, GrRenderable renderable, |
392 | int renderTargetSampleCnt, GrMipMapped) const; |
393 | |
394 | bool areColorTypeAndFormatCompatible(GrColorType grCT, |
395 | const GrBackendFormat& format) const { |
396 | if (GrColorType::kUnknown == grCT) { |
397 | return false; |
398 | } |
399 | |
400 | return this->onAreColorTypeAndFormatCompatible(grCT, format); |
401 | } |
402 | |
403 | /** These are used when creating a new texture internally. */ |
404 | GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const; |
405 | |
406 | virtual GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const = 0; |
407 | |
408 | /** |
409 | * The CLAMP_TO_BORDER wrap mode for texture coordinates was added to desktop GL in 1.3, and |
410 | * GLES 3.2, but is also available in extensions. Vulkan and Metal always have support. |
411 | */ |
412 | bool clampToBorderSupport() const { return fClampToBorderSupport; } |
413 | |
414 | /** |
415 | * Returns the GrSwizzle to use when sampling or reading back from a texture with the passed in |
416 | * GrBackendFormat and GrColorType. |
417 | */ |
418 | virtual GrSwizzle getReadSwizzle(const GrBackendFormat&, GrColorType) const = 0; |
419 | |
420 | /** |
421 | * Returns the GrSwizzle to use when writing colors to a surface with the passed in |
422 | * GrBackendFormat and GrColorType. |
423 | */ |
424 | virtual GrSwizzle getWriteSwizzle(const GrBackendFormat&, GrColorType) const = 0; |
425 | |
426 | virtual uint64_t computeFormatKey(const GrBackendFormat&) const = 0; |
427 | |
428 | const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; } |
429 | |
430 | /** |
431 | * Adds fields to the key to represent the sampler that will be created for the passed |
432 | * in parameters. Currently this extra keying is only needed when building a vulkan pipeline |
433 | * with immutable samplers. |
434 | */ |
435 | virtual void (GrProcessorKeyBuilder*, |
436 | GrSamplerState, |
437 | const GrBackendFormat&) const {} |
438 | |
439 | virtual GrProgramDesc makeDesc(const GrRenderTarget*, const GrProgramInfo&) const = 0; |
440 | |
441 | #if GR_TEST_UTILS |
442 | struct TestFormatColorTypeCombination { |
443 | GrColorType fColorType; |
444 | GrBackendFormat fFormat; |
445 | }; |
446 | |
447 | virtual std::vector<TestFormatColorTypeCombination> getTestingCombinations() const = 0; |
448 | #endif |
449 | |
450 | protected: |
451 | // Subclasses must call this at the end of their init method in order to do final processing on |
452 | // the caps (including overrides requested by the client). |
453 | // NOTE: this method will only reduce the caps, never expand them. |
454 | void finishInitialization(const GrContextOptions& options); |
455 | |
456 | sk_sp<GrShaderCaps> fShaderCaps; |
457 | |
458 | bool fNPOTTextureTileSupport : 1; |
459 | bool fMipMapSupport : 1; |
460 | bool fReuseScratchTextures : 1; |
461 | bool fReuseScratchBuffers : 1; |
462 | bool fGpuTracingSupport : 1; |
463 | bool fOversizedStencilSupport : 1; |
464 | bool fTextureBarrierSupport : 1; |
465 | bool fSampleLocationsSupport : 1; |
466 | bool fMultisampleDisableSupport : 1; |
467 | bool fDrawInstancedSupport : 1; |
468 | bool fNativeDrawIndirectSupport : 1; |
469 | bool fMixedSamplesSupport : 1; |
470 | bool fConservativeRasterSupport : 1; |
471 | bool fWireframeSupport : 1; |
472 | bool fMSAAResolvesAutomatically : 1; |
473 | bool fUsePrimitiveRestart : 1; |
474 | bool fPreferClientSideDynamicBuffers : 1; |
475 | bool fPreferFullscreenClears : 1; |
476 | bool fMustClearUploadedBufferData : 1; |
477 | bool fShouldInitializeTextures : 1; |
478 | bool fSupportsAHardwareBufferImages : 1; |
479 | bool fHalfFloatVertexAttributeSupport : 1; |
480 | bool fClampToBorderSupport : 1; |
481 | bool fPerformPartialClearsAsDraws : 1; |
482 | bool fPerformColorClearsAsDraws : 1; |
483 | bool fAvoidLargeIndexBufferDraws : 1; |
484 | bool fPerformStencilClearsAsDraws : 1; |
485 | bool fAllowCoverageCounting : 1; |
486 | bool fTransferFromBufferToTextureSupport : 1; |
487 | bool fTransferFromSurfaceToBufferSupport : 1; |
488 | bool fWritePixelsRowBytesSupport : 1; |
489 | bool fReadPixelsRowBytesSupport : 1; |
490 | bool fShouldCollapseSrcOverToSrcWhenAble : 1; |
491 | |
492 | // Driver workaround |
493 | bool fDriverBlacklistCCPR : 1; |
494 | bool fDriverBlacklistMSAACCPR : 1; |
495 | bool fAvoidStencilBuffers : 1; |
496 | bool fAvoidWritePixelsFastPath : 1; |
497 | bool fRequiresManualFBBarrierAfterTessellatedStencilDraw : 1; |
498 | bool fNativeDrawIndexedIndirectIsBroken : 1; |
499 | |
500 | // ANGLE performance workaround |
501 | bool fPreferVRAMUseOverFlushes : 1; |
502 | |
503 | // On some platforms it's better to make more triangles than to use the sample mask (MSAA only). |
504 | bool fPreferTrianglesOverSampleMask : 1; |
505 | |
506 | bool fFenceSyncSupport : 1; |
507 | bool fSemaphoreSupport : 1; |
508 | |
509 | // Requires fence sync support in GL. |
510 | bool fCrossContextTextureSupport : 1; |
511 | |
512 | // Not (yet) implemented in VK backend. |
513 | bool fDynamicStateArrayGeometryProcessorTextureSupport : 1; |
514 | |
515 | BlendEquationSupport fBlendEquationSupport; |
516 | uint32_t fAdvBlendEqBlacklist; |
517 | static_assert(kLast_GrBlendEquation < 32); |
518 | |
519 | uint32_t fMapBufferFlags; |
520 | int fBufferMapThreshold; |
521 | |
522 | int fMaxRenderTargetSize; |
523 | int fMaxPreferredRenderTargetSize; |
524 | int fMaxVertexAttributes; |
525 | int fMaxTextureSize; |
526 | int fMaxTileSize; |
527 | int fMaxWindowRectangles; |
528 | int fInternalMultisampleCount; |
529 | |
530 | GrDriverBugWorkarounds fDriverBugWorkarounds; |
531 | |
532 | private: |
533 | void applyOptionsOverrides(const GrContextOptions& options); |
534 | |
535 | virtual void onApplyOptionsOverrides(const GrContextOptions&) {} |
536 | virtual void onDumpJSON(SkJSONWriter*) const {} |
537 | virtual bool onSurfaceSupportsWritePixels(const GrSurface*) const = 0; |
538 | virtual bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src, |
539 | const SkIRect& srcRect, const SkIPoint& dstPoint) const = 0; |
540 | virtual GrBackendFormat onGetDefaultBackendFormat(GrColorType) const = 0; |
541 | |
542 | // Backends should implement this if they have any extra requirements for use of window |
543 | // rectangles for a specific GrBackendRenderTarget outside of basic support. |
544 | virtual bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const { |
545 | return true; |
546 | } |
547 | |
548 | virtual bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const = 0; |
549 | |
550 | virtual SupportedRead onSupportedReadPixelsColorType(GrColorType srcColorType, |
551 | const GrBackendFormat& srcFormat, |
552 | GrColorType dstColorType) const = 0; |
553 | |
554 | bool fSuppressPrints : 1; |
555 | bool fWireframeMode : 1; |
556 | |
557 | typedef SkRefCnt INHERITED; |
558 | }; |
559 | |
560 | #endif |
561 | |