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 #include "GrGLContext.h" | 10 #include "GrGLContext.h" |
11 #include "SkTSearch.h" | 11 #include "SkTSearch.h" |
12 #include "SkTSort.h" | 12 #include "SkTSort.h" |
13 | 13 |
14 GrGLCaps::GrGLCaps() { | 14 GrGLCaps::GrGLCaps() { |
15 this->reset(); | 15 this->reset(); |
16 } | 16 } |
17 | 17 |
18 void GrGLCaps::reset() { | 18 void GrGLCaps::reset() { |
19 INHERITED::reset(); | 19 INHERITED::reset(); |
20 | 20 |
21 fVerifiedColorConfigs.reset(); | 21 fVerifiedColorConfigs.reset(); |
22 fStencilFormats.reset(); | 22 fStencilFormats.reset(); |
23 fStencilVerifiedColorConfigs.reset(); | 23 fStencilVerifiedColorConfigs.reset(); |
24 fMSFBOType = kNone_MSFBOType; | 24 fMSFBOType = kNone_MSFBOType; |
25 fFBFetchType = kNone_FBFetchType; | 25 fFBFetchType = kNone_FBFetchType; |
26 fInvalidateFBType = kNone_InvalidateFBType; | 26 fInvalidateFBType = kNone_InvalidateFBType; |
| 27 fMapBufferType = kNone_MapBufferType; |
27 fMaxFragmentUniformVectors = 0; | 28 fMaxFragmentUniformVectors = 0; |
28 fMaxVertexAttributes = 0; | 29 fMaxVertexAttributes = 0; |
29 fMaxFragmentTextureUnits = 0; | 30 fMaxFragmentTextureUnits = 0; |
30 fMaxFixedFunctionTextureCoords = 0; | 31 fMaxFixedFunctionTextureCoords = 0; |
31 fRGBA8RenderbufferSupport = false; | 32 fRGBA8RenderbufferSupport = false; |
32 fBGRAFormatSupport = false; | 33 fBGRAFormatSupport = false; |
33 fBGRAIsInternalFormat = false; | 34 fBGRAIsInternalFormat = false; |
34 fTextureSwizzleSupport = false; | 35 fTextureSwizzleSupport = false; |
35 fUnpackRowLengthSupport = false; | 36 fUnpackRowLengthSupport = false; |
36 fUnpackFlipYSupport = false; | 37 fUnpackFlipYSupport = false; |
37 fPackRowLengthSupport = false; | 38 fPackRowLengthSupport = false; |
38 fPackFlipYSupport = false; | 39 fPackFlipYSupport = false; |
39 fTextureUsageSupport = false; | 40 fTextureUsageSupport = false; |
40 fTexStorageSupport = false; | 41 fTexStorageSupport = false; |
41 fTextureRedSupport = false; | 42 fTextureRedSupport = false; |
42 fImagingSupport = false; | 43 fImagingSupport = false; |
43 fTwoFormatLimit = false; | 44 fTwoFormatLimit = false; |
44 fFragCoordsConventionSupport = false; | 45 fFragCoordsConventionSupport = false; |
45 fVertexArrayObjectSupport = false; | 46 fVertexArrayObjectSupport = false; |
46 fUseNonVBOVertexAndIndexDynamicData = false; | 47 fUseNonVBOVertexAndIndexDynamicData = false; |
47 fIsCoreProfile = false; | 48 fIsCoreProfile = false; |
48 fFullClearIsFree = false; | 49 fFullClearIsFree = false; |
49 fDropsTileOnZeroDivide = false; | 50 fDropsTileOnZeroDivide = false; |
50 fMapSubSupport = false; | |
51 } | 51 } |
52 | 52 |
53 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { | 53 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { |
54 *this = caps; | 54 *this = caps; |
55 } | 55 } |
56 | 56 |
57 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { | 57 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { |
58 INHERITED::operator=(caps); | 58 INHERITED::operator=(caps); |
59 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; | 59 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
60 fStencilFormats = caps.fStencilFormats; | 60 fStencilFormats = caps.fStencilFormats; |
61 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; | 61 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; |
62 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; | 62 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; |
63 fMaxVertexAttributes = caps.fMaxVertexAttributes; | 63 fMaxVertexAttributes = caps.fMaxVertexAttributes; |
64 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; | 64 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; |
65 fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; | 65 fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; |
66 fMSFBOType = caps.fMSFBOType; | 66 fMSFBOType = caps.fMSFBOType; |
67 fFBFetchType = caps.fFBFetchType; | 67 fFBFetchType = caps.fFBFetchType; |
68 fInvalidateFBType = caps.fInvalidateFBType; | 68 fInvalidateFBType = caps.fInvalidateFBType; |
| 69 fMapBufferType = caps.fMapBufferType; |
69 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; | 70 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; |
70 fBGRAFormatSupport = caps.fBGRAFormatSupport; | 71 fBGRAFormatSupport = caps.fBGRAFormatSupport; |
71 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; | 72 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; |
72 fTextureSwizzleSupport = caps.fTextureSwizzleSupport; | 73 fTextureSwizzleSupport = caps.fTextureSwizzleSupport; |
73 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; | 74 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; |
74 fUnpackFlipYSupport = caps.fUnpackFlipYSupport; | 75 fUnpackFlipYSupport = caps.fUnpackFlipYSupport; |
75 fPackRowLengthSupport = caps.fPackRowLengthSupport; | 76 fPackRowLengthSupport = caps.fPackRowLengthSupport; |
76 fPackFlipYSupport = caps.fPackFlipYSupport; | 77 fPackFlipYSupport = caps.fPackFlipYSupport; |
77 fTextureUsageSupport = caps.fTextureUsageSupport; | 78 fTextureUsageSupport = caps.fTextureUsageSupport; |
78 fTexStorageSupport = caps.fTexStorageSupport; | 79 fTexStorageSupport = caps.fTexStorageSupport; |
79 fTextureRedSupport = caps.fTextureRedSupport; | 80 fTextureRedSupport = caps.fTextureRedSupport; |
80 fImagingSupport = caps.fImagingSupport; | 81 fImagingSupport = caps.fImagingSupport; |
81 fTwoFormatLimit = caps.fTwoFormatLimit; | 82 fTwoFormatLimit = caps.fTwoFormatLimit; |
82 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; | 83 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; |
83 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; | 84 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; |
84 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa
ta; | 85 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa
ta; |
85 fIsCoreProfile = caps.fIsCoreProfile; | 86 fIsCoreProfile = caps.fIsCoreProfile; |
86 fFullClearIsFree = caps.fFullClearIsFree; | 87 fFullClearIsFree = caps.fFullClearIsFree; |
87 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; | 88 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; |
88 fMapSubSupport = caps.fMapSubSupport; | |
89 | 89 |
90 return *this; | 90 return *this; |
91 } | 91 } |
92 | 92 |
93 bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { | 93 bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
94 | 94 |
95 this->reset(); | 95 this->reset(); |
96 if (!ctxInfo.isInitialized()) { | 96 if (!ctxInfo.isInitialized()) { |
97 return false; | 97 return false; |
98 } | 98 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // supported on GL 1.4 and higher or by extension | 283 // supported on GL 1.4 and higher or by extension |
284 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || | 284 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || |
285 ctxInfo.hasExtension("GL_EXT_stencil_wrap"); | 285 ctxInfo.hasExtension("GL_EXT_stencil_wrap"); |
286 } else { | 286 } else { |
287 // ES 2 has two sided stencil and stencil wrap | 287 // ES 2 has two sided stencil and stencil wrap |
288 fTwoSidedStencilSupport = true; | 288 fTwoSidedStencilSupport = true; |
289 fStencilWrapOpsSupport = true; | 289 fStencilWrapOpsSupport = true; |
290 } | 290 } |
291 | 291 |
292 if (kGL_GrGLStandard == standard) { | 292 if (kGL_GrGLStandard == standard) { |
293 fBufferLockSupport = true; // we require VBO support and the desktop VBO
extension includes | 293 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the des
ktop VBO |
294 // glMapBuffer. | 294 // extension includes glMapBuffer. |
295 fMapSubSupport = false; | 295 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffe
r_range")) { |
| 296 fMapBufferFlags |= kSubset_MapFlag; |
| 297 fMapBufferType = kMapBufferRange_MapBufferType; |
| 298 } else { |
| 299 fMapBufferType = kMapBuffer_MapBufferType; |
| 300 } |
296 } else { | 301 } else { |
297 fBufferLockSupport = ctxInfo.hasExtension("GL_OES_mapbuffer"); | 302 // Unextended GLES2 doesn't have any buffer mapping. |
298 fMapSubSupport = ctxInfo.hasExtension("GL_CHROMIUM_map_sub"); | 303 fMapBufferFlags = kNone_MapBufferType; |
| 304 if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) { |
| 305 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 306 fMapBufferType = kChromium_MapBufferType; |
| 307 } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_ma
p_buffer_range")) { |
| 308 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 309 fMapBufferType = kMapBufferRange_MapBufferType; |
| 310 } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) { |
| 311 fMapBufferFlags = kCanMap_MapFlag; |
| 312 fMapBufferType = kMapBuffer_MapBufferType; |
| 313 } |
299 } | 314 } |
300 | 315 |
301 if (kGL_GrGLStandard == standard) { | 316 if (kGL_GrGLStandard == standard) { |
302 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || | 317 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || |
303 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); | 318 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); |
304 fNPOTTextureTileSupport = true; | 319 fNPOTTextureTileSupport = true; |
305 fMipMapSupport = true; | 320 fMipMapSupport = true; |
306 } else { | 321 } else { |
307 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip
filters only | 322 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip
filters only |
308 // ES3 has no limitations. | 323 // ES3 has no limitations. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 static const char* kInvalidateFBTypeStr[] = { | 663 static const char* kInvalidateFBTypeStr[] = { |
649 "None", | 664 "None", |
650 "Discard", | 665 "Discard", |
651 "Invalidate", | 666 "Invalidate", |
652 }; | 667 }; |
653 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); | 668 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); |
654 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); | 669 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); |
655 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); | 670 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); |
656 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBT
ype + 1); | 671 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBT
ype + 1); |
657 | 672 |
| 673 static const char* kMapBufferTypeStr[] = { |
| 674 "None", |
| 675 "MapBuffer", |
| 676 "MapBufferRange", |
| 677 "Chromium", |
| 678 }; |
| 679 GR_STATIC_ASSERT(0 == kNone_MapBufferType); |
| 680 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType); |
| 681 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType); |
| 682 GR_STATIC_ASSERT(3 == kChromium_MapBufferType); |
| 683 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType +
1); |
| 684 |
658 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); | 685 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
659 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); | 686 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
660 r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); | 687 r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); |
661 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); | 688 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); |
| 689 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); |
662 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); | 690 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
663 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); | 691 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
664 if (!fIsCoreProfile) { | 692 if (!fIsCoreProfile) { |
665 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTe
xtureCoords); | 693 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTe
xtureCoords); |
666 } | 694 } |
667 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); | 695 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
668 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); | 696 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); |
669 r.appendf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); | 697 r.appendf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); |
670 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); | 698 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); |
671 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES":
"NO")); | 699 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES":
"NO")); |
672 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); | 700 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); |
673 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); | 701 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); |
674 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); | 702 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); |
675 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); | 703 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
676 | 704 |
677 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); | 705 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); |
678 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); | 706 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); |
679 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); | 707 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
680 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 708 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
681 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 709 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
682 r.appendf("Fragment coord conventions support: %s\n", | 710 r.appendf("Fragment coord conventions support: %s\n", |
683 (fFragCoordsConventionSupport ? "YES": "NO")); | 711 (fFragCoordsConventionSupport ? "YES": "NO")); |
684 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 712 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
685 r.appendf("Use non-VBO for dynamic data: %s\n", | 713 r.appendf("Use non-VBO for dynamic data: %s\n", |
686 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 714 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
687 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 715 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
688 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 716 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
689 return r; | 717 return r; |
690 } | 718 } |
OLD | NEW |