bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
| 8 | #include "GrCaps.h" |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 9 | #include "GrBackendSurface.h" |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 10 | #include "GrContextOptions.h" |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 11 | #include "GrSurface.h" |
| 12 | #include "GrSurfaceProxy.h" |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 13 | #include "GrTypesPriv.h" |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 14 | #include "GrWindowRectangles.h" |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 15 | #include "SkJSONWriter.h" |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 16 | |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 17 | GrCaps::GrCaps(const GrContextOptions& options) { |
| 18 | fMipMapSupport = false; |
| 19 | fNPOTTextureTileSupport = false; |
brianosman | a635936 | 2016-03-21 06:55:37 -0700 | [diff] [blame] | 20 | fSRGBSupport = false; |
brianosman | 35b784d | 2016-05-05 11:52:53 -0700 | [diff] [blame] | 21 | fSRGBWriteControl = false; |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 22 | fDiscardRenderTargetSupport = false; |
| 23 | fReuseScratchTextures = true; |
robertphillips | 1b8e1b5 | 2015-06-24 06:54:10 -0700 | [diff] [blame] | 24 | fReuseScratchBuffers = true; |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 25 | fGpuTracingSupport = false; |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 26 | fOversizedStencilSupport = false; |
| 27 | fTextureBarrierSupport = false; |
Robert Phillips | 7f86192 | 2018-01-30 13:13:42 +0000 | [diff] [blame] | 28 | fSampleLocationsSupport = false; |
csmartdalton | 2b5f2cb | 2016-06-10 14:06:32 -0700 | [diff] [blame] | 29 | fMultisampleDisableSupport = false; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 30 | fInstanceAttribSupport = false; |
egdaniel | eed519e | 2016-01-15 11:36:18 -0800 | [diff] [blame] | 31 | fUsesMixedSamples = false; |
Chris Dalton | 27059d3 | 2018-01-23 14:06:50 -0700 | [diff] [blame] | 32 | fUsePrimitiveRestart = false; |
csmartdalton | 485a120 | 2016-07-13 10:16:32 -0700 | [diff] [blame] | 33 | fPreferClientSideDynamicBuffers = false; |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 34 | fPreferFullscreenClears = false; |
bsalomon | 7dea7b7 | 2015-08-19 08:26:51 -0700 | [diff] [blame] | 35 | fMustClearUploadedBufferData = false; |
Greg Daniel | b2acf0a | 2018-09-12 09:17:11 -0400 | [diff] [blame] | 36 | fSupportsAHardwareBufferImages = false; |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 37 | fFenceSyncSupport = false; |
Brian Osman | 2c2bc11 | 2017-02-28 10:02:49 -0500 | [diff] [blame] | 38 | fCrossContextTextureSupport = false; |
Brian Osman | 499bf1a | 2018-09-17 11:32:42 -0400 | [diff] [blame] | 39 | fHalfFloatVertexAttributeSupport = false; |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 40 | fDynamicStateArrayGeometryProcessorTextureSupport = false; |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 41 | |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 42 | fBlendEquationSupport = kBasic_BlendEquationSupport; |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 43 | fAdvBlendEqBlacklist = 0; |
| 44 | |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 45 | fMapBufferFlags = kNone_MapFlags; |
| 46 | |
bsalomon | 7dbd45d | 2016-03-23 10:40:53 -0700 | [diff] [blame] | 47 | fMaxVertexAttributes = 0; |
egdaniel | ff1d547 | 2015-09-10 08:37:20 -0700 | [diff] [blame] | 48 | fMaxRenderTargetSize = 1; |
Chris Dalton | 2612bae | 2018-02-22 13:41:37 -0700 | [diff] [blame] | 49 | fMaxPreferredRenderTargetSize = 1; |
egdaniel | ff1d547 | 2015-09-10 08:37:20 -0700 | [diff] [blame] | 50 | fMaxTextureSize = 1; |
cdalton | af8bc7d | 2016-02-05 09:35:20 -0800 | [diff] [blame] | 51 | fMaxRasterSamples = 0; |
csmartdalton | 9bc1187 | 2016-08-09 12:42:47 -0700 | [diff] [blame] | 52 | fMaxWindowRectangles = 0; |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 53 | |
Chris Dalton | 584a79a | 2017-11-15 13:14:01 -0700 | [diff] [blame] | 54 | // An default count of 4 was chosen because of the common pattern in Blink of: |
| 55 | // isect RR |
| 56 | // diff RR |
| 57 | // isect convex_poly |
| 58 | // isect convex_poly |
| 59 | // when drawing rounded div borders. |
| 60 | fMaxClipAnalyticFPs = 4; |
| 61 | |
robertphillips | caef345 | 2015-11-11 13:18:11 -0800 | [diff] [blame] | 62 | fSuppressPrints = options.fSuppressPrints; |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame] | 63 | #if GR_TEST_UTILS |
Jim Van Verth | fbdc080 | 2017-05-02 16:15:53 -0400 | [diff] [blame] | 64 | fWireframeMode = options.fWireframeMode; |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame] | 65 | #else |
| 66 | fWireframeMode = false; |
| 67 | #endif |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 68 | fBufferMapThreshold = options.fBufferMapThreshold; |
Chris Dalton | e4679fa | 2017-09-29 13:58:26 -0600 | [diff] [blame] | 69 | fBlacklistCoverageCounting = false; |
Eric Karl | 5c77975 | 2017-05-08 12:02:07 -0700 | [diff] [blame] | 70 | fAvoidStencilBuffers = false; |
Greg Daniel | 4374e96 | 2018-09-28 15:09:47 -0400 | [diff] [blame] | 71 | fAvoidWritePixelsFastPath = false; |
robertphillips | 6392668 | 2015-08-20 09:39:02 -0700 | [diff] [blame] | 72 | |
| 73 | fPreferVRAMUseOverFlushes = true; |
Adrienne Walker | ab7181d | 2018-05-14 14:02:03 -0700 | [diff] [blame] | 74 | |
Michael Ludwig | f23a152 | 2018-12-10 11:36:13 -0500 | [diff] [blame] | 75 | // Default to true, allow older versions of OpenGL to disable explicitly |
| 76 | fClampToBorderSupport = true; |
| 77 | |
Adrienne Walker | ab7181d | 2018-05-14 14:02:03 -0700 | [diff] [blame] | 78 | fDriverBugWorkarounds = options.fDriverBugWorkarounds; |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 79 | } |
| 80 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 81 | void GrCaps::applyOptionsOverrides(const GrContextOptions& options) { |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 82 | this->onApplyOptionsOverrides(options); |
Brian Salomon | 01b476a | 2018-01-23 11:06:41 -0500 | [diff] [blame] | 83 | if (options.fDisableDriverCorrectnessWorkarounds) { |
Brian Salomon | e7393ab | 2018-02-13 09:05:54 -0500 | [diff] [blame] | 84 | // We always blacklist coverage counting on Vulkan currently. TODO: Either stop doing that |
| 85 | // or disambiguate blacklisting from incomplete implementation. |
| 86 | // SkASSERT(!fBlacklistCoverageCounting); |
Brian Salomon | 01b476a | 2018-01-23 11:06:41 -0500 | [diff] [blame] | 87 | SkASSERT(!fAvoidStencilBuffers); |
| 88 | SkASSERT(!fAdvBlendEqBlacklist); |
| 89 | } |
| 90 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 91 | fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride); |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame] | 92 | fMaxTileSize = fMaxTextureSize; |
| 93 | #if GR_TEST_UTILS |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 94 | // If the max tile override is zero, it means we should use the max texture size. |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame] | 95 | if (options.fMaxTileSizeOverride && options.fMaxTileSizeOverride < fMaxTextureSize) { |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 96 | fMaxTileSize = options.fMaxTileSizeOverride; |
| 97 | } |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 98 | if (options.fSuppressGeometryShaders) { |
| 99 | fShaderCaps->fGeometryShaderSupport = false; |
| 100 | } |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame] | 101 | #endif |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 102 | if (fMaxWindowRectangles > GrWindowRectangles::kMaxWindows) { |
csmartdalton | 7535f41 | 2016-08-23 06:51:00 -0700 | [diff] [blame] | 103 | SkDebugf("WARNING: capping window rectangles at %i. HW advertises support for %i.\n", |
| 104 | GrWindowRectangles::kMaxWindows, fMaxWindowRectangles); |
csmartdalton | 28341fa | 2016-08-17 10:00:21 -0700 | [diff] [blame] | 105 | fMaxWindowRectangles = GrWindowRectangles::kMaxWindows; |
| 106 | } |
Eric Karl | 5c77975 | 2017-05-08 12:02:07 -0700 | [diff] [blame] | 107 | fAvoidStencilBuffers = options.fAvoidStencilBuffers; |
Adrienne Walker | ab7181d | 2018-05-14 14:02:03 -0700 | [diff] [blame] | 108 | |
| 109 | fDriverBugWorkarounds.applyOverrides(options.fDriverBugWorkarounds); |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Kevin Lubick | f4def34 | 2018-10-04 12:52:50 -0400 | [diff] [blame] | 112 | |
| 113 | #ifdef SK_ENABLE_DUMP_GPU |
| 114 | static const char* pixel_config_name(GrPixelConfig config) { |
| 115 | switch (config) { |
| 116 | case kUnknown_GrPixelConfig: return "Unknown"; |
| 117 | case kAlpha_8_GrPixelConfig: return "Alpha8"; |
| 118 | case kAlpha_8_as_Alpha_GrPixelConfig: return "Alpha8_asAlpha"; |
| 119 | case kAlpha_8_as_Red_GrPixelConfig: return "Alpha8_asRed"; |
| 120 | case kGray_8_GrPixelConfig: return "Gray8"; |
| 121 | case kGray_8_as_Lum_GrPixelConfig: return "Gray8_asLum"; |
| 122 | case kGray_8_as_Red_GrPixelConfig: return "Gray8_asRed"; |
| 123 | case kRGB_565_GrPixelConfig: return "RGB565"; |
| 124 | case kRGBA_4444_GrPixelConfig: return "RGBA444"; |
| 125 | case kRGBA_8888_GrPixelConfig: return "RGBA8888"; |
| 126 | case kRGB_888_GrPixelConfig: return "RGB888"; |
Jim Van Verth | 69e5785 | 2018-12-05 13:38:59 -0500 | [diff] [blame] | 127 | case kRG_88_GrPixelConfig: return "RG88"; |
Kevin Lubick | f4def34 | 2018-10-04 12:52:50 -0400 | [diff] [blame] | 128 | case kBGRA_8888_GrPixelConfig: return "BGRA8888"; |
| 129 | case kSRGBA_8888_GrPixelConfig: return "SRGBA8888"; |
| 130 | case kSBGRA_8888_GrPixelConfig: return "SBGRA8888"; |
| 131 | case kRGBA_1010102_GrPixelConfig: return "RGBA1010102"; |
| 132 | case kRGBA_float_GrPixelConfig: return "RGBAFloat"; |
| 133 | case kRG_float_GrPixelConfig: return "RGFloat"; |
| 134 | case kAlpha_half_GrPixelConfig: return "AlphaHalf"; |
| 135 | case kAlpha_half_as_Red_GrPixelConfig: return "AlphaHalf_asRed"; |
| 136 | case kRGBA_half_GrPixelConfig: return "RGBAHalf"; |
| 137 | } |
| 138 | SK_ABORT("Invalid pixel config"); |
| 139 | return "<invalid>"; |
| 140 | } |
| 141 | |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 142 | static SkString map_flags_to_string(uint32_t flags) { |
| 143 | SkString str; |
| 144 | if (GrCaps::kNone_MapFlags == flags) { |
| 145 | str = "none"; |
| 146 | } else { |
| 147 | SkASSERT(GrCaps::kCanMap_MapFlag & flags); |
| 148 | SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag); |
| 149 | str = "can_map"; |
| 150 | |
| 151 | if (GrCaps::kSubset_MapFlag & flags) { |
| 152 | str.append(" partial"); |
| 153 | } else { |
| 154 | str.append(" full"); |
| 155 | } |
| 156 | SkDEBUGCODE(flags &= ~GrCaps::kSubset_MapFlag); |
| 157 | } |
| 158 | SkASSERT(0 == flags); // Make sure we handled all the flags. |
| 159 | return str; |
| 160 | } |
| 161 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 162 | void GrCaps::dumpJSON(SkJSONWriter* writer) const { |
| 163 | writer->beginObject(); |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 164 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 165 | writer->appendBool("MIP Map Support", fMipMapSupport); |
| 166 | writer->appendBool("NPOT Texture Tile Support", fNPOTTextureTileSupport); |
| 167 | writer->appendBool("sRGB Support", fSRGBSupport); |
| 168 | writer->appendBool("sRGB Write Control", fSRGBWriteControl); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 169 | writer->appendBool("Discard Render Target Support", fDiscardRenderTargetSupport); |
| 170 | writer->appendBool("Reuse Scratch Textures", fReuseScratchTextures); |
| 171 | writer->appendBool("Reuse Scratch Buffers", fReuseScratchBuffers); |
| 172 | writer->appendBool("Gpu Tracing Support", fGpuTracingSupport); |
| 173 | writer->appendBool("Oversized Stencil Support", fOversizedStencilSupport); |
| 174 | writer->appendBool("Texture Barrier Support", fTextureBarrierSupport); |
Robert Phillips | 7f86192 | 2018-01-30 13:13:42 +0000 | [diff] [blame] | 175 | writer->appendBool("Sample Locations Support", fSampleLocationsSupport); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 176 | writer->appendBool("Multisample disable support", fMultisampleDisableSupport); |
| 177 | writer->appendBool("Instance Attrib Support", fInstanceAttribSupport); |
| 178 | writer->appendBool("Uses Mixed Samples", fUsesMixedSamples); |
Chris Dalton | 27059d3 | 2018-01-23 14:06:50 -0700 | [diff] [blame] | 179 | writer->appendBool("Use primitive restart", fUsePrimitiveRestart); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 180 | writer->appendBool("Prefer client-side dynamic buffers", fPreferClientSideDynamicBuffers); |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 181 | writer->appendBool("Prefer fullscreen clears", fPreferFullscreenClears); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 182 | writer->appendBool("Must clear buffer memory", fMustClearUploadedBufferData); |
Greg Daniel | b2acf0a | 2018-09-12 09:17:11 -0400 | [diff] [blame] | 183 | writer->appendBool("Supports importing AHardwareBuffers", fSupportsAHardwareBufferImages); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 184 | writer->appendBool("Fence sync support", fFenceSyncSupport); |
| 185 | writer->appendBool("Cross context texture support", fCrossContextTextureSupport); |
Brian Osman | 499bf1a | 2018-09-17 11:32:42 -0400 | [diff] [blame] | 186 | writer->appendBool("Half float vertex attribute support", fHalfFloatVertexAttributeSupport); |
Brian Salomon | f723264 | 2018-09-19 08:58:08 -0400 | [diff] [blame] | 187 | writer->appendBool("Specify GeometryProcessor textures as a dynamic state array", |
| 188 | fDynamicStateArrayGeometryProcessorTextureSupport); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 189 | |
Chris Dalton | cc604e5 | 2017-10-06 16:27:32 -0600 | [diff] [blame] | 190 | writer->appendBool("Blacklist Coverage Counting Path Renderer [workaround]", |
| 191 | fBlacklistCoverageCounting); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 192 | writer->appendBool("Prefer VRAM Use over flushes [workaround]", fPreferVRAMUseOverFlushes); |
Robert Phillips | f2ec024 | 2018-03-01 16:51:25 -0500 | [diff] [blame] | 193 | writer->appendBool("Avoid stencil buffers [workaround]", fAvoidStencilBuffers); |
robertphillips | 6392668 | 2015-08-20 09:39:02 -0700 | [diff] [blame] | 194 | |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 195 | if (this->advancedBlendEquationSupport()) { |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 196 | writer->appendHexU32("Advanced Blend Equation Blacklist", fAdvBlendEqBlacklist); |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 197 | } |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 198 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 199 | writer->appendS32("Max Vertex Attributes", fMaxVertexAttributes); |
| 200 | writer->appendS32("Max Texture Size", fMaxTextureSize); |
| 201 | writer->appendS32("Max Render Target Size", fMaxRenderTargetSize); |
Chris Dalton | 2612bae | 2018-02-22 13:41:37 -0700 | [diff] [blame] | 202 | writer->appendS32("Max Preferred Render Target Size", fMaxPreferredRenderTargetSize); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 203 | writer->appendS32("Max Raster Samples", fMaxRasterSamples); |
| 204 | writer->appendS32("Max Window Rectangles", fMaxWindowRectangles); |
Chris Dalton | 584a79a | 2017-11-15 13:14:01 -0700 | [diff] [blame] | 205 | writer->appendS32("Max Clip Analytic Fragment Processors", fMaxClipAnalyticFPs); |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 206 | |
| 207 | static const char* kBlendEquationSupportNames[] = { |
| 208 | "Basic", |
| 209 | "Advanced", |
| 210 | "Advanced Coherent", |
| 211 | }; |
| 212 | GR_STATIC_ASSERT(0 == kBasic_BlendEquationSupport); |
| 213 | GR_STATIC_ASSERT(1 == kAdvanced_BlendEquationSupport); |
| 214 | GR_STATIC_ASSERT(2 == kAdvancedCoherent_BlendEquationSupport); |
| 215 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kBlendEquationSupportNames) == kLast_BlendEquationSupport + 1); |
| 216 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 217 | writer->appendString("Blend Equation Support", |
| 218 | kBlendEquationSupportNames[fBlendEquationSupport]); |
| 219 | writer->appendString("Map Buffer Support", map_flags_to_string(fMapBufferFlags).c_str()); |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 220 | |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame] | 221 | SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig)); |
Brian Osman | 0f450ac | 2017-08-09 20:45:52 +0000 | [diff] [blame] | 222 | SkASSERT(!this->isConfigTexturable(kUnknown_GrPixelConfig)); |
Brian Osman | 175af0d | 2017-08-09 14:29:36 -0400 | [diff] [blame] | 223 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 224 | writer->beginArray("configs"); |
| 225 | |
| 226 | for (size_t i = 1; i < kGrPixelConfigCnt; ++i) { |
Brian Osman | 0f450ac | 2017-08-09 20:45:52 +0000 | [diff] [blame] | 227 | GrPixelConfig config = static_cast<GrPixelConfig>(i); |
Brian Osman | 8048822 | 2017-08-10 13:29:30 -0400 | [diff] [blame] | 228 | writer->beginObject(nullptr, false); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 229 | writer->appendString("name", pixel_config_name(config)); |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame] | 230 | writer->appendS32("max sample count", this->maxRenderTargetSampleCount(config)); |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 231 | writer->appendBool("texturable", this->isConfigTexturable(config)); |
| 232 | writer->endObject(); |
Brian Osman | 0f450ac | 2017-08-09 20:45:52 +0000 | [diff] [blame] | 233 | } |
Brian Osman | 175af0d | 2017-08-09 14:29:36 -0400 | [diff] [blame] | 234 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 235 | writer->endArray(); |
| 236 | |
| 237 | this->onDumpJSON(writer); |
| 238 | |
| 239 | writer->appendName("shaderCaps"); |
| 240 | this->shaderCaps()->dumpJSON(writer); |
| 241 | |
| 242 | writer->endObject(); |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 243 | } |
Kevin Lubick | f4def34 | 2018-10-04 12:52:50 -0400 | [diff] [blame] | 244 | #else |
| 245 | void GrCaps::dumpJSON(SkJSONWriter* writer) const { } |
| 246 | #endif |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 247 | |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 248 | bool GrCaps::surfaceSupportsWritePixels(const GrSurface* surface) const { |
| 249 | return surface->readOnly() ? false : this->onSurfaceSupportsWritePixels(surface); |
| 250 | } |
| 251 | |
| 252 | bool GrCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src, |
| 253 | const SkIRect& srcRect, const SkIPoint& dstPoint) const { |
| 254 | return dst->readOnly() ? false : this->onCanCopySurface(dst, src, srcRect, dstPoint); |
| 255 | } |
| 256 | |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame] | 257 | bool GrCaps::validateSurfaceDesc(const GrSurfaceDesc& desc, GrMipMapped mipped) const { |
| 258 | if (!this->isConfigTexturable(desc.fConfig)) { |
| 259 | return false; |
| 260 | } |
| 261 | |
Brian Salomon | 5711133 | 2018-02-05 15:55:54 -0500 | [diff] [blame] | 262 | if (GrMipMapped::kYes == mipped && !this->mipMapSupport()) { |
| 263 | return false; |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (desc.fWidth < 1 || desc.fHeight < 1) { |
| 267 | return false; |
| 268 | } |
| 269 | |
| 270 | if (SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag)) { |
| 271 | if (0 == this->getRenderTargetSampleCount(desc.fSampleCnt, desc.fConfig)) { |
| 272 | return false; |
| 273 | } |
| 274 | int maxRTSize = this->maxRenderTargetSize(); |
| 275 | if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
| 276 | return false; |
| 277 | } |
| 278 | } else { |
| 279 | // We currently do not support multisampled textures |
| 280 | if (desc.fSampleCnt > 1) { |
| 281 | return false; |
| 282 | } |
| 283 | int maxSize = this->maxTextureSize(); |
| 284 | if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 285 | return false; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | return true; |
| 290 | } |
Timothy Liang | 036fdfe | 2018-06-28 15:50:36 -0400 | [diff] [blame] | 291 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 292 | GrBackendFormat GrCaps::getBackendFormatFromColorType(SkColorType ct) const { |
| 293 | return this->getBackendFormatFromGrColorType(SkColorTypeToGrColorType(ct), GrSRGBEncoded::kNo); |
| 294 | } |