OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file is here so other GLES2 related files can have a common set of | 5 // This file is here so other GLES2 related files can have a common set of |
6 // includes where appropriate. | 6 // includes where appropriate. |
7 | 7 |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 | 9 |
10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 return 1; | 476 return 1; |
477 | 477 |
478 // bad enum | 478 // bad enum |
479 default: | 479 default: |
480 return 0; | 480 return 0; |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 namespace { | 484 namespace { |
485 | 485 |
| 486 // Return the number of bytes per element, based on the element type. |
| 487 int BytesPerElement(int type) { |
| 488 switch (type) { |
| 489 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
| 490 return 8; |
| 491 case GL_FLOAT: |
| 492 case GL_UNSIGNED_INT_24_8_OES: |
| 493 case GL_UNSIGNED_INT: |
| 494 case GL_INT: |
| 495 case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 496 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
| 497 case GL_UNSIGNED_INT_5_9_9_9_REV: |
| 498 return 4; |
| 499 case GL_HALF_FLOAT: |
| 500 case GL_HALF_FLOAT_OES: |
| 501 case GL_UNSIGNED_SHORT: |
| 502 case GL_SHORT: |
| 503 case GL_UNSIGNED_SHORT_5_6_5: |
| 504 case GL_UNSIGNED_SHORT_4_4_4_4: |
| 505 case GL_UNSIGNED_SHORT_5_5_5_1: |
| 506 return 2; |
| 507 case GL_UNSIGNED_BYTE: |
| 508 case GL_BYTE: |
| 509 return 1; |
| 510 default: |
| 511 return 0; |
| 512 } |
| 513 } |
| 514 |
| 515 } // anonymous namespace |
| 516 |
486 // Return the number of elements per group of a specified format. | 517 // Return the number of elements per group of a specified format. |
487 int ElementsPerGroup(int format, int type) { | 518 int GLES2Util::ElementsPerGroup(int format, int type) { |
488 switch (type) { | 519 switch (type) { |
489 case GL_UNSIGNED_SHORT_5_6_5: | 520 case GL_UNSIGNED_SHORT_5_6_5: |
490 case GL_UNSIGNED_SHORT_4_4_4_4: | 521 case GL_UNSIGNED_SHORT_4_4_4_4: |
491 case GL_UNSIGNED_SHORT_5_5_5_1: | 522 case GL_UNSIGNED_SHORT_5_5_5_1: |
492 case GL_UNSIGNED_INT_24_8_OES: | 523 case GL_UNSIGNED_INT_24_8_OES: |
493 case GL_UNSIGNED_INT_2_10_10_10_REV: | 524 case GL_UNSIGNED_INT_2_10_10_10_REV: |
494 case GL_UNSIGNED_INT_10F_11F_11F_REV: | 525 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
495 case GL_UNSIGNED_INT_5_9_9_9_REV: | 526 case GL_UNSIGNED_INT_5_9_9_9_REV: |
496 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: | 527 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
497 return 1; | 528 return 1; |
(...skipping 24 matching lines...) Expand all Loading... |
522 case GL_DEPTH24_STENCIL8_OES: | 553 case GL_DEPTH24_STENCIL8_OES: |
523 case GL_DEPTH_STENCIL_OES: | 554 case GL_DEPTH_STENCIL_OES: |
524 case GL_RED_EXT: | 555 case GL_RED_EXT: |
525 case GL_RED_INTEGER: | 556 case GL_RED_INTEGER: |
526 return 1; | 557 return 1; |
527 default: | 558 default: |
528 return 0; | 559 return 0; |
529 } | 560 } |
530 } | 561 } |
531 | 562 |
532 // Return the number of bytes per element, based on the element type. | |
533 int BytesPerElement(int type) { | |
534 switch (type) { | |
535 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: | |
536 return 8; | |
537 case GL_FLOAT: | |
538 case GL_UNSIGNED_INT_24_8_OES: | |
539 case GL_UNSIGNED_INT: | |
540 case GL_INT: | |
541 case GL_UNSIGNED_INT_2_10_10_10_REV: | |
542 case GL_UNSIGNED_INT_10F_11F_11F_REV: | |
543 case GL_UNSIGNED_INT_5_9_9_9_REV: | |
544 return 4; | |
545 case GL_HALF_FLOAT: | |
546 case GL_HALF_FLOAT_OES: | |
547 case GL_UNSIGNED_SHORT: | |
548 case GL_SHORT: | |
549 case GL_UNSIGNED_SHORT_5_6_5: | |
550 case GL_UNSIGNED_SHORT_4_4_4_4: | |
551 case GL_UNSIGNED_SHORT_5_5_5_1: | |
552 return 2; | |
553 case GL_UNSIGNED_BYTE: | |
554 case GL_BYTE: | |
555 return 1; | |
556 default: | |
557 return 0; | |
558 } | |
559 } | |
560 | |
561 } // anonymous namespace | |
562 | |
563 uint32_t GLES2Util::ComputeImageGroupSize(int format, int type) { | 563 uint32_t GLES2Util::ComputeImageGroupSize(int format, int type) { |
564 int bytes_per_element = BytesPerElement(type); | 564 int bytes_per_element = BytesPerElement(type); |
565 DCHECK_GE(8, bytes_per_element); | 565 DCHECK_GE(8, bytes_per_element); |
566 int elements_per_group = ElementsPerGroup(format, type); | 566 int elements_per_group = ElementsPerGroup(format, type); |
567 DCHECK_GE(4, elements_per_group); | 567 DCHECK_GE(4, elements_per_group); |
568 return bytes_per_element * elements_per_group; | 568 return bytes_per_element * elements_per_group; |
569 } | 569 } |
570 | 570 |
571 bool GLES2Util::ComputeImageRowSizeHelper(int width, | 571 bool GLES2Util::ComputeImageRowSizeHelper(int width, |
572 uint32_t bytes_per_group, | 572 uint32_t bytes_per_group, |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 } | 1952 } |
1953 } | 1953 } |
1954 | 1954 |
1955 return true; | 1955 return true; |
1956 } | 1956 } |
1957 | 1957 |
1958 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1958 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
1959 | 1959 |
1960 } // namespace gles2 | 1960 } // namespace gles2 |
1961 } // namespace gpu | 1961 } // namespace gpu |
OLD | NEW |