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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 return 1; | 468 return 1; |
469 | 469 |
470 // bad enum | 470 // bad enum |
471 default: | 471 default: |
472 return 0; | 472 return 0; |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 namespace { | 476 namespace { |
477 | 477 |
| 478 // Return the number of bytes per element, based on the element type. |
| 479 int BytesPerElement(int type) { |
| 480 switch (type) { |
| 481 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
| 482 return 8; |
| 483 case GL_FLOAT: |
| 484 case GL_UNSIGNED_INT_24_8_OES: |
| 485 case GL_UNSIGNED_INT: |
| 486 case GL_INT: |
| 487 case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 488 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
| 489 case GL_UNSIGNED_INT_5_9_9_9_REV: |
| 490 return 4; |
| 491 case GL_HALF_FLOAT: |
| 492 case GL_HALF_FLOAT_OES: |
| 493 case GL_UNSIGNED_SHORT: |
| 494 case GL_SHORT: |
| 495 case GL_UNSIGNED_SHORT_5_6_5: |
| 496 case GL_UNSIGNED_SHORT_4_4_4_4: |
| 497 case GL_UNSIGNED_SHORT_5_5_5_1: |
| 498 return 2; |
| 499 case GL_UNSIGNED_BYTE: |
| 500 case GL_BYTE: |
| 501 return 1; |
| 502 default: |
| 503 return 0; |
| 504 } |
| 505 } |
| 506 |
| 507 } // anonymous namespace |
| 508 |
478 // Return the number of elements per group of a specified format. | 509 // Return the number of elements per group of a specified format. |
479 int ElementsPerGroup(int format, int type) { | 510 int GLES2Util::ElementsPerGroup(int format, int type) { |
480 switch (type) { | 511 switch (type) { |
481 case GL_UNSIGNED_SHORT_5_6_5: | 512 case GL_UNSIGNED_SHORT_5_6_5: |
482 case GL_UNSIGNED_SHORT_4_4_4_4: | 513 case GL_UNSIGNED_SHORT_4_4_4_4: |
483 case GL_UNSIGNED_SHORT_5_5_5_1: | 514 case GL_UNSIGNED_SHORT_5_5_5_1: |
484 case GL_UNSIGNED_INT_24_8_OES: | 515 case GL_UNSIGNED_INT_24_8_OES: |
485 case GL_UNSIGNED_INT_2_10_10_10_REV: | 516 case GL_UNSIGNED_INT_2_10_10_10_REV: |
486 case GL_UNSIGNED_INT_10F_11F_11F_REV: | 517 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
487 case GL_UNSIGNED_INT_5_9_9_9_REV: | 518 case GL_UNSIGNED_INT_5_9_9_9_REV: |
488 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: | 519 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
489 return 1; | 520 return 1; |
(...skipping 24 matching lines...) Expand all Loading... |
514 case GL_DEPTH24_STENCIL8_OES: | 545 case GL_DEPTH24_STENCIL8_OES: |
515 case GL_DEPTH_STENCIL_OES: | 546 case GL_DEPTH_STENCIL_OES: |
516 case GL_RED_EXT: | 547 case GL_RED_EXT: |
517 case GL_RED_INTEGER: | 548 case GL_RED_INTEGER: |
518 return 1; | 549 return 1; |
519 default: | 550 default: |
520 return 0; | 551 return 0; |
521 } | 552 } |
522 } | 553 } |
523 | 554 |
524 // Return the number of bytes per element, based on the element type. | |
525 int BytesPerElement(int type) { | |
526 switch (type) { | |
527 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: | |
528 return 8; | |
529 case GL_FLOAT: | |
530 case GL_UNSIGNED_INT_24_8_OES: | |
531 case GL_UNSIGNED_INT: | |
532 case GL_INT: | |
533 case GL_UNSIGNED_INT_2_10_10_10_REV: | |
534 case GL_UNSIGNED_INT_10F_11F_11F_REV: | |
535 case GL_UNSIGNED_INT_5_9_9_9_REV: | |
536 return 4; | |
537 case GL_HALF_FLOAT: | |
538 case GL_HALF_FLOAT_OES: | |
539 case GL_UNSIGNED_SHORT: | |
540 case GL_SHORT: | |
541 case GL_UNSIGNED_SHORT_5_6_5: | |
542 case GL_UNSIGNED_SHORT_4_4_4_4: | |
543 case GL_UNSIGNED_SHORT_5_5_5_1: | |
544 return 2; | |
545 case GL_UNSIGNED_BYTE: | |
546 case GL_BYTE: | |
547 return 1; | |
548 default: | |
549 return 0; | |
550 } | |
551 } | |
552 | |
553 } // anonymous namespace | |
554 | |
555 uint32_t GLES2Util::ComputeImageGroupSize(int format, int type) { | 555 uint32_t GLES2Util::ComputeImageGroupSize(int format, int type) { |
556 int bytes_per_element = BytesPerElement(type); | 556 int bytes_per_element = BytesPerElement(type); |
557 DCHECK_GE(8, bytes_per_element); | 557 DCHECK_GE(8, bytes_per_element); |
558 int elements_per_group = ElementsPerGroup(format, type); | 558 int elements_per_group = ElementsPerGroup(format, type); |
559 DCHECK_GE(4, elements_per_group); | 559 DCHECK_GE(4, elements_per_group); |
560 return bytes_per_element * elements_per_group; | 560 return bytes_per_element * elements_per_group; |
561 } | 561 } |
562 | 562 |
563 bool GLES2Util::ComputeImageRowSizeHelper(int width, | 563 bool GLES2Util::ComputeImageRowSizeHelper(int width, |
564 uint32_t bytes_per_group, | 564 uint32_t bytes_per_group, |
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 } | 1945 } |
1946 | 1946 |
1947 return true; | 1947 return true; |
1948 } | 1948 } |
1949 | 1949 |
1950 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1950 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
1951 | 1951 |
1952 } // namespace gles2 | 1952 } // namespace gles2 |
1953 } // namespace gpu | 1953 } // namespace gpu |
1954 | 1954 |
OLD | NEW |