OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 |
11 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 11 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
13 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 13 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
16 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 16 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 17 #if defined(OS_LINUX) |
| 18 #include "gpu/command_buffer/service/x_utils.h" |
| 19 #endif |
17 | 20 |
18 namespace gpu { | 21 namespace gpu { |
19 namespace gles2 { | 22 namespace gles2 { |
20 | 23 |
21 // Check that certain assumptions the code makes are true. There are places in | 24 // Check that certain assumptions the code makes are true. There are places in |
22 // the code where shared memory is passed direclty to GL. Example, glUniformiv, | 25 // the code where shared memory is passed direclty to GL. Example, glUniformiv, |
23 // glShaderSource. The command buffer code assumes GLint and GLsizei (and maybe | 26 // glShaderSource. The command buffer code assumes GLint and GLsizei (and maybe |
24 // a few others) are 32bits. If they are not 32bits the code will have to change | 27 // a few others) are 32bits. If they are not 32bits the code will have to change |
25 // to call those GL functions with service side memory and then copy the results | 28 // to call those GL functions with service side memory and then copy the results |
26 // to shared memory, converting the sizes. | 29 // to shared memory, converting the sizes. |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 // Note: args is a pointer to the command buffer. As such, it could be changed | 943 // Note: args is a pointer to the command buffer. As such, it could be changed |
941 // by a (malicious) client at any time, so if validation has to happen, it | 944 // by a (malicious) client at any time, so if validation has to happen, it |
942 // should operate on a copy of them. | 945 // should operate on a copy of them. |
943 parse_error::ParseError GLES2DecoderImpl::DoCommand( | 946 parse_error::ParseError GLES2DecoderImpl::DoCommand( |
944 unsigned int command, | 947 unsigned int command, |
945 unsigned int arg_count, | 948 unsigned int arg_count, |
946 const void* cmd_data) { | 949 const void* cmd_data) { |
947 parse_error::ParseError result; | 950 parse_error::ParseError result; |
948 if (debug()) { | 951 if (debug()) { |
949 // TODO(gman): Change output to something useful for NaCl. | 952 // TODO(gman): Change output to something useful for NaCl. |
950 const char* f = GetCommandName(command); | |
951 printf("cmd: %s\n", GetCommandName(command)); | 953 printf("cmd: %s\n", GetCommandName(command)); |
952 } | 954 } |
953 unsigned int command_index = command - kStartPoint - 1; | 955 unsigned int command_index = command - kStartPoint - 1; |
954 if (command_index < arraysize(g_command_info)) { | 956 if (command_index < arraysize(g_command_info)) { |
955 const CommandInfo& info = g_command_info[command_index]; | 957 const CommandInfo& info = g_command_info[command_index]; |
956 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); | 958 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); |
957 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || | 959 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || |
958 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { | 960 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { |
959 uint32 immediate_data_size = | 961 uint32 immediate_data_size = |
960 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT | 962 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 // TODO(gman): Should we check for error? | 1177 // TODO(gman): Should we check for error? |
1176 scoped_array<char> name_buffer(new char[max_len + 1]); | 1178 scoped_array<char> name_buffer(new char[max_len + 1]); |
1177 for (GLint ii = 0; ii < num_attribs; ++ii) { | 1179 for (GLint ii = 0; ii < num_attribs; ++ii) { |
1178 GLsizei length; | 1180 GLsizei length; |
1179 GLsizei size; | 1181 GLsizei size; |
1180 GLenum type; | 1182 GLenum type; |
1181 glGetActiveAttrib( | 1183 glGetActiveAttrib( |
1182 program, ii, max_len + 1, &length, &size, &type, name_buffer.get()); | 1184 program, ii, max_len + 1, &length, &size, &type, name_buffer.get()); |
1183 // TODO(gman): Should we check for error? | 1185 // TODO(gman): Should we check for error? |
1184 GLint location = glGetAttribLocation(program, name_buffer.get()); | 1186 GLint location = glGetAttribLocation(program, name_buffer.get()); |
1185 info->SetAttributeLocation(ii, num_attribs); | 1187 info->SetAttributeLocation(ii, location); |
1186 } | 1188 } |
1187 } | 1189 } |
1188 | 1190 |
1189 void GLES2DecoderImpl::RemoveProgramInfo(GLuint program) { | 1191 void GLES2DecoderImpl::RemoveProgramInfo(GLuint program) { |
1190 ProgramInfoMap::iterator it = program_infos_.find(program); | 1192 ProgramInfoMap::iterator it = program_infos_.find(program); |
1191 if (it != program_infos_.end()) { | 1193 if (it != program_infos_.end()) { |
1192 if (current_program_info_ == &it->second) { | 1194 if (current_program_info_ == &it->second) { |
1193 current_program_info_ = NULL; | 1195 current_program_info_ = NULL; |
1194 } | 1196 } |
1195 program_infos_.erase(it); | 1197 program_infos_.erase(it); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 return parse_error::kParseNoError; | 1717 return parse_error::kParseNoError; |
1716 } | 1718 } |
1717 | 1719 |
1718 // Include the auto-generated part of this file. We split this because it means | 1720 // Include the auto-generated part of this file. We split this because it means |
1719 // we can easily edit the non-auto generated parts right here in this file | 1721 // we can easily edit the non-auto generated parts right here in this file |
1720 // instead of having to edit some template or the code generator. | 1722 // instead of having to edit some template or the code generator. |
1721 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 1723 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
1722 | 1724 |
1723 } // namespace gles2 | 1725 } // namespace gles2 |
1724 } // namespace gpu | 1726 } // namespace gpu |
1725 | |
OLD | NEW |