Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/gpu/gl/GrGLCaps.cpp

Issue 304743004: Move ETC1 and LATC enums value to GrPixelConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add LATC checks Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 362 }
363 363
364 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) { 364 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) {
365 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); 365 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount);
366 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { 366 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) {
367 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); 367 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
368 } 368 }
369 369
370 this->initConfigRenderableTable(ctxInfo); 370 this->initConfigRenderableTable(ctxInfo);
371 371
372 this->initCompressedTextureSupport(ctxInfo);
373
374 return true; 372 return true;
375 } 373 }
376 374
377 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { 375 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
378 376
379 // OpenGL < 3.0 377 // OpenGL < 3.0
380 // no support for render targets unless the GL_ARB_framebuffer_object 378 // no support for render targets unless the GL_ARB_framebuffer_object
381 // extension is supported (in which case we get ALPHA, RED, RG, RGB, 379 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
382 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we 380 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
383 // probably don't get R8 in this case. 381 // probably don't get R8 in this case.
(...skipping 13 matching lines...) Expand all
397 // ES 2.0 395 // ES 2.0
398 // color renderable: RGBA4, RGB5_A1, RGB565 396 // color renderable: RGBA4, RGB5_A1, RGB565
399 // GL_EXT_texture_rg adds support for R8 as a color render target 397 // GL_EXT_texture_rg adds support for R8 as a color render target
400 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 398 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
401 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 a dded BGRA support 399 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 a dded BGRA support
402 400
403 // ES 3.0 401 // ES 3.0
404 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called 402 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
405 // below already account for this). 403 // below already account for this).
406 404
405 GrGLStandard standard = ctxInfo.standard();
406 GrGLVersion version = ctxInfo.version();
407
407 enum { 408 enum {
408 kNo_MSAA = 0, 409 kNo_MSAA = 0,
409 kYes_MSAA = 1, 410 kYes_MSAA = 1,
410 }; 411 };
411 412
412 if (kGL_GrGLStandard == ctxInfo.standard()) { 413 if (kGL_GrGLStandard == standard) {
413 // Post 3.0 we will get R8 414 // Post 3.0 we will get R8
414 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) 415 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
415 if (ctxInfo.version() >= GR_GL_VER(3,0) || 416 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
416 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { 417 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
417 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true; 418 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true;
418 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true; 419 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true;
419 } 420 }
420 } else { 421 } else {
421 // On ES we can only hope for R8 422 // On ES we can only hope for R8
422 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupp ort; 423 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupp ort;
423 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSup port; 424 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSup port;
424 } 425 }
425 426
426 if (kGL_GrGLStandard != ctxInfo.standard()) { 427 if (kGL_GrGLStandard != standard) {
427 // only available in ES 428 // only available in ES
428 fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true; 429 fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
429 fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true; 430 fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
430 } 431 }
431 432
432 // we no longer support 444 as a render target 433 // we no longer support 444 as a render target
433 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false; 434 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false;
434 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false; 435 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false;
435 436
436 if (this->fRGBA8RenderbufferSupport) { 437 if (this->fRGBA8RenderbufferSupport) {
437 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true; 438 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
438 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true; 439 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
439 } 440 }
440 441
441 if (this->fBGRAFormatSupport) { 442 if (this->fBGRAFormatSupport) {
442 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true; 443 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
443 // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of 444 // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
444 // configs that are color-renderable and can be passed to glRenderBuffer StorageMultisample. 445 // configs that are color-renderable and can be passed to glRenderBuffer StorageMultisample.
445 // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms. 446 // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms.
446 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) { 447 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) {
447 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true; 448 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true;
448 } else { 449 } else {
449 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = 450 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] =
450 !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers(); 451 !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers();
451 } 452 }
452 } 453 }
453 454
455 // Compressed texture support
456
457 // Check for ETC1
458 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version > GR_GL_VER (1, 3));
459
robertphillips 2014/05/29 12:53:18 Shouldn't this comment go above the prior line of
krajcevski 2014/05/29 14:28:22 Done.
460 // glCompressedTexImage2D is available on all OpenGL ES devices...
461 // however, it is only available on standard OpenGL after version 1.3
robertphillips 2014/05/29 12:53:18 I think setting this to false and just using 'hasC
krajcevski 2014/05/29 14:28:22 I agree. This is left over from when I was reorder
462 bool hasETC1 = hasCompressTex2D;
463
464 // First check version for support
465 if (kGL_GrGLStandard == standard) {
466 hasETC1 = hasETC1 && (version >= GR_GL_VER(4, 3) ||
467 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
468 } else {
469 hasETC1 = hasETC1 &&
470 (version >= GR_GL_VER(3, 0) ||
471 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
472 // ETC2 is a superset of ETC1, so we can just check for that, too.
473 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
474 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
475 }
476 fConfigRenderSupport[kETC1_GrPixelConfig][kYes_MSAA] = hasETC1;
477 fConfigRenderSupport[kETC1_GrPixelConfig][kNo_MSAA] = hasETC1;
478
479 // Check for LATC under its various forms
480 LATCAlias alias = kLATC_LATCAlias;
481 bool hasLATC = hasCompressTex2D && (ctxInfo.hasExtension("GL_EXT_texture_com pression_latc") ||
482 ctxInfo.hasExtension("GL_NV_texture_comp ression_latc"));
483
484 // Check for RGTC
485 if (!hasLATC) {
486 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical c ompression format.
487 if (kGL_GrGLStandard == standard) {
488 hasLATC = version >= GR_GL_VER(3, 0);
489 }
490
491 if (!hasLATC) {
492 hasLATC =
493 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
494 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
495 }
496
497 if (hasLATC) {
498 alias = kRGTC_LATCAlias;
499 }
500 }
501
502 // Check for 3DC
503 if (!hasLATC) {
504 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
505 if (hasLATC) {
506 alias = k3DC_LATCAlias;
507 }
508 }
509
510 fConfigRenderSupport[kLATC_GrPixelConfig][kYes_MSAA] = hasLATC;
511 fConfigRenderSupport[kLATC_GrPixelConfig][kNo_MSAA] = hasLATC;
512 fLATCAlias = alias;
513
454 // If we don't support MSAA then undo any places above where we set a config as renderable with 514 // If we don't support MSAA then undo any places above where we set a config as renderable with
455 // msaa. 515 // msaa.
456 if (kNone_MSFBOType == fMSFBOType) { 516 if (kNone_MSFBOType == fMSFBOType) {
457 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 517 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
458 fConfigRenderSupport[i][kYes_MSAA] = false; 518 fConfigRenderSupport[i][kYes_MSAA] = false;
459 } 519 }
460 } 520 }
461 } 521 }
462 522
463 void GrGLCaps::initCompressedTextureSupport(const GrGLContextInfo &ctxInfo) {
464 GrGLStandard standard = ctxInfo.standard();
465 GrGLVersion version = ctxInfo.version();
466
467 // glCompressedTexImage2D is available on all OpenGL ES devices...
468 // however, it is only available on standard OpenGL after version 1.3
469 if (kGL_GrGLStandard == standard && version < GR_GL_VER(1, 3)) {
470 return;
471 }
472
473 // Check for ETC1
474 bool hasETC1 = false;
475
476 // First check version for support
477 if (kGL_GrGLStandard == standard) {
478 hasETC1 =
479 version >= GR_GL_VER(4, 3) ||
480 ctxInfo.hasExtension("GL_ARB_ES3_compatibility");
481 } else {
482 hasETC1 =
483 version >= GR_GL_VER(3, 0) ||
484 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
485 // ETC2 is a superset of ETC1, so we can just check for that, too.
486 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
487 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"));
488 }
489 fCompressedFormatSupport[kETC1_GrCompressedFormat] = hasETC1;
490
491 fCompressedFormatSupport[kETC2_GrCompressedFormat] = false;
492 fCompressedFormatSupport[kDXT1_GrCompressedFormat] = false;
493 }
494
495 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, 523 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
496 GrGLenum format, 524 GrGLenum format,
497 GrGLenum type) const { 525 GrGLenum type) const {
498 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { 526 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
499 // ES 2 guarantees this format is supported 527 // ES 2 guarantees this format is supported
500 return true; 528 return true;
501 } 529 }
502 530
503 if (!fTwoFormatLimit) { 531 if (!fTwoFormatLimit) {
504 // not limited by ES 2's constraints 532 // not limited by ES 2's constraints
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); 771 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
744 r.appendf("Fragment coord conventions support: %s\n", 772 r.appendf("Fragment coord conventions support: %s\n",
745 (fFragCoordsConventionSupport ? "YES": "NO")); 773 (fFragCoordsConventionSupport ? "YES": "NO"));
746 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 774 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
747 r.appendf("Use non-VBO for dynamic data: %s\n", 775 r.appendf("Use non-VBO for dynamic data: %s\n",
748 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 776 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
749 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO ")); 777 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO "));
750 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); 778 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
751 return r; 779 return r;
752 } 780 }
OLDNEW
« src/gpu/gl/GrGLCaps.h ('K') | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLDefines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698