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; | |
28 fMaxFragmentUniformVectors = 0; | 27 fMaxFragmentUniformVectors = 0; |
29 fMaxVertexAttributes = 0; | 28 fMaxVertexAttributes = 0; |
30 fMaxFragmentTextureUnits = 0; | 29 fMaxFragmentTextureUnits = 0; |
31 fMaxFixedFunctionTextureCoords = 0; | 30 fMaxFixedFunctionTextureCoords = 0; |
32 fRGBA8RenderbufferSupport = false; | 31 fRGBA8RenderbufferSupport = false; |
33 fBGRAFormatSupport = false; | 32 fBGRAFormatSupport = false; |
34 fBGRAIsInternalFormat = false; | 33 fBGRAIsInternalFormat = false; |
35 fTextureSwizzleSupport = false; | 34 fTextureSwizzleSupport = false; |
36 fUnpackRowLengthSupport = false; | 35 fUnpackRowLengthSupport = false; |
37 fUnpackFlipYSupport = false; | 36 fUnpackFlipYSupport = false; |
38 fPackRowLengthSupport = false; | 37 fPackRowLengthSupport = false; |
39 fPackFlipYSupport = false; | 38 fPackFlipYSupport = false; |
40 fTextureUsageSupport = false; | 39 fTextureUsageSupport = false; |
41 fTexStorageSupport = false; | 40 fTexStorageSupport = false; |
42 fTextureRedSupport = false; | 41 fTextureRedSupport = false; |
43 fImagingSupport = false; | 42 fImagingSupport = false; |
44 fTwoFormatLimit = false; | 43 fTwoFormatLimit = false; |
45 fFragCoordsConventionSupport = false; | 44 fFragCoordsConventionSupport = false; |
46 fVertexArrayObjectSupport = false; | 45 fVertexArrayObjectSupport = false; |
47 fUseNonVBOVertexAndIndexDynamicData = false; | 46 fUseNonVBOVertexAndIndexDynamicData = false; |
48 fIsCoreProfile = false; | 47 fIsCoreProfile = false; |
49 fFullClearIsFree = false; | 48 fFullClearIsFree = false; |
50 fDropsTileOnZeroDivide = false; | 49 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; | |
70 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; | 69 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; |
71 fBGRAFormatSupport = caps.fBGRAFormatSupport; | 70 fBGRAFormatSupport = caps.fBGRAFormatSupport; |
72 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; | 71 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; |
73 fTextureSwizzleSupport = caps.fTextureSwizzleSupport; | 72 fTextureSwizzleSupport = caps.fTextureSwizzleSupport; |
74 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; | 73 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; |
75 fUnpackFlipYSupport = caps.fUnpackFlipYSupport; | 74 fUnpackFlipYSupport = caps.fUnpackFlipYSupport; |
76 fPackRowLengthSupport = caps.fPackRowLengthSupport; | 75 fPackRowLengthSupport = caps.fPackRowLengthSupport; |
77 fPackFlipYSupport = caps.fPackFlipYSupport; | 76 fPackFlipYSupport = caps.fPackFlipYSupport; |
78 fTextureUsageSupport = caps.fTextureUsageSupport; | 77 fTextureUsageSupport = caps.fTextureUsageSupport; |
79 fTexStorageSupport = caps.fTexStorageSupport; | 78 fTexStorageSupport = caps.fTexStorageSupport; |
80 fTextureRedSupport = caps.fTextureRedSupport; | 79 fTextureRedSupport = caps.fTextureRedSupport; |
81 fImagingSupport = caps.fImagingSupport; | 80 fImagingSupport = caps.fImagingSupport; |
82 fTwoFormatLimit = caps.fTwoFormatLimit; | 81 fTwoFormatLimit = caps.fTwoFormatLimit; |
83 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; | 82 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; |
84 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; | 83 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; |
85 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa
ta; | 84 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa
ta; |
86 fIsCoreProfile = caps.fIsCoreProfile; | 85 fIsCoreProfile = caps.fIsCoreProfile; |
87 fFullClearIsFree = caps.fFullClearIsFree; | 86 fFullClearIsFree = caps.fFullClearIsFree; |
88 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; | 87 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 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the des
ktop VBO | 293 fBufferLockSupport = true; // we require VBO support and the desktop VBO
extension includes |
294 // extension includes glMapBuffer. | 294 // glMapBuffer. |
295 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffe
r_range")) { | 295 fMapSubSupport = false; |
296 fMapBufferFlags |= kSubset_MapFlag; | |
297 fMapBufferType = kMapBufferRange_MapBufferType; | |
298 } else { | |
299 fMapBufferType = kMapBuffer_MapBufferType; | |
300 } | |
301 } else { | 296 } else { |
302 // Unextended GLES2 doesn't have any buffer mapping. | 297 fBufferLockSupport = ctxInfo.hasExtension("GL_OES_mapbuffer"); |
303 fMapBufferFlags = kNone_MapBufferType; | 298 fMapSubSupport = ctxInfo.hasExtension("GL_CHROMIUM_map_sub"); |
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 } | |
314 } | 299 } |
315 | 300 |
316 if (kGL_GrGLStandard == standard) { | 301 if (kGL_GrGLStandard == standard) { |
317 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || | 302 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || |
318 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); | 303 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); |
319 fNPOTTextureTileSupport = true; | 304 fNPOTTextureTileSupport = true; |
320 fMipMapSupport = true; | 305 fMipMapSupport = true; |
321 } else { | 306 } else { |
322 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip
filters only | 307 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip
filters only |
323 // ES3 has no limitations. | 308 // ES3 has no limitations. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 static const char* kInvalidateFBTypeStr[] = { | 648 static const char* kInvalidateFBTypeStr[] = { |
664 "None", | 649 "None", |
665 "Discard", | 650 "Discard", |
666 "Invalidate", | 651 "Invalidate", |
667 }; | 652 }; |
668 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); | 653 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); |
669 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); | 654 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); |
670 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); | 655 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); |
671 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBT
ype + 1); | 656 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBT
ype + 1); |
672 | 657 |
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 | |
685 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); | 658 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
686 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); | 659 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
687 r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); | 660 r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); |
688 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); | 661 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); |
689 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); | |
690 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); | 662 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
691 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); | 663 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
692 if (!fIsCoreProfile) { | 664 if (!fIsCoreProfile) { |
693 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTe
xtureCoords); | 665 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTe
xtureCoords); |
694 } | 666 } |
695 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); | 667 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
696 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); | 668 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); |
697 r.appendf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); | 669 r.appendf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); |
698 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); | 670 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); |
699 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES":
"NO")); | 671 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES":
"NO")); |
700 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); | 672 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); |
701 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); | 673 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); |
702 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); | 674 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); |
703 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); | 675 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
704 | 676 |
705 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); | 677 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); |
706 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); | 678 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); |
707 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); | 679 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
708 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 680 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
709 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 681 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
710 r.appendf("Fragment coord conventions support: %s\n", | 682 r.appendf("Fragment coord conventions support: %s\n", |
711 (fFragCoordsConventionSupport ? "YES": "NO")); | 683 (fFragCoordsConventionSupport ? "YES": "NO")); |
712 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 684 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
713 r.appendf("Use non-VBO for dynamic data: %s\n", | 685 r.appendf("Use non-VBO for dynamic data: %s\n", |
714 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 686 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
715 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 687 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
716 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 688 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
717 return r; | 689 return r; |
718 } | 690 } |
OLD | NEW |