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; | |
55 | 54 |
56 fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; | 55 fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; |
57 | 56 |
58 fShaderCaps.reset(new GrShaderCaps(contextOptions)); | 57 fShaderCaps.reset(new GrShaderCaps(contextOptions)); |
59 | 58 |
60 this->init(contextOptions, ctxInfo, glInterface); | 59 this->init(contextOptions, ctxInfo, glInterface); |
61 } | 60 } |
62 | 61 |
63 void GrGLCaps::init(const GrContextOptions& contextOptions, | 62 void GrGLCaps::init(const GrContextOptions& contextOptions, |
64 const GrGLContextInfo& ctxInfo, | 63 const GrGLContextInfo& ctxInfo, |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 // glGenerateMipmap. Our implementation requires mip-level sampling control.
Additionally, | 600 // glGenerateMipmap. Our implementation requires mip-level sampling control.
Additionally, |
602 // it can be much slower (especially on mobile GPUs), so we opt-in only when
necessary: | 601 // it can be much slower (especially on mobile GPUs), so we opt-in only when
necessary: |
603 if (fMipMapLevelAndLodControlSupport && | 602 if (fMipMapLevelAndLodControlSupport && |
604 (contextOptions.fDoManualMipmapping || | 603 (contextOptions.fDoManualMipmapping || |
605 (kIntel_GrGLVendor == ctxInfo.vendor()) || | 604 (kIntel_GrGLVendor == ctxInfo.vendor()) || |
606 (kNVIDIA_GrGLDriver == ctxInfo.driver() && isMAC) || | 605 (kNVIDIA_GrGLDriver == ctxInfo.driver() && isMAC) || |
607 (kATI_GrGLVendor == ctxInfo.vendor()))) { | 606 (kATI_GrGLVendor == ctxInfo.vendor()))) { |
608 fDoManualMipmapping = true; | 607 fDoManualMipmapping = true; |
609 } | 608 } |
610 | 609 |
611 fSRGBDecodeDisableSupport = ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode
"); | |
612 | |
613 // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES com
patibility have | 610 // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES com
patibility have |
614 // already been detected. | 611 // already been detected. |
615 this->initConfigTable(contextOptions, ctxInfo, gli, shaderCaps); | 612 this->initConfigTable(ctxInfo, gli, shaderCaps); |
616 | 613 |
617 this->applyOptionsOverrides(contextOptions); | 614 this->applyOptionsOverrides(contextOptions); |
618 shaderCaps->applyOptionsOverrides(contextOptions); | 615 shaderCaps->applyOptionsOverrides(contextOptions); |
619 } | 616 } |
620 | 617 |
621 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, | 618 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, |
622 bool isCoreProfile) { | 619 bool isCoreProfile) { |
623 switch (generation) { | 620 switch (generation) { |
624 case k110_GrGLSLGeneration: | 621 case k110_GrGLSLGeneration: |
625 if (kGLES_GrGLStandard == standard) { | 622 if (kGLES_GrGLStandard == standard) { |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) { | 1382 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) { |
1386 if (this->textureRedSupport()) { | 1383 if (this->textureRedSupport()) { |
1387 SkASSERT(GR_GL_RED == *externalFormat); | 1384 SkASSERT(GR_GL_RED == *externalFormat); |
1388 *externalFormat = GR_GL_ALPHA; | 1385 *externalFormat = GR_GL_ALPHA; |
1389 } | 1386 } |
1390 } | 1387 } |
1391 | 1388 |
1392 return true; | 1389 return true; |
1393 } | 1390 } |
1394 | 1391 |
1395 void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, | 1392 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, |
1396 const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, | |
1397 GrShaderCaps* shaderCaps) { | 1393 GrShaderCaps* shaderCaps) { |
1398 /* | 1394 /* |
1399 Comments on renderability of configs on various GL versions. | 1395 Comments on renderability of configs on various GL versions. |
1400 OpenGL < 3.0: | 1396 OpenGL < 3.0: |
1401 no built in support for render targets. | 1397 no built in support for render targets. |
1402 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal | 1398 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal |
1403 format RGB, RGBA and NV float formats we don't use. | 1399 format RGB, RGBA and NV float formats we don't use. |
1404 This is the following: | 1400 This is the following: |
1405 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R
GB5_A1, RGBA8 | 1401 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R
GB5_A1, RGBA8 |
1406 RGB10_A2, RGBA12,RGBA16 | 1402 RGB10_A2, RGBA12,RGBA16 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || | 1568 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
1573 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { | 1569 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
1574 fSRGBSupport = true; | 1570 fSRGBSupport = true; |
1575 } | 1571 } |
1576 } | 1572 } |
1577 // All the above srgb extensions support toggling srgb writes | 1573 // All the above srgb extensions support toggling srgb writes |
1578 if (fSRGBSupport) { | 1574 if (fSRGBSupport) { |
1579 fSRGBWriteControl = true; | 1575 fSRGBWriteControl = true; |
1580 } | 1576 } |
1581 } else { | 1577 } else { |
1582 fSRGBSupport = ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtensi
on("GL_EXT_sRGB"); | 1578 // See https://bug.skia.org/4148 for PowerVR issue. |
1583 #if defined(SK_CPU_X86) | 1579 fSRGBSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && |
1584 if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) { | 1580 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT
_sRGB")); |
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 | |
1590 // ES through 3.1 requires EXT_srgb_write_control to support toggling | 1581 // ES through 3.1 requires EXT_srgb_write_control to support toggling |
1591 // sRGB writing for destinations. | 1582 // sRGB writing for destinations. |
1592 // See https://bug.skia.org/5329 for Adreno4xx issue. | 1583 // See https://bug.skia.org/5329 for Adreno4xx issue. |
1593 fSRGBWriteControl = kAdreno4xx_GrGLRenderer != ctxInfo.renderer() && | 1584 fSRGBWriteControl = kAdreno4xx_GrGLRenderer != ctxInfo.renderer() && |
1594 ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); | 1585 ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); |
1595 } | 1586 } |
1596 if (contextOptions.fRequireDecodeDisableForSRGB && !fSRGBDecodeDisableSuppor
t) { | 1587 if (!ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode")) { |
1597 // To support "legacy" L32 mode, we require the ability to turn off sRGB
decode. Clients | 1588 // To support "legacy" L32 mode, we require the ability to turn off sRGB
decode: |
1598 // can opt-out of that requirement, if they intend to always do linear b
lending. | |
1599 fSRGBSupport = false; | 1589 fSRGBSupport = false; |
1600 } | 1590 } |
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 | |
1613 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; | 1591 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; |
1614 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; | 1592 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; |
1615 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the | 1593 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the |
1616 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. | 1594 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. |
1617 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = | 1595 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = |
1618 GR_GL_RGBA; | 1596 GR_GL_RGBA; |
1619 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1597 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
1620 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; | 1598 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
1621 if (fSRGBSupport) { | 1599 if (fSRGBSupport) { |
1622 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | | 1600 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { | 2075 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { |
2098 if (options.fEnableInstancedRendering) { | 2076 if (options.fEnableInstancedRendering) { |
2099 fInstancedSupport = gr_instanced::GLInstancedRendering::CheckSupport(*th
is); | 2077 fInstancedSupport = gr_instanced::GLInstancedRendering::CheckSupport(*th
is); |
2100 #ifndef SK_BUILD_FOR_MAC | 2078 #ifndef SK_BUILD_FOR_MAC |
2101 // OS X doesn't seem to write correctly to floating point textures when
using | 2079 // OS X doesn't seem to write correctly to floating point textures when
using |
2102 // glDraw*Indirect, regardless of the underlying GPU. | 2080 // glDraw*Indirect, regardless of the underlying GPU. |
2103 fAvoidInstancedDrawsToFPTargets = true; | 2081 fAvoidInstancedDrawsToFPTargets = true; |
2104 #endif | 2082 #endif |
2105 } | 2083 } |
2106 } | 2084 } |
OLD | NEW |