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

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 isConfigTexturable() 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
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLDefines.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 fShaderDerivativeSupport = ctxInfo.hasExtension("GL_OES_standard_derivat ives"); 361 fShaderDerivativeSupport = ctxInfo.hasExtension("GL_OES_standard_derivat ives");
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 this->initConfigTexturableTable(ctxInfo);
372 this->initCompressedTextureSupport(ctxInfo);
373 372
374 return true; 373 return true;
375 } 374 }
376 375
377 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { 376 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
378 377
379 // OpenGL < 3.0 378 // OpenGL < 3.0
380 // no support for render targets unless the GL_ARB_framebuffer_object 379 // no support for render targets unless the GL_ARB_framebuffer_object
381 // extension is supported (in which case we get ALPHA, RED, RG, RGB, 380 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
382 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we 381 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
(...skipping 14 matching lines...) Expand all
397 // ES 2.0 396 // ES 2.0
398 // color renderable: RGBA4, RGB5_A1, RGB565 397 // color renderable: RGBA4, RGB5_A1, RGB565
399 // GL_EXT_texture_rg adds support for R8 as a color render target 398 // 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 399 // 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 400 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 a dded BGRA support
402 401
403 // ES 3.0 402 // ES 3.0
404 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called 403 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
405 // below already account for this). 404 // below already account for this).
406 405
406 GrGLStandard standard = ctxInfo.standard();
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) {
(...skipping 16 matching lines...) Expand all
453 454
454 // If we don't support MSAA then undo any places above where we set a config as renderable with 455 // If we don't support MSAA then undo any places above where we set a config as renderable with
455 // msaa. 456 // msaa.
456 if (kNone_MSFBOType == fMSFBOType) { 457 if (kNone_MSFBOType == fMSFBOType) {
457 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 458 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
458 fConfigRenderSupport[i][kYes_MSAA] = false; 459 fConfigRenderSupport[i][kYes_MSAA] = false;
459 } 460 }
460 } 461 }
461 } 462 }
462 463
463 void GrGLCaps::initCompressedTextureSupport(const GrGLContextInfo &ctxInfo) { 464 void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo) {
465 // Base texture support
466 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
467 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
468 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
469 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
470 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
471 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
bsalomon 2014/05/29 19:11:29 I think this needs to duplicate the logic to setup
krajcevski 2014/05/29 19:46:42 Done.
472
473 // Compressed texture support
464 GrGLStandard standard = ctxInfo.standard(); 474 GrGLStandard standard = ctxInfo.standard();
465 GrGLVersion version = ctxInfo.version(); 475 GrGLVersion version = ctxInfo.version();
466 476
467 // glCompressedTexImage2D is available on all OpenGL ES devices... 477 // glCompressedTexImage2D is available on all OpenGL ES devices...
468 // however, it is only available on standard OpenGL after version 1.3 478 // however, it is only available on standard OpenGL after version 1.3
469 if (kGL_GrGLStandard == standard && version < GR_GL_VER(1, 3)) { 479 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version > GR_GL_VER (1, 3));
470 return;
471 }
472 480
473 // Check for ETC1 481 // Check for ETC1
474 bool hasETC1 = false; 482 bool hasETC1 = false;
475 483
476 // First check version for support 484 // First check version for support
477 if (kGL_GrGLStandard == standard) { 485 if (kGL_GrGLStandard == standard) {
478 hasETC1 = 486 hasETC1 = hasCompressTex2D &&
479 version >= GR_GL_VER(4, 3) || 487 (version >= GR_GL_VER(4, 3) ||
480 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"); 488 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
481 } else { 489 } else {
482 hasETC1 = 490 hasETC1 = hasCompressTex2D &&
483 version >= GR_GL_VER(3, 0) || 491 (version >= GR_GL_VER(3, 0) ||
484 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || 492 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
485 // ETC2 is a superset of ETC1, so we can just check for that, too. 493 // ETC2 is a superset of ETC1, so we can just check for that, too.
486 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && 494 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
487 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")); 495 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
488 } 496 }
489 fCompressedFormatSupport[kETC1_GrCompressedFormat] = hasETC1; 497 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
490 498
491 fCompressedFormatSupport[kETC2_GrCompressedFormat] = false; 499 // Check for LATC under its various forms
492 fCompressedFormatSupport[kDXT1_GrCompressedFormat] = false; 500 LATCAlias alias = kLATC_LATCAlias;
501 bool hasLATC = hasCompressTex2D &&
502 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
503 ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
504
505 // Check for RGTC
506 if (!hasLATC) {
507 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical c ompression format.
508 if (kGL_GrGLStandard == standard) {
509 hasLATC = version >= GR_GL_VER(3, 0);
510 }
511
512 if (!hasLATC) {
513 hasLATC =
514 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
515 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
516 }
517
518 if (hasLATC) {
519 alias = kRGTC_LATCAlias;
520 }
521 }
522
523 // Check for 3DC
524 if (!hasLATC) {
525 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
526 if (hasLATC) {
527 alias = k3DC_LATCAlias;
528 }
529 }
530
531 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
532 fLATCAlias = alias;
493 } 533 }
494 534
495 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, 535 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
496 GrGLenum format, 536 GrGLenum format,
497 GrGLenum type) const { 537 GrGLenum type) const {
498 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { 538 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
499 // ES 2 guarantees this format is supported 539 // ES 2 guarantees this format is supported
500 return true; 540 return true;
501 } 541 }
502 542
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); 783 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
744 r.appendf("Fragment coord conventions support: %s\n", 784 r.appendf("Fragment coord conventions support: %s\n",
745 (fFragCoordsConventionSupport ? "YES": "NO")); 785 (fFragCoordsConventionSupport ? "YES": "NO"));
746 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 786 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
747 r.appendf("Use non-VBO for dynamic data: %s\n", 787 r.appendf("Use non-VBO for dynamic data: %s\n",
748 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 788 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
749 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO ")); 789 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")); 790 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
751 return r; 791 return r;
752 } 792 }
OLDNEW
« no previous file with comments | « 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