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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 1308313008: Fix ReadPixels implementation specific read format/type on desktop GL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clear
Patch Set: Created 5 years, 3 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 // 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 <sstream> 8 #include <sstream>
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 802 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
803 return 4; 803 return 4;
804 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 804 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
805 return 5; 805 return 5;
806 default: 806 default:
807 NOTREACHED(); 807 NOTREACHED();
808 return 0; 808 return 0;
809 } 809 }
810 } 810 }
811 811
812 uint32 GLES2Util::GetPreferredGLReadPixelsFormat(uint32 internal_format) { 812 uint32 GLES2Util::GetGLReadPixelsImplementationFormat(
813 uint32 internal_format, GLES2Util::TargetESVersion target_es_version) {
813 switch (internal_format) { 814 switch (internal_format) {
814 case GL_RGB16F_EXT: 815 case GL_R8:
815 case GL_RGB32F_EXT: 816 case GL_R16F:
817 case GL_R32F:
818 return GL_RED;
819 case GL_R8UI:
820 case GL_R8I:
821 case GL_R16UI:
822 case GL_R16I:
823 case GL_R32UI:
824 case GL_R32I:
825 return GL_RED_INTEGER;
826 case GL_RG8:
827 case GL_RG16F:
828 case GL_RG32F:
829 return GL_RG;
830 case GL_RG8UI:
831 case GL_RG8I:
832 case GL_RG16UI:
833 case GL_RG16I:
834 case GL_RG32UI:
835 case GL_RG32I:
836 return GL_RG_INTEGER;
837 case GL_RGB8:
838 case GL_RGB565:
839 case GL_R11F_G11F_B10F:
816 return GL_RGB; 840 return GL_RGB;
817 case GL_RGBA16F_EXT: 841 case GL_RGB:
818 case GL_RGBA32F_EXT: 842 case GL_RGB16F:
819 return GL_RGBA; 843 case GL_RGB32F:
844 if (target_es_version == kES2) {
845 return GL_RGBA;
846 }
847 return GL_RGB;
848 case GL_RGBA8UI:
849 case GL_RGBA8I:
850 case GL_RGB10_A2UI:
851 case GL_RGBA16UI:
852 case GL_RGBA16I:
853 case GL_RGBA32UI:
854 case GL_RGBA32I:
855 return GL_RGBA_INTEGER;
820 default: 856 default:
821 return GL_RGBA; 857 return GL_RGBA;
822 } 858 }
823 } 859 }
824 860
825 uint32 GLES2Util::GetPreferredGLReadPixelsType( 861 uint32 GLES2Util::GetGLReadPixelsImplementationType(
826 uint32 internal_format, uint32 texture_type) { 862 uint32 internal_format, uint32 texture_type,
863 GLES2Util::TargetESVersion target_es_version) {
827 switch (internal_format) { 864 switch (internal_format) {
828 case GL_RGBA32F_EXT: 865 case GL_R16UI:
829 case GL_RGB32F_EXT: 866 case GL_RG16UI:
867 case GL_RGBA16UI:
868 case GL_RGB10_A2:
869 case GL_RGB10_A2UI:
870 return GL_UNSIGNED_SHORT;
871 case GL_R32UI:
872 case GL_RG32UI:
873 case GL_RGBA32UI:
874 return GL_UNSIGNED_INT;
875 case GL_R8I:
876 case GL_RG8I:
877 case GL_RGBA8I:
878 return GL_BYTE;
879 case GL_R16I:
880 case GL_RG16I:
881 case GL_RGBA16I:
882 return GL_SHORT;
883 case GL_R32I:
884 case GL_RG32I:
885 case GL_RGBA32I:
886 return GL_INT;
887 case GL_R32F:
888 case GL_RG32F:
889 case GL_RGB32F:
890 case GL_RGBA32F:
830 return GL_FLOAT; 891 return GL_FLOAT;
831 case GL_RGBA16F_EXT: 892 case GL_R16F:
832 case GL_RGB16F_EXT: 893 case GL_RG16F:
833 return GL_HALF_FLOAT_OES; 894 return GL_HALF_FLOAT;
895 case GL_R11F_G11F_B10F:
896 return GL_UNSIGNED_INT_10F_11F_11F_REV;
897 case GL_RGB16F:
898 case GL_RGBA16F:
899 if (target_es_version == kES2) {
900 return GL_HALF_FLOAT_OES;
901 }
902 return GL_HALF_FLOAT;
834 case GL_RGBA: 903 case GL_RGBA:
835 case GL_RGB: 904 case GL_RGB:
836 // Unsized internal format, check the type 905 // Unsized internal format, check the type
837 switch (texture_type) { 906 switch (texture_type) {
838 case GL_FLOAT: 907 case GL_FLOAT:
839 case GL_HALF_FLOAT_OES: 908 case GL_HALF_FLOAT_OES:
840 return GL_FLOAT; 909 return GL_FLOAT;
910 // TODO(zmo): Consider return GL_UNSIGNED_SHORT_5_6_5,
911 // GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, and
912 // GL_UNSIGNED_INT_2_10_10_10_REV.
841 default: 913 default:
842 return GL_UNSIGNED_BYTE; 914 return GL_UNSIGNED_BYTE;
843 } 915 }
844 default: 916 default:
845 return GL_UNSIGNED_BYTE; 917 return GL_UNSIGNED_BYTE;
846 } 918 }
847 } 919 }
848 920
849 uint32 GLES2Util::GetChannelsForFormat(int format) { 921 uint32 GLES2Util::GetChannelsForFormat(int format) {
850 switch (format) { 922 switch (format) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 } 1356 }
1285 1357
1286 return true; 1358 return true;
1287 } 1359 }
1288 1360
1289 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" 1361 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h"
1290 1362
1291 } // namespace gles2 1363 } // namespace gles2
1292 } // namespace gpu 1364 } // namespace gpu
1293 1365
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698