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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 CheckGLError(); | 607 CheckGLError(); |
608 return state; | 608 return state; |
609 } | 609 } |
610 | 610 |
611 bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { | 611 bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { |
612 // TODO(zmo): For all the BINDING points, there is a possibility where | 612 // TODO(zmo): For all the BINDING points, there is a possibility where |
613 // resources are shared among multiple contexts, that the cached points | 613 // resources are shared among multiple contexts, that the cached points |
614 // are invalid. It is not a problem for now, but once we allow resource | 614 // are invalid. It is not a problem for now, but once we allow resource |
615 // sharing in WebGL, we need to implement a mechanism to allow correct | 615 // sharing in WebGL, we need to implement a mechanism to allow correct |
616 // client side binding points tracking. crbug.com/465562. | 616 // client side binding points tracking. crbug.com/465562. |
| 617 |
| 618 // ES2 parameters. |
617 switch (pname) { | 619 switch (pname) { |
| 620 case GL_ACTIVE_TEXTURE: |
| 621 *params = active_texture_unit_ + GL_TEXTURE0; |
| 622 return true; |
| 623 case GL_ARRAY_BUFFER_BINDING: |
| 624 *params = bound_array_buffer_id_; |
| 625 return true; |
| 626 case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 627 *params = |
| 628 vertex_array_object_manager_->bound_element_array_buffer(); |
| 629 return true; |
| 630 case GL_FRAMEBUFFER_BINDING: |
| 631 *params = bound_framebuffer_; |
| 632 return true; |
618 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: | 633 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
619 *params = capabilities_.max_combined_texture_image_units; | 634 *params = capabilities_.max_combined_texture_image_units; |
620 return true; | 635 return true; |
621 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 636 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
622 *params = capabilities_.max_cube_map_texture_size; | 637 *params = capabilities_.max_cube_map_texture_size; |
623 return true; | 638 return true; |
624 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: | 639 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
625 *params = capabilities_.max_fragment_uniform_vectors; | 640 *params = capabilities_.max_fragment_uniform_vectors; |
626 return true; | 641 return true; |
627 case GL_MAX_RENDERBUFFER_SIZE: | 642 case GL_MAX_RENDERBUFFER_SIZE: |
(...skipping 16 matching lines...) Expand all Loading... |
644 return true; | 659 return true; |
645 case GL_MAX_VERTEX_UNIFORM_VECTORS: | 660 case GL_MAX_VERTEX_UNIFORM_VECTORS: |
646 *params = capabilities_.max_vertex_uniform_vectors; | 661 *params = capabilities_.max_vertex_uniform_vectors; |
647 return true; | 662 return true; |
648 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: | 663 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
649 *params = capabilities_.num_compressed_texture_formats; | 664 *params = capabilities_.num_compressed_texture_formats; |
650 return true; | 665 return true; |
651 case GL_NUM_SHADER_BINARY_FORMATS: | 666 case GL_NUM_SHADER_BINARY_FORMATS: |
652 *params = capabilities_.num_shader_binary_formats; | 667 *params = capabilities_.num_shader_binary_formats; |
653 return true; | 668 return true; |
654 case GL_ARRAY_BUFFER_BINDING: | 669 case GL_RENDERBUFFER_BINDING: |
655 *params = bound_array_buffer_id_; | 670 *params = bound_renderbuffer_; |
656 return true; | |
657 case GL_ELEMENT_ARRAY_BUFFER_BINDING: | |
658 *params = | |
659 vertex_array_object_manager_->bound_element_array_buffer(); | |
660 return true; | |
661 case GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM: | |
662 *params = bound_pixel_pack_transfer_buffer_id_; | |
663 return true; | |
664 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM: | |
665 *params = bound_pixel_unpack_transfer_buffer_id_; | |
666 return true; | |
667 case GL_ACTIVE_TEXTURE: | |
668 *params = active_texture_unit_ + GL_TEXTURE0; | |
669 return true; | 671 return true; |
670 case GL_TEXTURE_BINDING_2D: | 672 case GL_TEXTURE_BINDING_2D: |
671 *params = texture_units_[active_texture_unit_].bound_texture_2d; | 673 *params = texture_units_[active_texture_unit_].bound_texture_2d; |
672 return true; | 674 return true; |
673 case GL_TEXTURE_BINDING_CUBE_MAP: | 675 case GL_TEXTURE_BINDING_CUBE_MAP: |
674 *params = texture_units_[active_texture_unit_].bound_texture_cube_map; | 676 *params = texture_units_[active_texture_unit_].bound_texture_cube_map; |
675 return true; | 677 return true; |
| 678 |
| 679 // Non-standard parameters. |
676 case GL_TEXTURE_BINDING_EXTERNAL_OES: | 680 case GL_TEXTURE_BINDING_EXTERNAL_OES: |
677 *params = | 681 *params = |
678 texture_units_[active_texture_unit_].bound_texture_external_oes; | 682 texture_units_[active_texture_unit_].bound_texture_external_oes; |
679 return true; | 683 return true; |
680 case GL_FRAMEBUFFER_BINDING: | 684 case GL_PIXEL_PACK_TRANSFER_BUFFER_BINDING_CHROMIUM: |
681 *params = bound_framebuffer_; | 685 *params = bound_pixel_pack_transfer_buffer_id_; |
| 686 return true; |
| 687 case GL_PIXEL_UNPACK_TRANSFER_BUFFER_BINDING_CHROMIUM: |
| 688 *params = bound_pixel_unpack_transfer_buffer_id_; |
682 return true; | 689 return true; |
683 case GL_READ_FRAMEBUFFER_BINDING: | 690 case GL_READ_FRAMEBUFFER_BINDING: |
684 if (IsChromiumFramebufferMultisampleAvailable()) { | 691 if (IsChromiumFramebufferMultisampleAvailable()) { |
685 *params = bound_read_framebuffer_; | 692 *params = bound_read_framebuffer_; |
686 return true; | 693 return true; |
687 } | 694 } |
| 695 break; |
| 696 |
| 697 // Non-cached parameters. |
| 698 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 699 case GL_ALIASED_POINT_SIZE_RANGE: |
| 700 case GL_ALPHA_BITS: |
| 701 case GL_BLEND: |
| 702 case GL_BLEND_COLOR: |
| 703 case GL_BLEND_DST_ALPHA: |
| 704 case GL_BLEND_DST_RGB: |
| 705 case GL_BLEND_EQUATION_ALPHA: |
| 706 case GL_BLEND_EQUATION_RGB: |
| 707 case GL_BLEND_SRC_ALPHA: |
| 708 case GL_BLEND_SRC_RGB: |
| 709 case GL_BLUE_BITS: |
| 710 case GL_COLOR_CLEAR_VALUE: |
| 711 case GL_COLOR_WRITEMASK: |
| 712 case GL_COMPRESSED_TEXTURE_FORMATS: |
| 713 case GL_CULL_FACE: |
| 714 case GL_CULL_FACE_MODE: |
| 715 case GL_CURRENT_PROGRAM: |
| 716 case GL_DEPTH_BITS: |
| 717 case GL_DEPTH_CLEAR_VALUE: |
| 718 case GL_DEPTH_FUNC: |
| 719 case GL_DEPTH_RANGE: |
| 720 case GL_DEPTH_TEST: |
| 721 case GL_DEPTH_WRITEMASK: |
| 722 case GL_DITHER: |
| 723 case GL_FRONT_FACE: |
| 724 case GL_GENERATE_MIPMAP_HINT: |
| 725 case GL_GREEN_BITS: |
| 726 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 727 case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 728 case GL_LINE_WIDTH: |
| 729 case GL_MAX_VIEWPORT_DIMS: |
| 730 case GL_PACK_ALIGNMENT: |
| 731 case GL_POLYGON_OFFSET_FACTOR: |
| 732 case GL_POLYGON_OFFSET_FILL: |
| 733 case GL_POLYGON_OFFSET_UNITS: |
| 734 case GL_RED_BITS: |
| 735 case GL_SAMPLE_ALPHA_TO_COVERAGE: |
| 736 case GL_SAMPLE_BUFFERS: |
| 737 case GL_SAMPLE_COVERAGE: |
| 738 case GL_SAMPLE_COVERAGE_INVERT: |
| 739 case GL_SAMPLE_COVERAGE_VALUE: |
| 740 case GL_SAMPLES: |
| 741 case GL_SCISSOR_BOX: |
| 742 case GL_SCISSOR_TEST: |
| 743 case GL_SHADER_COMPILER: |
| 744 case GL_STENCIL_BACK_FAIL: |
| 745 case GL_STENCIL_BACK_FUNC: |
| 746 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 747 case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 748 case GL_STENCIL_BACK_REF: |
| 749 case GL_STENCIL_BACK_VALUE_MASK: |
| 750 case GL_STENCIL_BACK_WRITEMASK: |
| 751 case GL_STENCIL_BITS: |
| 752 case GL_STENCIL_CLEAR_VALUE: |
| 753 case GL_STENCIL_FAIL: |
| 754 case GL_STENCIL_FUNC: |
| 755 case GL_STENCIL_PASS_DEPTH_FAIL: |
| 756 case GL_STENCIL_PASS_DEPTH_PASS: |
| 757 case GL_STENCIL_REF: |
| 758 case GL_STENCIL_TEST: |
| 759 case GL_STENCIL_VALUE_MASK: |
| 760 case GL_STENCIL_WRITEMASK: |
| 761 case GL_SUBPIXEL_BITS: |
| 762 case GL_UNPACK_ALIGNMENT: |
| 763 case GL_VIEWPORT: |
688 return false; | 764 return false; |
689 case GL_RENDERBUFFER_BINDING: | 765 default: |
690 *params = bound_renderbuffer_; | 766 break; |
| 767 } |
| 768 |
| 769 if (capabilities_.major_version < 3) { |
| 770 return false; |
| 771 } |
| 772 |
| 773 // ES3 parameters. |
| 774 switch (pname) { |
| 775 case GL_MAJOR_VERSION: |
| 776 *params = capabilities_.major_version; |
| 777 return true; |
| 778 case GL_MAX_3D_TEXTURE_SIZE: |
| 779 *params = capabilities_.max_3d_texture_size; |
| 780 return true; |
| 781 case GL_MAX_ARRAY_TEXTURE_LAYERS: |
| 782 *params = capabilities_.max_array_texture_layers; |
| 783 return true; |
| 784 case GL_MAX_COLOR_ATTACHMENTS: |
| 785 *params = capabilities_.max_color_attachments; |
| 786 return true; |
| 787 case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: |
| 788 *params = capabilities_.max_combined_fragment_uniform_components; |
| 789 return true; |
| 790 case GL_MAX_COMBINED_UNIFORM_BLOCKS: |
| 791 *params = capabilities_.max_combined_uniform_blocks; |
| 792 return true; |
| 793 case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: |
| 794 *params = capabilities_.max_combined_vertex_uniform_components; |
| 795 return true; |
| 796 case GL_MAX_DRAW_BUFFERS: |
| 797 *params = capabilities_.max_draw_buffers; |
| 798 return true; |
| 799 case GL_MAX_ELEMENT_INDEX: |
| 800 *params = capabilities_.max_element_index; |
| 801 return true; |
| 802 case GL_MAX_ELEMENTS_INDICES: |
| 803 *params = capabilities_.max_elements_indices; |
| 804 return true; |
| 805 case GL_MAX_ELEMENTS_VERTICES: |
| 806 *params = capabilities_.max_elements_vertices; |
| 807 return true; |
| 808 case GL_MAX_FRAGMENT_INPUT_COMPONENTS: |
| 809 *params = capabilities_.max_fragment_input_components; |
| 810 return true; |
| 811 case GL_MAX_FRAGMENT_UNIFORM_BLOCKS: |
| 812 *params = capabilities_.max_fragment_uniform_blocks; |
| 813 return true; |
| 814 case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS: |
| 815 *params = capabilities_.max_fragment_uniform_components; |
| 816 return true; |
| 817 case GL_MAX_PROGRAM_TEXEL_OFFSET: |
| 818 *params = capabilities_.max_program_texel_offset; |
| 819 return true; |
| 820 case GL_MAX_SAMPLES: |
| 821 *params = capabilities_.max_samples; |
| 822 return true; |
| 823 case GL_MAX_SERVER_WAIT_TIMEOUT: |
| 824 *params = capabilities_.max_server_wait_timeout; |
| 825 return true; |
| 826 case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: |
| 827 *params = capabilities_.max_transform_feedback_interleaved_components; |
| 828 return true; |
| 829 case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: |
| 830 *params = capabilities_.max_transform_feedback_separate_attribs; |
| 831 return true; |
| 832 case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: |
| 833 *params = capabilities_.max_transform_feedback_separate_components; |
| 834 return true; |
| 835 case GL_MAX_UNIFORM_BLOCK_SIZE: |
| 836 *params = capabilities_.max_uniform_block_size; |
691 return true; | 837 return true; |
692 case GL_MAX_UNIFORM_BUFFER_BINDINGS: | 838 case GL_MAX_UNIFORM_BUFFER_BINDINGS: |
693 *params = capabilities_.max_uniform_buffer_bindings; | 839 *params = capabilities_.max_uniform_buffer_bindings; |
694 return true; | 840 return true; |
695 case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: | 841 case GL_MAX_VARYING_COMPONENTS: |
696 *params = capabilities_.max_transform_feedback_separate_attribs; | 842 *params = capabilities_.max_varying_components; |
| 843 return true; |
| 844 case GL_MAX_VERTEX_OUTPUT_COMPONENTS: |
| 845 *params = capabilities_.max_vertex_output_components; |
| 846 return true; |
| 847 case GL_MAX_VERTEX_UNIFORM_BLOCKS: |
| 848 *params = capabilities_.max_vertex_uniform_blocks; |
| 849 return true; |
| 850 case GL_MAX_VERTEX_UNIFORM_COMPONENTS: |
| 851 *params = capabilities_.max_vertex_uniform_components; |
| 852 return true; |
| 853 case GL_MIN_PROGRAM_TEXEL_OFFSET: |
| 854 *params = capabilities_.min_program_texel_offset; |
| 855 return true; |
| 856 case GL_MINOR_VERSION: |
| 857 *params = capabilities_.minor_version; |
| 858 return true; |
| 859 case GL_NUM_EXTENSIONS: |
| 860 *params = capabilities_.num_extensions; |
| 861 return true; |
| 862 case GL_NUM_PROGRAM_BINARY_FORMATS: |
| 863 *params = capabilities_.num_program_binary_formats; |
697 return true; | 864 return true; |
698 case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: | 865 case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: |
699 *params = capabilities_.uniform_buffer_offset_alignment; | 866 *params = capabilities_.uniform_buffer_offset_alignment; |
700 return true; | 867 return true; |
701 // TODO(zmo): Support ES3 pnames. | 868 |
| 869 // Non-cached ES3 parameters. |
| 870 case GL_COPY_READ_BUFFER_BINDING: |
| 871 case GL_COPY_WRITE_BUFFER_BINDING: |
| 872 case GL_DRAW_BUFFER0: |
| 873 case GL_DRAW_BUFFER1: |
| 874 case GL_DRAW_BUFFER2: |
| 875 case GL_DRAW_BUFFER3: |
| 876 case GL_DRAW_BUFFER4: |
| 877 case GL_DRAW_BUFFER5: |
| 878 case GL_DRAW_BUFFER6: |
| 879 case GL_DRAW_BUFFER7: |
| 880 case GL_DRAW_BUFFER8: |
| 881 case GL_DRAW_BUFFER9: |
| 882 case GL_DRAW_BUFFER10: |
| 883 case GL_DRAW_BUFFER11: |
| 884 case GL_DRAW_BUFFER12: |
| 885 case GL_DRAW_BUFFER13: |
| 886 case GL_DRAW_BUFFER14: |
| 887 case GL_DRAW_BUFFER15: |
| 888 case GL_DRAW_FRAMEBUFFER_BINDING: |
| 889 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: |
| 890 case GL_MAX_TEXTURE_LOD_BIAS: |
| 891 case GL_PACK_ROW_LENGTH: |
| 892 case GL_PACK_SKIP_PIXELS: |
| 893 case GL_PACK_SKIP_ROWS: |
| 894 case GL_PIXEL_PACK_BUFFER_BINDING: |
| 895 case GL_PIXEL_UNPACK_BUFFER_BINDING: |
| 896 case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 897 case GL_PROGRAM_BINARY_FORMATS: |
| 898 case GL_RASTERIZER_DISCARD: |
| 899 case GL_READ_BUFFER: |
| 900 case GL_READ_FRAMEBUFFER_BINDING: |
| 901 case GL_SAMPLER_BINDING: |
| 902 case GL_SHADER_BINARY_FORMATS: |
| 903 case GL_TEXTURE_BINDING_2D_ARRAY: |
| 904 case GL_TEXTURE_BINDING_3D: |
| 905 case GL_TRANSFORM_FEEDBACK_BINDING: |
| 906 case GL_TRANSFORM_FEEDBACK_ACTIVE: |
| 907 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 908 case GL_TRANSFORM_FEEDBACK_PAUSED: |
| 909 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 910 case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 911 case GL_UNIFORM_BUFFER_BINDING: |
| 912 case GL_UNIFORM_BUFFER_SIZE: |
| 913 case GL_UNIFORM_BUFFER_START: |
| 914 case GL_UNPACK_IMAGE_HEIGHT: |
| 915 case GL_UNPACK_ROW_LENGTH: |
| 916 case GL_UNPACK_SKIP_IMAGES: |
| 917 case GL_UNPACK_SKIP_PIXELS: |
| 918 case GL_UNPACK_SKIP_ROWS: |
| 919 case GL_VERTEX_ARRAY_BINDING: |
| 920 return false; |
702 default: | 921 default: |
703 return false; | 922 return false; |
704 } | 923 } |
705 } | 924 } |
706 | 925 |
707 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { | 926 bool GLES2Implementation::GetBooleanvHelper(GLenum pname, GLboolean* params) { |
708 // TODO(gman): Make this handle pnames that return more than 1 value. | 927 // TODO(gman): Make this handle pnames that return more than 1 value. |
709 GLint value; | 928 GLint value; |
710 if (!GetHelper(pname, &value)) { | 929 if (!GetHelper(pname, &value)) { |
711 return false; | 930 return false; |
(...skipping 4417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5129 CheckGLError(); | 5348 CheckGLError(); |
5130 } | 5349 } |
5131 | 5350 |
5132 // Include the auto-generated part of this file. We split this because it means | 5351 // Include the auto-generated part of this file. We split this because it means |
5133 // we can easily edit the non-auto generated parts right here in this file | 5352 // we can easily edit the non-auto generated parts right here in this file |
5134 // instead of having to edit some template or the code generator. | 5353 // instead of having to edit some template or the code generator. |
5135 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 5354 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
5136 | 5355 |
5137 } // namespace gles2 | 5356 } // namespace gles2 |
5138 } // namespace gpu | 5357 } // namespace gpu |
OLD | NEW |