OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 fBaseInstanceSupport = false; | 44 fBaseInstanceSupport = false; |
45 fIsCoreProfile = false; | 45 fIsCoreProfile = false; |
46 fBindFragDataLocationSupport = false; | 46 fBindFragDataLocationSupport = false; |
47 fRectangleTextureSupport = false; | 47 fRectangleTextureSupport = false; |
48 fTextureSwizzleSupport = false; | 48 fTextureSwizzleSupport = false; |
49 fRGBA8888PixelsOpsAreSlow = false; | 49 fRGBA8888PixelsOpsAreSlow = false; |
50 fPartialFBOReadIsSlow = false; | 50 fPartialFBOReadIsSlow = false; |
51 fMipMapLevelAndLodControlSupport = false; | 51 fMipMapLevelAndLodControlSupport = false; |
52 fRGBAToBGRAReadbackConversionsAreSlow = false; | 52 fRGBAToBGRAReadbackConversionsAreSlow = false; |
53 fDoManualMipmapping = false; | 53 fDoManualMipmapping = false; |
| 54 fSRGBDecodeDisableSupport = false; |
54 | 55 |
55 fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; | 56 fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; |
56 | 57 |
57 fShaderCaps.reset(new GrShaderCaps(contextOptions)); | 58 fShaderCaps.reset(new GrShaderCaps(contextOptions)); |
58 | 59 |
59 this->init(contextOptions, ctxInfo, glInterface); | 60 this->init(contextOptions, ctxInfo, glInterface); |
60 } | 61 } |
61 | 62 |
62 void GrGLCaps::init(const GrContextOptions& contextOptions, | 63 void GrGLCaps::init(const GrContextOptions& contextOptions, |
63 const GrGLContextInfo& ctxInfo, | 64 const GrGLContextInfo& ctxInfo, |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 // glGenerateMipmap. Our implementation requires mip-level sampling control.
Additionally, | 601 // glGenerateMipmap. Our implementation requires mip-level sampling control.
Additionally, |
601 // it can be much slower (especially on mobile GPUs), so we opt-in only when
necessary: | 602 // it can be much slower (especially on mobile GPUs), so we opt-in only when
necessary: |
602 if (fMipMapLevelAndLodControlSupport && | 603 if (fMipMapLevelAndLodControlSupport && |
603 (contextOptions.fDoManualMipmapping || | 604 (contextOptions.fDoManualMipmapping || |
604 (kIntel_GrGLVendor == ctxInfo.vendor()) || | 605 (kIntel_GrGLVendor == ctxInfo.vendor()) || |
605 (kNVIDIA_GrGLDriver == ctxInfo.driver() && isMAC) || | 606 (kNVIDIA_GrGLDriver == ctxInfo.driver() && isMAC) || |
606 (kATI_GrGLVendor == ctxInfo.vendor()))) { | 607 (kATI_GrGLVendor == ctxInfo.vendor()))) { |
607 fDoManualMipmapping = true; | 608 fDoManualMipmapping = true; |
608 } | 609 } |
609 | 610 |
| 611 fSRGBDecodeDisableSupport = ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode
"); |
| 612 |
610 // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES com
patibility have | 613 // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES com
patibility have |
611 // already been detected. | 614 // already been detected. |
612 this->initConfigTable(ctxInfo, gli, shaderCaps); | 615 this->initConfigTable(contextOptions, ctxInfo, gli, shaderCaps); |
613 | 616 |
614 this->applyOptionsOverrides(contextOptions); | 617 this->applyOptionsOverrides(contextOptions); |
615 shaderCaps->applyOptionsOverrides(contextOptions); | 618 shaderCaps->applyOptionsOverrides(contextOptions); |
616 } | 619 } |
617 | 620 |
618 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, | 621 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, |
619 bool isCoreProfile) { | 622 bool isCoreProfile) { |
620 switch (generation) { | 623 switch (generation) { |
621 case k110_GrGLSLGeneration: | 624 case k110_GrGLSLGeneration: |
622 if (kGLES_GrGLStandard == standard) { | 625 if (kGLES_GrGLStandard == standard) { |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) { | 1385 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) { |
1383 if (this->textureRedSupport()) { | 1386 if (this->textureRedSupport()) { |
1384 SkASSERT(GR_GL_RED == *externalFormat); | 1387 SkASSERT(GR_GL_RED == *externalFormat); |
1385 *externalFormat = GR_GL_ALPHA; | 1388 *externalFormat = GR_GL_ALPHA; |
1386 } | 1389 } |
1387 } | 1390 } |
1388 | 1391 |
1389 return true; | 1392 return true; |
1390 } | 1393 } |
1391 | 1394 |
1392 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, | 1395 void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, |
| 1396 const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, |
1393 GrShaderCaps* shaderCaps) { | 1397 GrShaderCaps* shaderCaps) { |
1394 /* | 1398 /* |
1395 Comments on renderability of configs on various GL versions. | 1399 Comments on renderability of configs on various GL versions. |
1396 OpenGL < 3.0: | 1400 OpenGL < 3.0: |
1397 no built in support for render targets. | 1401 no built in support for render targets. |
1398 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal | 1402 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal |
1399 format RGB, RGBA and NV float formats we don't use. | 1403 format RGB, RGBA and NV float formats we don't use. |
1400 This is the following: | 1404 This is the following: |
1401 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R
GB5_A1, RGBA8 | 1405 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R
GB5_A1, RGBA8 |
1402 RGB10_A2, RGBA12,RGBA16 | 1406 RGB10_A2, RGBA12,RGBA16 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || | 1572 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
1569 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { | 1573 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
1570 fSRGBSupport = true; | 1574 fSRGBSupport = true; |
1571 } | 1575 } |
1572 } | 1576 } |
1573 // All the above srgb extensions support toggling srgb writes | 1577 // All the above srgb extensions support toggling srgb writes |
1574 if (fSRGBSupport) { | 1578 if (fSRGBSupport) { |
1575 fSRGBWriteControl = true; | 1579 fSRGBWriteControl = true; |
1576 } | 1580 } |
1577 } else { | 1581 } else { |
1578 // See https://bug.skia.org/4148 for PowerVR issue. | 1582 fSRGBSupport = ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtensi
on("GL_EXT_sRGB"); |
1579 fSRGBSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && | 1583 #if defined(SK_CPU_X86) |
1580 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT
_sRGB")); | 1584 if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) { |
| 1585 // NexusPlayer has strange bugs with sRGB (skbug.com/4148). This is
a targeted fix to |
| 1586 // blacklist that device (and any others that might be sharing the s
ame driver). |
| 1587 fSRGBSupport = false; |
| 1588 } |
| 1589 #endif |
1581 // ES through 3.1 requires EXT_srgb_write_control to support toggling | 1590 // ES through 3.1 requires EXT_srgb_write_control to support toggling |
1582 // sRGB writing for destinations. | 1591 // sRGB writing for destinations. |
1583 // See https://bug.skia.org/5329 for Adreno4xx issue. | 1592 // See https://bug.skia.org/5329 for Adreno4xx issue. |
1584 fSRGBWriteControl = kAdreno4xx_GrGLRenderer != ctxInfo.renderer() && | 1593 fSRGBWriteControl = kAdreno4xx_GrGLRenderer != ctxInfo.renderer() && |
1585 ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); | 1594 ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); |
1586 } | 1595 } |
1587 if (!ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode")) { | 1596 if (contextOptions.fRequireDecodeDisableForSRGB && !fSRGBDecodeDisableSuppor
t) { |
1588 // To support "legacy" L32 mode, we require the ability to turn off sRGB
decode: | 1597 // To support "legacy" L32 mode, we require the ability to turn off sRGB
decode. Clients |
| 1598 // can opt-out of that requirement, if they intend to always do linear b
lending. |
1589 fSRGBSupport = false; | 1599 fSRGBSupport = false; |
1590 } | 1600 } |
| 1601 |
| 1602 // This is very conservative, if we're on a platform where N32 is BGRA, and
using ES, disable |
| 1603 // all sRGB support. Too much code relies on creating surfaces with N32 + sR
GB colorspace, |
| 1604 // and sBGRA is basically impossible to support on any version of ES (with o
ur current code). |
| 1605 // In particular, ES2 doesn't support sBGRA at all, and even in ES3, there i
s no valid pair |
| 1606 // of formats that can be used for TexImage calls to upload BGRA data to sRG
BA (which is what |
| 1607 // we *have* to use as the internal format, because sBGRA doesn't exist). Th
is primarily |
| 1608 // affects Windows. |
| 1609 if (kSkia8888_GrPixelConfig == kBGRA_8888_GrPixelConfig && kGLES_GrGLStandar
d == standard) { |
| 1610 fSRGBSupport = false; |
| 1611 } |
| 1612 |
1591 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; | 1613 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; |
1592 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; | 1614 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; |
1593 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the | 1615 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the |
1594 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. | 1616 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. |
1595 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = | 1617 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = |
1596 GR_GL_RGBA; | 1618 GR_GL_RGBA; |
1597 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1619 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
1598 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; | 1620 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
1599 if (fSRGBSupport) { | 1621 if (fSRGBSupport) { |
1600 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | | 1622 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { | 2097 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { |
2076 if (options.fEnableInstancedRendering) { | 2098 if (options.fEnableInstancedRendering) { |
2077 fInstancedSupport = gr_instanced::GLInstancedRendering::CheckSupport(*th
is); | 2099 fInstancedSupport = gr_instanced::GLInstancedRendering::CheckSupport(*th
is); |
2078 #ifndef SK_BUILD_FOR_MAC | 2100 #ifndef SK_BUILD_FOR_MAC |
2079 // OS X doesn't seem to write correctly to floating point textures when
using | 2101 // OS X doesn't seem to write correctly to floating point textures when
using |
2080 // glDraw*Indirect, regardless of the underlying GPU. | 2102 // glDraw*Indirect, regardless of the underlying GPU. |
2081 fAvoidInstancedDrawsToFPTargets = true; | 2103 fAvoidInstancedDrawsToFPTargets = true; |
2082 #endif | 2104 #endif |
2083 } | 2105 } |
2084 } | 2106 } |
OLD | NEW |