GrCaps.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*
  2. * Copyright 2013 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrCaps_DEFINED
  8. #define GrCaps_DEFINED
  9. #include "include/core/SkImageInfo.h"
  10. #include "include/core/SkRefCnt.h"
  11. #include "include/core/SkString.h"
  12. #include "include/gpu/GrBlend.h"
  13. #include "include/gpu/GrDriverBugWorkarounds.h"
  14. #include "include/private/GrTypesPriv.h"
  15. #include "src/gpu/GrShaderCaps.h"
  16. #include "src/gpu/GrSurfaceProxy.h"
  17. class GrBackendFormat;
  18. class GrBackendRenderTarget;
  19. class GrBackendTexture;
  20. struct GrContextOptions;
  21. class GrRenderTargetProxy;
  22. class GrSurface;
  23. class SkJSONWriter;
  24. /**
  25. * Represents the capabilities of a GrContext.
  26. */
  27. class GrCaps : public SkRefCnt {
  28. public:
  29. GrCaps(const GrContextOptions&);
  30. void dumpJSON(SkJSONWriter*) const;
  31. const GrShaderCaps* shaderCaps() const { return fShaderCaps.get(); }
  32. bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
  33. /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
  34. only for POT textures) */
  35. bool mipMapSupport() const { return fMipMapSupport; }
  36. /**
  37. * Skia convention is that a device only has sRGB support if it supports sRGB formats for both
  38. * textures and framebuffers.
  39. */
  40. bool srgbSupport() const { return fSRGBSupport; }
  41. /**
  42. * Is there support for enabling/disabling sRGB writes for sRGB-capable color buffers?
  43. */
  44. bool srgbWriteControl() const { return fSRGBWriteControl; }
  45. bool gpuTracingSupport() const { return fGpuTracingSupport; }
  46. bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
  47. bool textureBarrierSupport() const { return fTextureBarrierSupport; }
  48. bool sampleLocationsSupport() const { return fSampleLocationsSupport; }
  49. bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
  50. bool instanceAttribSupport() const { return fInstanceAttribSupport; }
  51. bool mixedSamplesSupport() const { return fMixedSamplesSupport; }
  52. bool halfFloatVertexAttributeSupport() const { return fHalfFloatVertexAttributeSupport; }
  53. // Primitive restart functionality is core in ES 3.0, but using it will cause slowdowns on some
  54. // systems. This cap is only set if primitive restart will improve performance.
  55. bool usePrimitiveRestart() const { return fUsePrimitiveRestart; }
  56. bool preferClientSideDynamicBuffers() const { return fPreferClientSideDynamicBuffers; }
  57. // On tilers, an initial fullscreen clear is an OPTIMIZATION. It allows the hardware to
  58. // initialize each tile with a constant value rather than loading each pixel from memory.
  59. bool preferFullscreenClears() const { return fPreferFullscreenClears; }
  60. bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; }
  61. bool preferTrianglesOverSampleMask() const { return fPreferTrianglesOverSampleMask; }
  62. bool avoidStencilBuffers() const { return fAvoidStencilBuffers; }
  63. bool avoidWritePixelsFastPath() const { return fAvoidWritePixelsFastPath; }
  64. /**
  65. * Indicates the capabilities of the fixed function blend unit.
  66. */
  67. enum BlendEquationSupport {
  68. kBasic_BlendEquationSupport, //<! Support to select the operator that
  69. // combines src and dst terms.
  70. kAdvanced_BlendEquationSupport, //<! Additional fixed function support for specific
  71. // SVG/PDF blend modes. Requires blend barriers.
  72. kAdvancedCoherent_BlendEquationSupport, //<! Advanced blend equation support that does not
  73. // require blend barriers, and permits overlap.
  74. kLast_BlendEquationSupport = kAdvancedCoherent_BlendEquationSupport
  75. };
  76. BlendEquationSupport blendEquationSupport() const { return fBlendEquationSupport; }
  77. bool advancedBlendEquationSupport() const {
  78. return fBlendEquationSupport >= kAdvanced_BlendEquationSupport;
  79. }
  80. bool advancedCoherentBlendEquationSupport() const {
  81. return kAdvancedCoherent_BlendEquationSupport == fBlendEquationSupport;
  82. }
  83. bool isAdvancedBlendEquationBlacklisted(GrBlendEquation equation) const {
  84. SkASSERT(GrBlendEquationIsAdvanced(equation));
  85. SkASSERT(this->advancedBlendEquationSupport());
  86. return SkToBool(fAdvBlendEqBlacklist & (1 << equation));
  87. }
  88. /**
  89. * Indicates whether GPU->CPU memory mapping for GPU resources such as vertex buffers and
  90. * textures allows partial mappings or full mappings.
  91. */
  92. enum MapFlags {
  93. kNone_MapFlags = 0x0, //<! Cannot map the resource.
  94. kCanMap_MapFlag = 0x1, //<! The resource can be mapped. Must be set for any of
  95. // the other flags to have meaning.
  96. kSubset_MapFlag = 0x2, //<! The resource can be partially mapped.
  97. kAsyncRead_MapFlag = 0x4, //<! Are maps for reading asynchronous WRT GrGpuCommandBuffers
  98. // submitted to GrGpu.
  99. };
  100. uint32_t mapBufferFlags() const { return fMapBufferFlags; }
  101. // Scratch textures not being reused means that those scratch textures
  102. // that we upload to (i.e., don't have a render target) will not be
  103. // recycled in the texture cache. This is to prevent ghosting by drivers
  104. // (in particular for deferred architectures).
  105. bool reuseScratchTextures() const { return fReuseScratchTextures; }
  106. bool reuseScratchBuffers() const { return fReuseScratchBuffers; }
  107. /// maximum number of attribute values per vertex
  108. int maxVertexAttributes() const { return fMaxVertexAttributes; }
  109. int maxRenderTargetSize() const { return fMaxRenderTargetSize; }
  110. /** This is the largest render target size that can be used without incurring extra perfomance
  111. cost. It is usually the max RT size, unless larger render targets are known to be slower. */
  112. int maxPreferredRenderTargetSize() const { return fMaxPreferredRenderTargetSize; }
  113. int maxTextureSize() const { return fMaxTextureSize; }
  114. /** This is the maximum tile size to use by GPU devices for rendering sw-backed images/bitmaps.
  115. It is usually the max texture size, unless we're overriding it for testing. */
  116. int maxTileSize() const {
  117. SkASSERT(fMaxTileSize <= fMaxTextureSize);
  118. return fMaxTileSize;
  119. }
  120. int maxWindowRectangles() const { return fMaxWindowRectangles; }
  121. // Returns whether mixed samples is supported for the given backend render target.
  122. bool isWindowRectanglesSupportedForRT(const GrBackendRenderTarget& rt) const {
  123. return this->maxWindowRectangles() > 0 && this->onIsWindowRectanglesSupportedForRT(rt);
  124. }
  125. virtual bool isFormatSRGB(const GrBackendFormat&) const = 0;
  126. virtual bool isFormatTexturable(GrColorType, const GrBackendFormat&) const = 0;
  127. virtual bool isConfigTexturable(GrPixelConfig) const = 0;
  128. // Returns whether a texture of the given config can be copied to a texture of the same config.
  129. virtual bool isFormatCopyable(GrColorType, const GrBackendFormat&) const = 0;
  130. virtual bool isConfigCopyable(GrPixelConfig) const = 0;
  131. // Returns the maximum supported sample count for a config. 0 means the config is not renderable
  132. // 1 means the config is renderable but doesn't support MSAA.
  133. virtual int maxRenderTargetSampleCount(GrColorType, const GrBackendFormat&) const = 0;
  134. virtual int maxRenderTargetSampleCount(GrPixelConfig) const = 0;
  135. // Returns the number of samples to use when performing internal draws to the given config with
  136. // MSAA or mixed samples. If 0, Ganesh should not attempt to use internal multisampling.
  137. int internalMultisampleCount(GrPixelConfig config) const {
  138. return SkTMin(fInternalMultisampleCount, this->maxRenderTargetSampleCount(config));
  139. }
  140. bool isConfigRenderable(GrPixelConfig config) const {
  141. return this->maxRenderTargetSampleCount(config) > 0;
  142. }
  143. bool isFormatRenderable(GrColorType ct, const GrBackendFormat& format) const {
  144. return this->maxRenderTargetSampleCount(ct, format) > 0;
  145. }
  146. // Find a sample count greater than or equal to the requested count which is supported for a
  147. // color buffer of the given config or 0 if no such sample count is supported. If the requested
  148. // sample count is 1 then 1 will be returned if non-MSAA rendering is supported, otherwise 0.
  149. // For historical reasons requestedCount==0 is handled identically to requestedCount==1.
  150. virtual int getRenderTargetSampleCount(int requestedCount,
  151. GrColorType, const GrBackendFormat&) const = 0;
  152. virtual int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const = 0;
  153. /**
  154. * Backends may have restrictions on what types of surfaces support GrGpu::writePixels().
  155. * If this returns false then the caller should implement a fallback where a temporary texture
  156. * is created, pixels are written to it, and then that is copied or drawn into the the surface.
  157. */
  158. bool surfaceSupportsWritePixels(const GrSurface*) const;
  159. /**
  160. * Indicates whether surface supports GrGpu::readPixels, must be copied, or cannot be read.
  161. */
  162. enum class SurfaceReadPixelsSupport {
  163. /** GrGpu::readPixels is supported by the surface. */
  164. kSupported,
  165. /**
  166. * GrGpu::readPixels is not supported by this surface but this surface can be drawn
  167. * or copied to a Ganesh-created GrTextureType::kTexture2D and then that surface will be
  168. * readable.
  169. */
  170. kCopyToTexture2D,
  171. /**
  172. * Not supported
  173. */
  174. kUnsupported,
  175. };
  176. /**
  177. * Backends may have restrictions on what types of surfaces support GrGpu::readPixels(). We may
  178. * either be able to read directly from the surface, read from a copy of the surface, or not
  179. * read at all.
  180. */
  181. virtual SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const = 0;
  182. /**
  183. * Given a dst pixel config and a src color type what color type must the caller coax the
  184. * the data into in order to use GrGpu::writePixels().
  185. */
  186. virtual GrColorType supportedWritePixelsColorType(GrPixelConfig config,
  187. GrColorType srcColorType) const {
  188. return GrPixelConfigToColorType(config);
  189. }
  190. struct SupportedRead {
  191. GrSwizzle fSwizzle;
  192. GrColorType fColorType;
  193. };
  194. /**
  195. * Given a src surface's color type and its backend format as well as a color type the caller
  196. * would like read into, this provides a legal color type that the caller may pass to
  197. * GrGpu::readPixels(). The returned color type may differ from the passed dstColorType, in
  198. * which case the caller must convert the read pixel data (see GrConvertPixels). When converting
  199. * to dstColorType the swizzle in the returned struct should be applied. The caller must check
  200. * the returned color type for kUnknown.
  201. */
  202. virtual SupportedRead supportedReadPixelsColorType(GrColorType srcColorType,
  203. const GrBackendFormat& srcFormat,
  204. GrColorType dstColorType) const;
  205. /**
  206. * Do GrGpu::writePixels() and GrGpu::transferPixelsTo() support a src buffer where the row
  207. * bytes is not equal to bpp * w?
  208. */
  209. bool writePixelsRowBytesSupport() const { return fWritePixelsRowBytesSupport; }
  210. /**
  211. * Does GrGpu::readPixels() support a dst buffer where the row bytes is not equal to bpp * w?
  212. */
  213. bool readPixelsRowBytesSupport() const { return fReadPixelsRowBytesSupport; }
  214. /** Are transfer buffers (to textures and from surfaces) supported? */
  215. bool transferBufferSupport() const { return fTransferBufferSupport; }
  216. /**
  217. * Gets the alignment requirement for the buffer offset used with GrGpu::transferPixelsFrom for
  218. * a given GrColorType. To check whether a pixels as GrColorType can be read for a given surface
  219. * see supportedReadPixelsColorType() and surfaceSupportsReadPixels().
  220. *
  221. * @param bufferColorType The color type of the pixel data that will be stored in the transfer
  222. * buffer.
  223. * @return minimum required alignment for the buffer offset or zero if reading to the color type
  224. * is not supported.
  225. */
  226. size_t transferFromOffsetAlignment(GrColorType bufferColorType) const;
  227. bool suppressPrints() const { return fSuppressPrints; }
  228. size_t bufferMapThreshold() const {
  229. SkASSERT(fBufferMapThreshold >= 0);
  230. return fBufferMapThreshold;
  231. }
  232. /** True in environments that will issue errors if memory uploaded to buffers
  233. is not initialized (even if not read by draw calls). */
  234. bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; }
  235. /** For some environments, there is a performance or safety concern to not
  236. initializing textures. For example, with WebGL and Firefox, there is a large
  237. performance hit to not doing it.
  238. */
  239. bool shouldInitializeTextures() const { return fShouldInitializeTextures; }
  240. /**
  241. * When this is true it is required that all textures are initially cleared. However, the
  242. * clearing must be implemented by passing level data to GrGpu::createTexture() rather than
  243. * be implemeted by GrGpu::createTexture().
  244. *
  245. * TODO: Make this take GrBacknedFormat when canClearTextureOnCreation() does as well.
  246. */
  247. bool createTextureMustSpecifyAllLevels() const {
  248. return this->shouldInitializeTextures() && !this->canClearTextureOnCreation();
  249. }
  250. /** Returns true if the given backend supports importing AHardwareBuffers via the
  251. * GrAHardwarebufferImageGenerator. This will only ever be supported on Android devices with API
  252. * level >= 26.
  253. * */
  254. bool supportsAHardwareBufferImages() const { return fSupportsAHardwareBufferImages; }
  255. bool wireframeMode() const { return fWireframeMode; }
  256. /** Supports using GrFence. */
  257. bool fenceSyncSupport() const { return fFenceSyncSupport; }
  258. /** Supports using GrSemaphore. */
  259. bool semaphoreSupport() const { return fSemaphoreSupport; }
  260. bool crossContextTextureSupport() const { return fCrossContextTextureSupport; }
  261. /**
  262. * Returns whether or not we will be able to do a copy given the passed in params
  263. */
  264. bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
  265. const SkIRect& srcRect, const SkIPoint& dstPoint) const;
  266. bool dynamicStateArrayGeometryProcessorTextureSupport() const {
  267. return fDynamicStateArrayGeometryProcessorTextureSupport;
  268. }
  269. // Not all backends support clearing with a scissor test (e.g. Metal), this will always
  270. // return true if performColorClearsAsDraws() returns true.
  271. bool performPartialClearsAsDraws() const {
  272. return fPerformColorClearsAsDraws || fPerformPartialClearsAsDraws;
  273. }
  274. // Many drivers have issues with color clears.
  275. bool performColorClearsAsDraws() const { return fPerformColorClearsAsDraws; }
  276. /// Adreno 4xx devices experience an issue when there are a large number of stencil clip bit
  277. /// clears. The minimal repro steps are not precisely known but drawing a rect with a stencil
  278. /// op instead of using glClear seems to resolve the issue.
  279. bool performStencilClearsAsDraws() const { return fPerformStencilClearsAsDraws; }
  280. // Can we use coverage counting shortcuts to render paths? Coverage counting can cause artifacts
  281. // along shared edges if care isn't taken to ensure both contours wind in the same direction.
  282. bool allowCoverageCounting() const { return fAllowCoverageCounting; }
  283. // Should we disable the CCPR code due to a faulty driver?
  284. bool driverBlacklistCCPR() const { return fDriverBlacklistCCPR; }
  285. bool driverBlacklistMSAACCPR() const { return fDriverBlacklistMSAACCPR; }
  286. /**
  287. * This is used to try to ensure a successful copy a dst in order to perform shader-based
  288. * blending.
  289. *
  290. * fRectsMustMatch will be set to true if the copy operation must ensure that the src and dest
  291. * rects are identical.
  292. *
  293. * fMustCopyWholeSrc will be set to true if copy rect must equal src's bounds.
  294. *
  295. * Caller will detect cases when copy cannot succeed and try copy-as-draw as a fallback.
  296. */
  297. struct DstCopyRestrictions {
  298. GrSurfaceProxy::RectsMustMatch fRectsMustMatch = GrSurfaceProxy::RectsMustMatch::kNo;
  299. bool fMustCopyWholeSrc = false;
  300. };
  301. virtual DstCopyRestrictions getDstCopyRestrictions(const GrRenderTargetProxy* src) const {
  302. return {};
  303. }
  304. bool validateSurfaceDesc(const GrSurfaceDesc&, GrRenderable renderable,
  305. int renderTargetSampleCnt, GrMipMapped) const;
  306. /**
  307. * If the GrBackendRenderTarget can be used with the supplied SkColorType the return will be
  308. * the config that matches the backend format and requested SkColorType. Otherwise, kUnknown is
  309. * returned.
  310. */
  311. virtual GrPixelConfig validateBackendRenderTarget(const GrBackendRenderTarget&,
  312. GrColorType) const = 0;
  313. bool areColorTypeAndFormatCompatible(GrColorType grCT,
  314. const GrBackendFormat& format) const {
  315. if (GrColorType::kUnknown == grCT) {
  316. return false;
  317. }
  318. return this->onAreColorTypeAndFormatCompatible(grCT, format);
  319. }
  320. // TODO: replace validateBackendRenderTarget with calls to getConfigFromBackendFormat?
  321. // TODO: it seems like we could pass the full SkImageInfo and validate its colorSpace too
  322. // Returns kUnknown if a valid config could not be determined.
  323. GrPixelConfig getConfigFromBackendFormat(const GrBackendFormat& format,
  324. GrColorType grCT) const {
  325. if (GrColorType::kUnknown == grCT) {
  326. return kUnknown_GrPixelConfig;
  327. }
  328. return this->onGetConfigFromBackendFormat(format, grCT);
  329. }
  330. /**
  331. * Special method only for YUVA images. Returns a config that matches the backend format or
  332. * kUnknown if a config could not be determined.
  333. */
  334. virtual GrPixelConfig getYUVAConfigFromBackendFormat(const GrBackendFormat&) const = 0;
  335. virtual GrColorType getYUVAColorTypeFromBackendFormat(const GrBackendFormat&) const = 0;
  336. /** These are used when creating a new texture internally. */
  337. virtual GrBackendFormat getBackendFormatFromColorType(GrColorType ct) const = 0;
  338. virtual GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const = 0;
  339. /**
  340. * Used by implementation of shouldInitializeTextures(). Indicates whether GrGpu implements the
  341. * clear in GrGpu::createTexture() or if false then the caller must provide cleared MIP level
  342. * data or GrGpu::createTexture() will fail.
  343. *
  344. * TODO: Make this take a GrBackendFormat so that GL can make this faster for cases
  345. * when the format is renderable and glTexClearImage is not available. Doing this
  346. * is overly complicated until the GrPixelConfig/format mess is straightened out..
  347. */
  348. virtual bool canClearTextureOnCreation() const = 0;
  349. /**
  350. * The CLAMP_TO_BORDER wrap mode for texture coordinates was added to desktop GL in 1.3, and
  351. * GLES 3.2, but is also available in extensions. Vulkan and Metal always have support.
  352. */
  353. bool clampToBorderSupport() const { return fClampToBorderSupport; }
  354. /**
  355. * Returns the GrSwizzle to use when sampling from a texture with the passed in GrBackendFormat
  356. * and GrColorType.
  357. */
  358. virtual GrSwizzle getTextureSwizzle(const GrBackendFormat&, GrColorType) const = 0;
  359. /**
  360. * Returns the GrSwizzle to use when outputting to a render target with the passed in
  361. * GrBackendFormat and GrColorType.
  362. */
  363. virtual GrSwizzle getOutputSwizzle(const GrBackendFormat&, GrColorType) const = 0;
  364. const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; }
  365. /**
  366. * Given a possibly generic GrPixelConfig and a backend format return a specific
  367. * GrPixelConfig.
  368. */
  369. GrPixelConfig makeConfigSpecific(GrPixelConfig config, const GrBackendFormat& format) const {
  370. auto ct = GrPixelConfigToColorType(config);
  371. auto result = this->getConfigFromBackendFormat(format, ct);
  372. SkASSERT(config == result || AreConfigsCompatible(config, result));
  373. return result;
  374. }
  375. #ifdef SK_DEBUG
  376. // This is just a debugging entry point until we're weaned off of GrPixelConfig. It
  377. // should be used to verify that the pixel config from user-level code (the genericConfig)
  378. // is compatible with a pixel config we've computed from scratch (the specificConfig).
  379. static bool AreConfigsCompatible(GrPixelConfig genericConfig, GrPixelConfig specificConfig);
  380. #endif
  381. protected:
  382. /** Subclasses must call this at the end of their constructors in order to apply caps
  383. overrides requested by the client. Note that overrides will only reduce the caps never
  384. expand them. */
  385. void applyOptionsOverrides(const GrContextOptions& options);
  386. sk_sp<GrShaderCaps> fShaderCaps;
  387. bool fNPOTTextureTileSupport : 1;
  388. bool fMipMapSupport : 1;
  389. bool fSRGBSupport : 1;
  390. bool fSRGBWriteControl : 1;
  391. bool fReuseScratchTextures : 1;
  392. bool fReuseScratchBuffers : 1;
  393. bool fGpuTracingSupport : 1;
  394. bool fOversizedStencilSupport : 1;
  395. bool fTextureBarrierSupport : 1;
  396. bool fSampleLocationsSupport : 1;
  397. bool fMultisampleDisableSupport : 1;
  398. bool fInstanceAttribSupport : 1;
  399. bool fMixedSamplesSupport : 1;
  400. bool fUsePrimitiveRestart : 1;
  401. bool fPreferClientSideDynamicBuffers : 1;
  402. bool fPreferFullscreenClears : 1;
  403. bool fMustClearUploadedBufferData : 1;
  404. bool fShouldInitializeTextures : 1;
  405. bool fSupportsAHardwareBufferImages : 1;
  406. bool fHalfFloatVertexAttributeSupport : 1;
  407. bool fClampToBorderSupport : 1;
  408. bool fPerformPartialClearsAsDraws : 1;
  409. bool fPerformColorClearsAsDraws : 1;
  410. bool fPerformStencilClearsAsDraws : 1;
  411. bool fAllowCoverageCounting : 1;
  412. bool fTransferBufferSupport : 1;
  413. bool fWritePixelsRowBytesSupport : 1;
  414. bool fReadPixelsRowBytesSupport : 1;
  415. // Driver workaround
  416. bool fDriverBlacklistCCPR : 1;
  417. bool fDriverBlacklistMSAACCPR : 1;
  418. bool fAvoidStencilBuffers : 1;
  419. bool fAvoidWritePixelsFastPath : 1;
  420. // ANGLE performance workaround
  421. bool fPreferVRAMUseOverFlushes : 1;
  422. // On some platforms it's better to make more triangles than to use the sample mask (MSAA only).
  423. bool fPreferTrianglesOverSampleMask : 1;
  424. bool fFenceSyncSupport : 1;
  425. bool fSemaphoreSupport : 1;
  426. // Requires fence sync support in GL.
  427. bool fCrossContextTextureSupport : 1;
  428. // Not (yet) implemented in VK backend.
  429. bool fDynamicStateArrayGeometryProcessorTextureSupport : 1;
  430. BlendEquationSupport fBlendEquationSupport;
  431. uint32_t fAdvBlendEqBlacklist;
  432. GR_STATIC_ASSERT(kLast_GrBlendEquation < 32);
  433. uint32_t fMapBufferFlags;
  434. int fBufferMapThreshold;
  435. int fMaxRenderTargetSize;
  436. int fMaxPreferredRenderTargetSize;
  437. int fMaxVertexAttributes;
  438. int fMaxTextureSize;
  439. int fMaxTileSize;
  440. int fMaxWindowRectangles;
  441. int fInternalMultisampleCount;
  442. GrDriverBugWorkarounds fDriverBugWorkarounds;
  443. private:
  444. virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
  445. virtual void onDumpJSON(SkJSONWriter*) const {}
  446. virtual bool onSurfaceSupportsWritePixels(const GrSurface*) const = 0;
  447. virtual bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
  448. const SkIRect& srcRect, const SkIPoint& dstPoint) const = 0;
  449. virtual size_t onTransferFromOffsetAlignment(GrColorType bufferColorType) const = 0;
  450. // Backends should implement this if they have any extra requirements for use of window
  451. // rectangles for a specific GrBackendRenderTarget outside of basic support.
  452. virtual bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const {
  453. return true;
  454. }
  455. virtual GrPixelConfig onGetConfigFromBackendFormat(const GrBackendFormat& format,
  456. GrColorType ct) const = 0;
  457. virtual bool onAreColorTypeAndFormatCompatible(GrColorType, const GrBackendFormat&) const = 0;
  458. bool fSuppressPrints : 1;
  459. bool fWireframeMode : 1;
  460. typedef SkRefCnt INHERITED;
  461. };
  462. #endif