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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 434063: Merged in recent changes to command buffer code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 #include <vector> 5 #include <vector>
6 #include <string> 6 #include <string>
7 #include <map> 7 #include <map>
8 #include <build/build_config.h> 8 #include <build/build_config.h>
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #define GLES2_GPU_SERVICE 1 10 #define GLES2_GPU_SERVICE 1
(...skipping 25 matching lines...) Expand all
36 template <typename T> 36 template <typename T>
37 unsigned int ImmediateDataSize(uint32 arg_count) { 37 unsigned int ImmediateDataSize(uint32 arg_count) {
38 return static_cast<unsigned int>( 38 return static_cast<unsigned int>(
39 (arg_count + 1 - ComputeNumEntries(sizeof(T))) * 39 (arg_count + 1 - ComputeNumEntries(sizeof(T))) *
40 sizeof(CommandBufferEntry)); // NOLINT 40 sizeof(CommandBufferEntry)); // NOLINT
41 } 41 }
42 42
43 // Checks if there is enough immediate data. 43 // Checks if there is enough immediate data.
44 template<typename T> 44 template<typename T>
45 bool CheckImmediateDataSize( 45 bool CheckImmediateDataSize(
46 unsigned int arg_count, 46 uint32 immediate_data_size,
47 GLuint count, 47 GLuint count,
48 size_t size, 48 size_t size,
49 unsigned int elements_per_unit) { 49 unsigned int elements_per_unit) {
50 return ImmediateDataSize<T>(arg_count) == count * size * elements_per_unit; 50 return immediate_data_size == count * size * elements_per_unit;
51 } 51 }
52 52
53 // A struct to hold info about each command. 53 // A struct to hold info about each command.
54 struct CommandInfo { 54 struct CommandInfo {
55 int arg_flags; // How to handle the arguments for this command 55 int arg_flags; // How to handle the arguments for this command
56 int arg_count; // How many arguments are expected for this command. 56 int arg_count; // How many arguments are expected for this command.
57 }; 57 };
58 58
59 // A table of CommandInfo for all the commands. 59 // A table of CommandInfo for all the commands.
60 const CommandInfo g_command_info[] = { 60 const CommandInfo g_command_info[] = {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 case GLErrorBit::kInvalidFrameBufferOperation: 142 case GLErrorBit::kInvalidFrameBufferOperation:
143 return GL_INVALID_FRAMEBUFFER_OPERATION; 143 return GL_INVALID_FRAMEBUFFER_OPERATION;
144 default: 144 default:
145 DCHECK(false); 145 DCHECK(false);
146 return GL_NO_ERROR; 146 return GL_NO_ERROR;
147 } 147 }
148 } 148 }
149 149
150 } // anonymous namespace. 150 } // anonymous namespace.
151 151
152 #if defined(OS_LINUX)
152 GLES2Decoder::GLES2Decoder() 153 GLES2Decoder::GLES2Decoder()
153 #ifdef OS_LINUX 154 : debug_(false),
154 : window_(NULL) { 155 window_(NULL) {
155 #endif 156 #elif defined(OS_WIN)
156 #ifdef OS_WIN 157 GLES2Decoder::GLES2Decoder()
157 : hwnd_(NULL) { 158 : debug_(false),
159 hwnd_(NULL) {
160 #else
161 GLES2Decoder::GLES2Decoder() {
158 #endif 162 #endif
159 } 163 }
160 164
161 // This class maps one set of ids to another. 165 // This class maps one set of ids to another.
162 class IdMap { 166 class IdMap {
163 public: 167 public:
164 // Maps a client_id to a service_id. Return false if the client_id or 168 // Maps a client_id to a service_id. Return false if the client_id or
165 // service_id are already mapped to something else. 169 // service_id are already mapped to something else.
166 bool AddMapping(GLuint client_id, GLuint service_id); 170 bool AddMapping(GLuint client_id, GLuint service_id);
167 171
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Gets the GLError through our wrapper. 308 // Gets the GLError through our wrapper.
305 GLenum GetGLError(); 309 GLenum GetGLError();
306 310
307 // Sets our wrapper for the GLError. 311 // Sets our wrapper for the GLError.
308 void SetGLError(GLenum error); 312 void SetGLError(GLenum error);
309 313
310 // Generate a member function prototype for each command in an automated and 314 // Generate a member function prototype for each command in an automated and
311 // typesafe way. 315 // typesafe way.
312 #define GLES2_CMD_OP(name) \ 316 #define GLES2_CMD_OP(name) \
313 ParseError Handle ## name( \ 317 ParseError Handle ## name( \
314 unsigned int arg_count, \ 318 uint32 immediate_data_size, \
315 const gles2::name& args); \ 319 const gles2::name& args); \
316 320
317 GLES2_COMMAND_LIST(GLES2_CMD_OP) 321 GLES2_COMMAND_LIST(GLES2_CMD_OP)
318 322
319 #undef GLES2_CMD_OP 323 #undef GLES2_CMD_OP
320 324
321 // Current GL error bits. 325 // Current GL error bits.
322 uint32 error_bits_; 326 uint32 error_bits_;
323 327
324 // Map of client ids to GL ids. 328 // Map of client ids to GL ids.
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 666 }
663 667
664 // Decode command with its arguments, and call the corresponding GL function. 668 // Decode command with its arguments, and call the corresponding GL function.
665 // Note: args is a pointer to the command buffer. As such, it could be changed 669 // Note: args is a pointer to the command buffer. As such, it could be changed
666 // by a (malicious) client at any time, so if validation has to happen, it 670 // by a (malicious) client at any time, so if validation has to happen, it
667 // should operate on a copy of them. 671 // should operate on a copy of them.
668 parse_error::ParseError GLES2DecoderImpl::DoCommand( 672 parse_error::ParseError GLES2DecoderImpl::DoCommand(
669 unsigned int command, 673 unsigned int command,
670 unsigned int arg_count, 674 unsigned int arg_count,
671 const void* cmd_data) { 675 const void* cmd_data) {
676 parse_error::ParseError result;
677 if (debug()) {
678 // TODO(gman): Change output to something useful for NaCl.
679 const char* f = GetCommandName(command);
680 printf("cmd: %s\n", GetCommandName(command));
681 }
672 unsigned int command_index = command - kStartPoint - 1; 682 unsigned int command_index = command - kStartPoint - 1;
673 if (command_index < arraysize(g_command_info)) { 683 if (command_index < arraysize(g_command_info)) {
674 const CommandInfo& info = g_command_info[command_index]; 684 const CommandInfo& info = g_command_info[command_index];
675 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); 685 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
676 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || 686 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
677 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { 687 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) {
688 uint32 immediate_data_size =
689 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT
678 switch (command) { 690 switch (command) {
679 #define GLES2_CMD_OP(name) \ 691 #define GLES2_CMD_OP(name) \
680 case name::kCmdId: \ 692 case name::kCmdId: \
681 return Handle ## name( \ 693 result = Handle ## name( \
682 arg_count, \ 694 immediate_data_size, \
683 *static_cast<const name*>(cmd_data)); \ 695 *static_cast<const name*>(cmd_data)); \
696 break; \
684 697
685 GLES2_COMMAND_LIST(GLES2_CMD_OP) 698 GLES2_COMMAND_LIST(GLES2_CMD_OP)
686
687 #undef GLES2_CMD_OP 699 #undef GLES2_CMD_OP
700 if (debug()) {
701 if (glGetError() != 0) {
702 // TODO(gman): Change output to something useful for NaCl.
703 printf("GL ERROR b4: %s\n", GetCommandName(command));
704 }
705 }
688 } 706 }
689 } else { 707 } else {
690 return parse_error::kParseInvalidArguments; 708 result = parse_error::kParseInvalidArguments;
691 } 709 }
710 } else {
711 result = DoCommonCommand(command, arg_count, cmd_data);
692 } 712 }
693 return DoCommonCommand(command, arg_count, cmd_data); 713 return result;
694 } 714 }
695 715
696 } // namespace gles2 716 } // namespace gles2
697 } // namespace command_buffer 717 } // namespace command_buffer
698 718
699 // This is included so the compiler will make these inline. 719 // This is included so the compiler will make these inline.
700 #include "gpu/command_buffer/service/gles2_cmd_decoder_validate.h" 720 #include "gpu/command_buffer/service/gles2_cmd_decoder_validate.h"
701 721
702 namespace command_buffer { 722 namespace command_buffer {
703 namespace gles2 { 723 namespace gles2 {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 error_bits_ &= ~GLErrorToErrorBit(error); 799 error_bits_ &= ~GLErrorToErrorBit(error);
780 } 800 }
781 return error; 801 return error;
782 } 802 }
783 803
784 void GLES2DecoderImpl::SetGLError(GLenum error) { 804 void GLES2DecoderImpl::SetGLError(GLenum error) {
785 error_bits_ |= GLErrorToErrorBit(error); 805 error_bits_ |= GLErrorToErrorBit(error);
786 } 806 }
787 807
788 parse_error::ParseError GLES2DecoderImpl::HandleDrawElements( 808 parse_error::ParseError GLES2DecoderImpl::HandleDrawElements(
789 unsigned int arg_count, const gles2::DrawElements& c) { 809 uint32 immediate_data_size, const gles2::DrawElements& c) {
790 if (bound_element_array_buffer_ != 0) { 810 if (bound_element_array_buffer_ != 0) {
791 GLenum mode = c.mode; 811 GLenum mode = c.mode;
792 GLsizei count = c.count; 812 GLsizei count = c.count;
793 GLenum type = c.type; 813 GLenum type = c.type;
794 const GLvoid* indices = reinterpret_cast<const GLvoid*>(c.index_offset); 814 const GLvoid* indices = reinterpret_cast<const GLvoid*>(c.index_offset);
795 glDrawElements(mode, count, type, indices); 815 glDrawElements(mode, count, type, indices);
796 } else { 816 } else {
797 SetGLError(GL_INVALID_VALUE); 817 SetGLError(GL_INVALID_VALUE);
798 } 818 }
799 return parse_error::kParseNoError; 819 return parse_error::kParseNoError;
(...skipping 24 matching lines...) Expand all
824 string_pointers[ii] = strings[ii].c_str(); 844 string_pointers[ii] = strings[ii].c_str();
825 } 845 }
826 846
827 glShaderSource(shader, count, string_pointers.get(), NULL); 847 glShaderSource(shader, count, string_pointers.get(), NULL);
828 return parse_error::kParseNoError; 848 return parse_error::kParseNoError;
829 } 849 }
830 850
831 } // anonymous namespace. 851 } // anonymous namespace.
832 852
833 parse_error::ParseError GLES2DecoderImpl::HandleShaderSource( 853 parse_error::ParseError GLES2DecoderImpl::HandleShaderSource(
834 unsigned int arg_count, const gles2::ShaderSource& c) { 854 uint32 immediate_data_size, const gles2::ShaderSource& c) {
835 GLuint shader = c.shader; 855 GLuint shader;
856 if (!id_map_.GetServiceId(c.shader, &shader)) {
857 SetGLError(GL_INVALID_VALUE);
858 return parse_error::kParseNoError;
859 }
836 GLsizei count = c.count; 860 GLsizei count = c.count;
837 uint32 data_size = c.data_size; 861 uint32 data_size = c.data_size;
838 const char** data = GetSharedMemoryAs<const char**>( 862 const char** data = GetSharedMemoryAs<const char**>(
839 c.data_shm_id, c.data_shm_offset, data_size); 863 c.data_shm_id, c.data_shm_offset, data_size);
840 parse_error::ParseError result = 864 parse_error::ParseError result =
841 ValidateShaderSource(this, arg_count, shader, count, data, NULL); 865 // TODO(gman): Manually implement validation.
866 ValidateShaderSource(
867 this, immediate_data_size, shader, count, data,
868 reinterpret_cast<const GLint*>(1));
842 if (result != parse_error::kParseNoError) { 869 if (result != parse_error::kParseNoError) {
843 return result; 870 return result;
844 } 871 }
845 return ShaderSourceHelper( 872 return ShaderSourceHelper(
846 shader, count, reinterpret_cast<const char*>(data), data_size); 873 shader, count, reinterpret_cast<const char*>(data), data_size);
847 } 874 }
848 875
849 parse_error::ParseError GLES2DecoderImpl::HandleShaderSourceImmediate( 876 parse_error::ParseError GLES2DecoderImpl::HandleShaderSourceImmediate(
850 unsigned int arg_count, const gles2::ShaderSourceImmediate& c) { 877 uint32 immediate_data_size, const gles2::ShaderSourceImmediate& c) {
851 GLuint shader = c.shader; 878 GLuint shader;
879 if (!id_map_.GetServiceId(c.shader, &shader)) {
880 SetGLError(GL_INVALID_VALUE);
881 return parse_error::kParseNoError;
882 }
852 GLsizei count = c.count; 883 GLsizei count = c.count;
853 uint32 data_size = c.data_size; 884 uint32 data_size = c.data_size;
854 // TODO(gman): need to check that data_size is in range for arg_count. 885 // TODO(gman): need to check that data_size is in range for arg_count.
855 const char** data = GetImmediateDataAs<const char**>(c); 886 const char** data = GetImmediateDataAs<const char**>(c);
856 parse_error::ParseError result = 887 parse_error::ParseError result =
857 ValidateShaderSourceImmediate( 888 ValidateShaderSourceImmediate(
858 this, arg_count, shader, count, data, NULL); 889 this, immediate_data_size, shader, count, data, NULL);
859 if (result != parse_error::kParseNoError) { 890 if (result != parse_error::kParseNoError) {
860 return result; 891 return result;
861 } 892 }
862 return ShaderSourceHelper( 893 return ShaderSourceHelper(
863 shader, count, reinterpret_cast<const char*>(data), data_size); 894 shader, count, reinterpret_cast<const char*>(data), data_size);
864 } 895 }
865 896
866 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttribPointer( 897 parse_error::ParseError GLES2DecoderImpl::HandleVertexAttribPointer(
867 unsigned int arg_count, const gles2::VertexAttribPointer& c) { 898 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) {
868 if (bound_array_buffer_ != 0) { 899 if (bound_array_buffer_ != 0) {
869 GLuint indx = c.indx; 900 GLuint indx = c.indx;
870 GLint size = c.size; 901 GLint size = c.size;
871 GLenum type = c.type; 902 GLenum type = c.type;
872 GLboolean normalized = c.normalized; 903 GLboolean normalized = c.normalized;
873 GLsizei stride = c.stride; 904 GLsizei stride = c.stride;
874 GLuint offset = c.offset; 905 GLuint offset = c.offset;
875 const void* ptr = reinterpret_cast<const void*>(c.offset); 906 const void* ptr = reinterpret_cast<const void*>(c.offset);
907 // TODO(gman): Do manual validation.
876 parse_error::ParseError result = 908 parse_error::ParseError result =
877 ValidateVertexAttribPointer( 909 ValidateVertexAttribPointer(
878 this, arg_count, indx, size, type, normalized, stride, ptr); 910 this, immediate_data_size, indx, size, type, normalized, stride,
911 reinterpret_cast<const void*>(1));
879 if (result != parse_error::kParseNoError) { 912 if (result != parse_error::kParseNoError) {
880 return result; 913 return result;
881 } 914 }
882 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); 915 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
883 } else { 916 } else {
884 SetGLError(GL_INVALID_VALUE); 917 SetGLError(GL_INVALID_VALUE);
885 } 918 }
886 return parse_error::kParseNoError; 919 return parse_error::kParseNoError;
887 } 920 }
888 921
889 parse_error::ParseError GLES2DecoderImpl::HandleReadPixels( 922 parse_error::ParseError GLES2DecoderImpl::HandleReadPixels(
890 unsigned int arg_count, const gles2::ReadPixels& c) { 923 uint32 immediate_data_size, const gles2::ReadPixels& c) {
891 // TODO(gman): Implement. 924 // TODO(gman): Implement.
892 return parse_error::kParseNoError; 925 return parse_error::kParseNoError;
893 } 926 }
894 927
895 parse_error::ParseError GLES2DecoderImpl::HandlePixelStorei( 928 parse_error::ParseError GLES2DecoderImpl::HandlePixelStorei(
896 unsigned int arg_count, const gles2::PixelStorei& c) { 929 uint32 immediate_data_size, const gles2::PixelStorei& c) {
897 // TODO(gman): Implement. 930 GLenum pname = c.pname;
931 GLenum param = c.param;
932 parse_error::ParseError result =
933 ValidatePixelStorei(this, immediate_data_size, pname, param);
934 if (result != parse_error::kParseNoError) {
935 return result;
936 }
937 glPixelStorei(pname, param);
938 switch (pname) {
939 case GL_PACK_ALIGNMENT:
940 pack_alignment_ = param;
941 break;
942 case GL_UNPACK_ALIGNMENT:
943 unpack_alignment_ = param;
944 break;
945 default:
946 // Validation should have prevented us from getting here.
947 DCHECK(false);
948 break;
949 }
950 return parse_error::kParseNoError;
951 }
952
953 parse_error::ParseError GLES2DecoderImpl::HandleGetAttribLocation(
954 uint32 immediate_data_size, const gles2::GetAttribLocation& c) {
955 GLuint program;
956 if (!id_map_.GetServiceId(c.program, &program)) {
957 SetGLError(GL_INVALID_VALUE);
958 return parse_error::kParseNoError;
959 }
960 uint32 name_size = c.data_size;
961 const char* name = GetSharedMemoryAs<const char*>(
962 c.name_shm_id, c.name_shm_offset, name_size);
963 GLint* location = GetSharedMemoryAs<GLint*>(
964 c.location_shm_id, c.location_shm_offset, sizeof(GLint));
965 if (!location || !name) {
966 return parse_error::kParseOutOfBounds;
967 }
968 String name_str(name, name_size);
969 *location = glGetAttribLocation(program, name_str.c_str());
970 return parse_error::kParseNoError;
971 }
972
973 parse_error::ParseError GLES2DecoderImpl::HandleGetAttribLocationImmediate(
974 uint32 immediate_data_size, const gles2::GetAttribLocationImmediate& c) {
975 GLuint program;
976 if (!id_map_.GetServiceId(c.program, &program)) {
977 SetGLError(GL_INVALID_VALUE);
978 return parse_error::kParseNoError;
979 }
980 uint32 name_size = c.data_size;
981 const char* name = GetImmediateDataAs<const char*>(c);
982 // TODO(gman): Make sure validate checks arg_count
983 // covers data_size.
984 GLint* location = GetSharedMemoryAs<GLint*>(
985 c.location_shm_id, c.location_shm_offset, sizeof(GLint));
986 if (!location || !name) {
987 return parse_error::kParseOutOfBounds;
988 }
989 String name_str(name, name_size);
990 *location = glGetAttribLocation(program, name_str.c_str());
991 return parse_error::kParseNoError;
992 }
993
994 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformLocation(
995 uint32 immediate_data_size, const gles2::GetUniformLocation& c) {
996 GLuint program;
997 if (!id_map_.GetServiceId(c.program, &program)) {
998 SetGLError(GL_INVALID_VALUE);
999 return parse_error::kParseNoError;
1000 }
1001 uint32 name_size = c.data_size;
1002 const char* name = GetSharedMemoryAs<const char*>(
1003 c.name_shm_id, c.name_shm_offset, name_size);
1004 GLint* location = GetSharedMemoryAs<GLint*>(
1005 c.location_shm_id, c.location_shm_offset, sizeof(GLint));
1006 if (!location || !name) {
1007 return parse_error::kParseOutOfBounds;
1008 }
1009 String name_str(name, name_size);
1010 *location = glGetUniformLocation(program, name_str.c_str());
1011 return parse_error::kParseNoError;
1012 }
1013
1014 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformLocationImmediate(
1015 uint32 immediate_data_size, const gles2::GetUniformLocationImmediate& c) {
1016 GLuint program;
1017 if (!id_map_.GetServiceId(c.program, &program)) {
1018 SetGLError(GL_INVALID_VALUE);
1019 return parse_error::kParseNoError;
1020 }
1021 uint32 name_size = c.data_size;
1022 const char* name = GetImmediateDataAs<const char*>(c);
1023 // TODO(gman): Make sure validate checks arg_count
1024 // covers data_size.
1025 GLint* location = GetSharedMemoryAs<GLint*>(
1026 c.location_shm_id, c.location_shm_offset, sizeof(GLint));
1027 if (!location || !name) {
1028 return parse_error::kParseOutOfBounds;
1029 }
1030 String name_str(name, name_size);
1031 *location = glGetUniformLocation(program, name_str.c_str());
1032 return parse_error::kParseNoError;
1033 }
1034
1035 parse_error::ParseError GLES2DecoderImpl::HandleBufferData(
1036 uint32 immediate_data_size, const gles2::BufferData& c) {
1037 GLenum target = static_cast<GLenum>(c.target);
1038 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
1039 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
1040 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
1041 GLenum usage = static_cast<GLenum>(c.usage);
1042 const void* data = NULL;
1043 if (data_shm_id != 0 || data_shm_offset != 0) {
1044 data = GetSharedMemoryAs<const void*>(data_shm_id, data_shm_offset, size);
1045 parse_error::ParseError result =
1046 ValidateBufferData(this, immediate_data_size, target, size, data,
1047 usage);
1048 if (result != parse_error::kParseNoError) {
1049 return result;
1050 }
1051 }
1052 // TODO(gman): Validate case where data is NULL.
1053 glBufferData(target, size, data, usage);
1054 return parse_error::kParseNoError;
1055 }
1056
1057 parse_error::ParseError GLES2DecoderImpl::HandleBufferDataImmediate(
1058 uint32 immediate_data_size, const gles2::BufferDataImmediate& c) {
1059 GLenum target = static_cast<GLenum>(c.target);
1060 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
1061 const void* data = GetImmediateDataAs<const void*>(c);
1062 GLenum usage = static_cast<GLenum>(c.usage);
1063 // Immediate version.
1064 // TODO(gman): Handle case where data is NULL.
1065 parse_error::ParseError result =
1066 ValidateBufferDataImmediate(this, immediate_data_size, target, size, data,
1067 usage);
1068 if (result != parse_error::kParseNoError) {
1069 return result;
1070 }
1071 glBufferData(target, size, data, usage);
1072 return parse_error::kParseNoError;
1073 }
1074
1075 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexImage2D(
1076 uint32 immediate_data_size, const gles2::CompressedTexImage2D& c) {
1077 GLenum target = static_cast<GLenum>(c.target);
1078 GLint level = static_cast<GLint>(c.level);
1079 GLenum internal_format = static_cast<GLenum>(c.internalformat);
1080 GLsizei width = static_cast<GLsizei>(c.width);
1081 GLsizei height = static_cast<GLsizei>(c.height);
1082 GLint border = static_cast<GLint>(c.border);
1083 GLsizei image_size = static_cast<GLsizei>(c.imageSize);
1084 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
1085 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
1086 const void* data = NULL;
1087 if (data_shm_id != 0 || data_shm_offset != 0) {
1088 data = GetSharedMemoryAs<const void*>(
1089 data_shm_id, data_shm_offset, image_size);
1090 parse_error::ParseError result =
1091 ValidateCompressedTexImage2D(
1092 this, immediate_data_size, target, level, internal_format, width,
1093 height, border, image_size, data);
1094 if (result != parse_error::kParseNoError) {
1095 return result;
1096 }
1097 }
1098 // TODO(gman): Validate case where data is NULL.
1099 glCompressedTexImage2D(
1100 target, level, internal_format, width, height, border, image_size, data);
1101 return parse_error::kParseNoError;
1102 }
1103
1104 parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexImage2DImmediate(
1105 uint32 immediate_data_size, const gles2::CompressedTexImage2DImmediate& c) {
1106 GLenum target = static_cast<GLenum>(c.target);
1107 GLint level = static_cast<GLint>(c.level);
1108 GLenum internal_format = static_cast<GLenum>(c.internalformat);
1109 GLsizei width = static_cast<GLsizei>(c.width);
1110 GLsizei height = static_cast<GLsizei>(c.height);
1111 GLint border = static_cast<GLint>(c.border);
1112 GLsizei image_size = static_cast<GLsizei>(c.imageSize);
1113 const void* data = GetImmediateDataAs<const void*>(c);
1114 // Immediate version.
1115 // TODO(gman): Handle case where data is NULL.
1116 parse_error::ParseError result =
1117 ValidateCompressedTexImage2DImmediate(
1118 this, immediate_data_size, target, level, internal_format, width,
1119 height, border, image_size, data);
1120 if (result != parse_error::kParseNoError) {
1121 return result;
1122 }
1123 glCompressedTexImage2D(
1124 target, level, internal_format, width, height, border, image_size, data);
1125 return parse_error::kParseNoError;
1126 }
1127
1128 parse_error::ParseError GLES2DecoderImpl::HandleTexImage2D(
1129 uint32 immediate_data_size, const gles2::TexImage2D& c) {
1130 GLenum target = static_cast<GLenum>(c.target);
1131 GLint level = static_cast<GLint>(c.level);
1132 GLint internal_format = static_cast<GLint>(c.internalformat);
1133 GLsizei width = static_cast<GLsizei>(c.width);
1134 GLsizei height = static_cast<GLsizei>(c.height);
1135 GLint border = static_cast<GLint>(c.border);
1136 GLenum format = static_cast<GLenum>(c.format);
1137 GLenum type = static_cast<GLenum>(c.type);
1138 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id);
1139 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset);
1140 uint32 pixels_size = GLES2Util::ComputeImageDataSize(
1141 width, height, format, type, unpack_alignment_);
1142 const void* pixels = NULL;
1143 if (pixels_shm_id != 0 || pixels_shm_offset != 0) {
1144 pixels = GetSharedMemoryAs<const void*>(
1145 pixels_shm_id, pixels_shm_offset, pixels_size);
1146 parse_error::ParseError result =
1147 ValidateTexImage2D(
1148 this, immediate_data_size, target, level, internal_format, width,
1149 height, border, format, type, pixels);
1150 if (result != parse_error::kParseNoError) {
1151 return result;
1152 }
1153 }
1154 // TODO(gman): Validate case where data is NULL.
1155 glTexImage2D(
1156 target, level, internal_format, width, height, border, format, type,
1157 pixels);
1158 return parse_error::kParseNoError;
1159 }
1160
1161 parse_error::ParseError GLES2DecoderImpl::HandleTexImage2DImmediate(
1162 uint32 immediate_data_size, const gles2::TexImage2DImmediate& c) {
1163 GLenum target = static_cast<GLenum>(c.target);
1164 GLint level = static_cast<GLint>(c.level);
1165 GLint internalformat = static_cast<GLint>(c.internalformat);
1166 GLsizei width = static_cast<GLsizei>(c.width);
1167 GLsizei height = static_cast<GLsizei>(c.height);
1168 GLint border = static_cast<GLint>(c.border);
1169 GLenum format = static_cast<GLenum>(c.format);
1170 GLenum type = static_cast<GLenum>(c.type);
1171 const void* pixels = GetImmediateDataAs<const void*>(c);
1172 // Immediate version.
1173 // TODO(gman): Handle case where data is NULL.
1174 parse_error::ParseError result =
1175 ValidateTexImage2DImmediate(
1176 this, immediate_data_size, target, level, internalformat, width,
1177 height, border, format, type, pixels);
1178 if (result != parse_error::kParseNoError) {
1179 return result;
1180 }
1181 glTexImage2D(
1182 target, level, internalformat, width, height, border, format, type,
1183 pixels);
898 return parse_error::kParseNoError; 1184 return parse_error::kParseNoError;
899 } 1185 }
900 1186
901 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribPointerv( 1187 parse_error::ParseError GLES2DecoderImpl::HandleGetVertexAttribPointerv(
902 unsigned int arg_count, const gles2::GetVertexAttribPointerv& c) { 1188 uint32 immediate_data_size, const gles2::GetVertexAttribPointerv& c) {
903 // TODO(gman): Implement. 1189 // TODO(gman): Implement.
904 return parse_error::kParseNoError; 1190 return parse_error::kParseNoError;
905 } 1191 }
906 1192
907 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformiv( 1193 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformiv(
908 unsigned int arg_count, const gles2::GetUniformiv& c) { 1194 uint32 immediate_data_size, const gles2::GetUniformiv& c) {
909 // TODO(gman): Implement. 1195 // TODO(gman): Implement.
910 return parse_error::kParseNoError; 1196 return parse_error::kParseNoError;
911 } 1197 }
912 1198
913 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformfv( 1199 parse_error::ParseError GLES2DecoderImpl::HandleGetUniformfv(
914 unsigned int arg_count, const gles2::GetUniformfv& c) { 1200 uint32 immediate_data_size, const gles2::GetUniformfv& c) {
915 // TODO(gman): Implement. 1201 // TODO(gman): Implement.
916 return parse_error::kParseNoError; 1202 return parse_error::kParseNoError;
917 } 1203 }
918 1204
919 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderPrecisionFormat( 1205 parse_error::ParseError GLES2DecoderImpl::HandleGetShaderPrecisionFormat(
920 unsigned int arg_count, const gles2::GetShaderPrecisionFormat& c) { 1206 uint32 immediate_data_size, const gles2::GetShaderPrecisionFormat& c) {
921 // TODO(gman): Implement. 1207 // TODO(gman): Implement.
922 return parse_error::kParseNoError; 1208 return parse_error::kParseNoError;
923 } 1209 }
924 1210
925 parse_error::ParseError GLES2DecoderImpl::HandleGetAttachedShaders( 1211 parse_error::ParseError GLES2DecoderImpl::HandleGetAttachedShaders(
926 unsigned int arg_count, const gles2::GetAttachedShaders& c) { 1212 uint32 immediate_data_size, const gles2::GetAttachedShaders& c) {
927 // TODO(gman): Implement. 1213 // TODO(gman): Implement.
928 return parse_error::kParseNoError; 1214 return parse_error::kParseNoError;
929 } 1215 }
930 1216
931 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveUniform( 1217 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveUniform(
932 unsigned int arg_count, const gles2::GetActiveUniform& c) { 1218 uint32 immediate_data_size, const gles2::GetActiveUniform& c) {
933 // TODO(gman): Implement. 1219 // TODO(gman): Implement.
934 return parse_error::kParseNoError; 1220 return parse_error::kParseNoError;
935 } 1221 }
936 1222
937 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveAttrib( 1223 parse_error::ParseError GLES2DecoderImpl::HandleGetActiveAttrib(
938 unsigned int arg_count, const gles2::GetActiveAttrib& c) { 1224 uint32 immediate_data_size, const gles2::GetActiveAttrib& c) {
939 // TODO(gman): Implement. 1225 // TODO(gman): Implement.
940 return parse_error::kParseNoError; 1226 return parse_error::kParseNoError;
941 } 1227 }
942 1228
943 // Include the auto-generated part of this file. We split this because it means 1229 // Include the auto-generated part of this file. We split this because it means
944 // we can easily edit the non-auto generated parts right here in this file 1230 // we can easily edit the non-auto generated parts right here in this file
945 // instead of having to edit some template or the code generator. 1231 // instead of having to edit some template or the code generator.
946 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 1232 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
947 1233
948 } // namespace gles2 1234 } // namespace gles2
949 } // namespace command_buffer 1235 } // namespace command_buffer
950 1236
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698