blob: a115b5d12e3b6cd16c41514c054047fe57703635 [file] [log] [blame]
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001/*
2 * Copyright 2012 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
9#include "GrGLCaps.h"
robertphillips@google.com6177e692013-02-28 20:16:25 +000010#include "GrGLContext.h"
bsalomon@google.comc9668ec2012-04-11 18:16:41 +000011#include "SkTSearch.h"
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000012
13GrGLCaps::GrGLCaps() {
14 this->reset();
15}
16
17void GrGLCaps::reset() {
18 fVerifiedColorConfigs.reset();
19 fStencilFormats.reset();
20 fStencilVerifiedColorConfigs.reset();
21 fMSFBOType = kNone_MSFBOType;
bsalomon@google.comc9668ec2012-04-11 18:16:41 +000022 fCoverageAAType = kNone_CoverageAAType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000023 fMaxFragmentUniformVectors = 0;
bsalomon@google.com60da4172012-06-01 19:25:00 +000024 fMaxVertexAttributes = 0;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000025 fRGBA8RenderbufferSupport = false;
26 fBGRAFormatSupport = false;
27 fBGRAIsInternalFormat = false;
28 fTextureSwizzleSupport = false;
29 fUnpackRowLengthSupport = false;
30 fUnpackFlipYSupport = false;
31 fPackRowLengthSupport = false;
32 fPackFlipYSupport = false;
33 fTextureUsageSupport = false;
34 fTexStorageSupport = false;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000035 fTextureRedSupport = false;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000036 fImagingSupport = false;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000037 fTwoFormatLimit = false;
bsalomon@google.com706f6682012-10-23 14:53:55 +000038 fFragCoordsConventionSupport = false;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000039 fVertexArrayObjectSupport = false;
bsalomon@google.com96966a52013-02-21 16:34:21 +000040 fUseNonVBOVertexAndIndexDynamicData = false;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000041 fIsCoreProfile = false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000042}
43
44GrGLCaps::GrGLCaps(const GrGLCaps& caps) {
45 *this = caps;
46}
47
48GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
49 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
50 fStencilFormats = caps.fStencilFormats;
51 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
52 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +000053 fMaxVertexAttributes = caps.fMaxVertexAttributes;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000054 fMSFBOType = caps.fMSFBOType;
bsalomon@google.comc9668ec2012-04-11 18:16:41 +000055 fCoverageAAType = caps.fCoverageAAType;
56 fMSAACoverageModes = caps.fMSAACoverageModes;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000057 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
58 fBGRAFormatSupport = caps.fBGRAFormatSupport;
59 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
60 fTextureSwizzleSupport = caps.fTextureSwizzleSupport;
61 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport;
62 fUnpackFlipYSupport = caps.fUnpackFlipYSupport;
63 fPackRowLengthSupport = caps.fPackRowLengthSupport;
64 fPackFlipYSupport = caps.fPackFlipYSupport;
65 fTextureUsageSupport = caps.fTextureUsageSupport;
66 fTexStorageSupport = caps.fTexStorageSupport;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000067 fTextureRedSupport = caps.fTextureRedSupport;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000068 fImagingSupport = caps.fImagingSupport;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000069 fTwoFormatLimit = caps.fTwoFormatLimit;
bsalomon@google.com706f6682012-10-23 14:53:55 +000070 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000071 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport;
bsalomon@google.com96966a52013-02-21 16:34:21 +000072 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000073 fIsCoreProfile = caps.fIsCoreProfile;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000074
75 return *this;
76}
77
robertphillips@google.com6177e692013-02-28 20:16:25 +000078void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000079
80 this->reset();
81 if (!ctxInfo.isInitialized()) {
82 return;
83 }
84
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000085 GrGLBinding binding = ctxInfo.binding();
86 GrGLVersion version = ctxInfo.version();
87
88 if (kES2_GrGLBinding == binding) {
89 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
90 &fMaxFragmentUniformVectors);
91 } else {
92 GrAssert(kDesktop_GrGLBinding == binding);
93 GrGLint max;
94 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max);
95 fMaxFragmentUniformVectors = max / 4;
96 }
bsalomon@google.com60da4172012-06-01 19:25:00 +000097 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000098
99 if (kDesktop_GrGLBinding == binding) {
100 fRGBA8RenderbufferSupport = true;
101 } else {
102 fRGBA8RenderbufferSupport = ctxInfo.hasExtension("GL_OES_rgb8_rgba8") ||
103 ctxInfo.hasExtension("GL_ARM_rgba8");
104 }
105
106 if (kDesktop_GrGLBinding == binding) {
107 fBGRAFormatSupport = version >= GR_GL_VER(1,2) ||
108 ctxInfo.hasExtension("GL_EXT_bgra");
109 } else {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000110 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
111 fBGRAFormatSupport = true;
112 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
113 fBGRAFormatSupport = true;
114 fBGRAIsInternalFormat = true;
115 }
116 GrAssert(fBGRAFormatSupport ||
bsalomon@google.com0342a852012-08-20 19:22:38 +0000117 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000118 }
119
120 if (kDesktop_GrGLBinding == binding) {
121 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) ||
122 ctxInfo.hasExtension("GL_ARB_texture_swizzle");
123 } else {
124 fTextureSwizzleSupport = false;
125 }
126
127 if (kDesktop_GrGLBinding == binding) {
128 fUnpackRowLengthSupport = true;
129 fUnpackFlipYSupport = false;
130 fPackRowLengthSupport = true;
131 fPackFlipYSupport = false;
132 } else {
133 fUnpackRowLengthSupport =ctxInfo.hasExtension("GL_EXT_unpack_subimage");
134 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
135 // no extension for pack row length
136 fPackRowLengthSupport = false;
137 fPackFlipYSupport =
138 ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order");
139 }
140
141 fTextureUsageSupport = (kES2_GrGLBinding == binding) &&
142 ctxInfo.hasExtension("GL_ANGLE_texture_usage");
143
144 // Tex storage is in desktop 4.2 and can be an extension to desktop or ES.
145 fTexStorageSupport = (kDesktop_GrGLBinding == binding &&
146 version >= GR_GL_VER(4,2)) ||
147 ctxInfo.hasExtension("GL_ARB_texture_storage") ||
148 ctxInfo.hasExtension("GL_EXT_texture_storage");
149
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000150 // ARB_texture_rg is part of OpenGL 3.0
151 if (kDesktop_GrGLBinding == binding) {
152 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
153 ctxInfo.hasExtension("GL_ARB_texture_rg");
154 } else {
155 fTextureRedSupport = ctxInfo.hasExtension("GL_EXT_texture_rg");
156 }
157
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000158 fImagingSupport = kDesktop_GrGLBinding == binding &&
159 ctxInfo.hasExtension("GL_ARB_imaging");
160
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000161 // ES 2 only guarantees RGBA/uchar + one other format/type combo for
162 // ReadPixels. The other format has to checked at run-time since it
163 // can change based on which render target is bound
164 fTwoFormatLimit = kES2_GrGLBinding == binding;
165
bsalomon@google.com706f6682012-10-23 14:53:55 +0000166 // Known issue on at least some Intel platforms:
167 // http://code.google.com/p/skia/issues/detail?id=946
168 if (kIntel_GrGLVendor != ctxInfo.vendor()) {
169 fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration ||
170 ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions");
171 }
172
bsalomon@google.com3012ded2013-02-22 16:44:04 +0000173 // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
174 // frequently changing VBOs. We've measured a performance increase using non-VBO vertex
175 // data for dynamic content on these GPUs. Perhaps we should read the renderer string and
176 // limit this decision to specific GPU families rather than basing it on the vendor alone.
177 if (!GR_GL_MUST_USE_VBO &&
178 (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor())) {
bsalomon@google.com96966a52013-02-21 16:34:21 +0000179 fUseNonVBOVertexAndIndexDynamicData = true;
180 }
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000181
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000182 if (kDesktop_GrGLBinding == binding && version >= GR_GL_VER(3, 2)) {
183 GrGLint profileMask;
184 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
185 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
186 }
bsalomon@google.com96966a52013-02-21 16:34:21 +0000187
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000188 if (kDesktop_GrGLBinding == binding) {
189 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
190 ctxInfo.hasExtension("GL_ARB_vertex_array_object");
191 } else {
192 fVertexArrayObjectSupport = ctxInfo.hasExtension("GL_OES_vertex_array_object");
193 }
194
robertphillips@google.com6177e692013-02-28 20:16:25 +0000195 this->initFSAASupport(ctxInfo, gli);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000196 this->initStencilFormats(ctxInfo);
197}
198
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000199bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000200 GrGLenum format,
201 GrGLenum type) const {
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000202 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
203 // ES 2 guarantees this format is supported
robertphillips@google.comeca2dfb2012-06-27 20:13:49 +0000204 return true;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000205 }
206
207 if (!fTwoFormatLimit) {
208 // not limited by ES 2's constraints
209 return true;
210 }
211
bsalomon@google.com548a4332012-07-11 19:45:22 +0000212 GrGLint otherFormat = GR_GL_RGBA;
213 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000214
215 // The other supported format/type combo supported for ReadPixels
216 // can change based on which render target is bound
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000217 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000218 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
219 &otherFormat);
220
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000221 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000222 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
223 &otherType);
224
bsalomon@google.com548a4332012-07-11 19:45:22 +0000225 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000226}
227
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000228namespace {
229int coverage_mode_compare(const GrGLCaps::MSAACoverageMode* left,
230 const GrGLCaps::MSAACoverageMode* right) {
231 if (left->fCoverageSampleCnt < right->fCoverageSampleCnt) {
232 return -1;
233 } else if (right->fCoverageSampleCnt < left->fCoverageSampleCnt) {
234 return 1;
235 } else if (left->fColorSampleCnt < right->fColorSampleCnt) {
236 return -1;
237 } else if (right->fColorSampleCnt < left->fColorSampleCnt) {
238 return 1;
239 }
240 return 0;
241}
242}
243
robertphillips@google.com6177e692013-02-28 20:16:25 +0000244void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000245
246 fMSFBOType = kNone_MSFBOType;
247 if (kDesktop_GrGLBinding != ctxInfo.binding()) {
248 if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
249 // chrome's extension is equivalent to the EXT msaa
250 // and fbo_blit extensions.
251 fMSFBOType = kDesktopEXT_MSFBOType;
252 } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000253 fMSFBOType = kAppleES_MSFBOType;
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000254 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
255 fMSFBOType = kImaginationES_MSFBOType;
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000256 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000257 } else {
258 if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
259 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
260 fMSFBOType = GrGLCaps::kDesktopARB_MSFBOType;
261 } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
262 ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
263 fMSFBOType = GrGLCaps::kDesktopEXT_MSFBOType;
264 }
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000265 // TODO: We could populate fMSAACoverageModes using GetInternalformativ
266 // on GL 4.2+. It's format-specific, though. See also
267 // http://code.google.com/p/skia/issues/detail?id=470 about using actual
268 // rather than requested sample counts in cache key.
269 if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) {
270 fCoverageAAType = kNVDesktop_CoverageAAType;
271 GrGLint count;
robertphillips@google.com6177e692013-02-28 20:16:25 +0000272 GR_GL_GetIntegerv(gli,
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000273 GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES,
274 &count);
275 fMSAACoverageModes.setCount(count);
robertphillips@google.com6177e692013-02-28 20:16:25 +0000276 GR_GL_GetIntegerv(gli,
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000277 GR_GL_MULTISAMPLE_COVERAGE_MODES,
278 (int*)&fMSAACoverageModes[0]);
279 // The NV driver seems to return the modes already sorted but the
280 // spec doesn't require this. So we sort.
reed@google.comc7a67cb2012-05-07 14:52:12 +0000281 qsort(&fMSAACoverageModes[0],
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000282 count,
283 sizeof(MSAACoverageMode),
reed@google.comc7a67cb2012-05-07 14:52:12 +0000284 SkCastForQSort(coverage_mode_compare));
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000285 }
286 }
287}
288
bsalomon@google.com8a70eef2013-03-19 13:58:55 +0000289const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampleCount) const {
bsalomon@google.comc9668ec2012-04-11 18:16:41 +0000290 static const MSAACoverageMode kNoneMode = {0, 0};
291 if (0 == fMSAACoverageModes.count()) {
292 return kNoneMode;
293 } else {
294 GrAssert(kNone_CoverageAAType != fCoverageAAType);
295 int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt;
296 desiredSampleCount = GrMin(desiredSampleCount, max);
297 MSAACoverageMode desiredMode = {desiredSampleCount, 0};
298 int idx = SkTSearch<MSAACoverageMode>(&fMSAACoverageModes[0],
299 fMSAACoverageModes.count(),
300 desiredMode,
301 sizeof(MSAACoverageMode),
302 &coverage_mode_compare);
303 if (idx < 0) {
304 idx = ~idx;
305 }
306 GrAssert(idx >= 0 && idx < fMSAACoverageModes.count());
307 return fMSAACoverageModes[idx];
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000308 }
309}
310
311namespace {
312const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount;
313}
314
315void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
316
317 // Build up list of legal stencil formats (though perhaps not supported on
318 // the particular gpu/driver) from most preferred to least.
319
320 // these consts are in order of most preferred to least preferred
321 // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
322
323 static const StencilFormat
324 // internal Format stencil bits total bits packed?
325 gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
326 gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
327 gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
328 gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000329 // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000330 gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
331
332 if (kDesktop_GrGLBinding == ctxInfo.binding()) {
333 bool supportsPackedDS =
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000334 ctxInfo.version() >= GR_GL_VER(3,0) ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000335 ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
336 ctxInfo.hasExtension("GL_ARB_framebuffer_object");
337
338 // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
339 // require FBO support we can expect these are legal formats and don't
340 // check. These also all support the unsized GL_STENCIL_INDEX.
341 fStencilFormats.push_back() = gS8;
342 fStencilFormats.push_back() = gS16;
343 if (supportsPackedDS) {
344 fStencilFormats.push_back() = gD24S8;
345 }
346 fStencilFormats.push_back() = gS4;
347 if (supportsPackedDS) {
348 fStencilFormats.push_back() = gDS;
349 }
350 } else {
351 // ES2 has STENCIL_INDEX8 without extensions but requires extensions
352 // for other formats.
353 // ES doesn't support using the unsized format.
354
355 fStencilFormats.push_back() = gS8;
356 //fStencilFormats.push_back() = gS16;
357 if (ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
358 fStencilFormats.push_back() = gD24S8;
359 }
360 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
361 fStencilFormats.push_back() = gS4;
362 }
363 }
364 GrAssert(0 == fStencilVerifiedColorConfigs.count());
365 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
366}
367
368void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
369 GrPixelConfig config,
370 const GrGLStencilBuffer::Format& format) {
371#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
372 return;
373#endif
374 GrAssert((unsigned)config < kGrPixelConfigCount);
375 GrAssert(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
376 int count = fStencilFormats.count();
377 // we expect a really small number of possible formats so linear search
378 // should be OK
379 GrAssert(count < 16);
380 for (int i = 0; i < count; ++i) {
381 if (format.fInternalFormat ==
382 fStencilFormats[i].fInternalFormat) {
383 fStencilVerifiedColorConfigs[i].markVerified(config);
384 return;
385 }
386 }
387 GrCrash("Why are we seeing a stencil format that "
388 "GrGLCaps doesn't know about.");
389}
390
391bool GrGLCaps::isColorConfigAndStencilFormatVerified(
392 GrPixelConfig config,
393 const GrGLStencilBuffer::Format& format) const {
394#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
395 return false;
396#endif
397 GrAssert((unsigned)config < kGrPixelConfigCount);
398 int count = fStencilFormats.count();
399 // we expect a really small number of possible formats so linear search
400 // should be OK
401 GrAssert(count < 16);
402 for (int i = 0; i < count; ++i) {
403 if (format.fInternalFormat ==
404 fStencilFormats[i].fInternalFormat) {
405 return fStencilVerifiedColorConfigs[i].isVerified(config);
406 }
407 }
408 GrCrash("Why are we seeing a stencil format that "
409 "GLCaps doesn't know about.");
410 return false;
411}
412
413void GrGLCaps::print() const {
414 for (int i = 0; i < fStencilFormats.count(); ++i) {
415 GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
416 i,
417 fStencilFormats[i].fStencilBits,
418 fStencilFormats[i].fTotalBits);
419 }
420
421 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
422 GR_STATIC_ASSERT(1 == kDesktopARB_MSFBOType);
423 GR_STATIC_ASSERT(2 == kDesktopEXT_MSFBOType);
424 GR_STATIC_ASSERT(3 == kAppleES_MSFBOType);
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000425 GR_STATIC_ASSERT(4 == kImaginationES_MSFBOType);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000426 static const char* gMSFBOExtStr[] = {
427 "None",
428 "ARB",
429 "EXT",
430 "Apple",
bsalomon@google.comf3a60c02013-03-19 19:06:09 +0000431 "IMG",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000432 };
433 GrPrintf("MSAA Type: %s\n", gMSFBOExtStr[fMSFBOType]);
434 GrPrintf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
435 GrPrintf("Support RGBA8 Render Buffer: %s\n",
436 (fRGBA8RenderbufferSupport ? "YES": "NO"));
437 GrPrintf("BGRA is an internal format: %s\n",
438 (fBGRAIsInternalFormat ? "YES": "NO"));
439 GrPrintf("Support texture swizzle: %s\n",
440 (fTextureSwizzleSupport ? "YES": "NO"));
441 GrPrintf("Unpack Row length support: %s\n",
442 (fUnpackRowLengthSupport ? "YES": "NO"));
443 GrPrintf("Unpack Flip Y support: %s\n",
444 (fUnpackFlipYSupport ? "YES": "NO"));
445 GrPrintf("Pack Row length support: %s\n",
446 (fPackRowLengthSupport ? "YES": "NO"));
447 GrPrintf("Pack Flip Y support: %s\n",
448 (fPackFlipYSupport ? "YES": "NO"));
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000449 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
bsalomon@google.com706f6682012-10-23 14:53:55 +0000450 GrPrintf("Fragment coord conventions support: %s\n", (fFragCoordsConventionSupport ? "YES": "NO"));
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000451}