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

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

Issue 10836185: Implement GL_EXT_debug_marker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/at_exit.h" 15 #include "base/at_exit.h"
16 #include "base/atomicops.h" 16 #include "base/atomicops.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/debug/trace_event.h" 19 #include "base/debug/trace_event.h"
20 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
21 #include "base/mac/scoped_cftyperef.h" 21 #include "base/mac/scoped_cftyperef.h"
22 #endif 22 #endif
23 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
24 #include "base/memory/weak_ptr.h" 24 #include "base/memory/weak_ptr.h"
25 #include "base/string_number_conversions.h" 25 #include "base/string_number_conversions.h"
26 #include "build/build_config.h" 26 #include "build/build_config.h"
27 #define GLES2_GPU_SERVICE 1 27 #define GLES2_GPU_SERVICE 1
28 #include "gpu/command_buffer/common/gles2_cmd_format.h" 28 #include "gpu/command_buffer/common/gles2_cmd_format.h"
29 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 29 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
30 #include "gpu/command_buffer/common/debug_marker_manager.h"
30 #include "gpu/command_buffer/common/id_allocator.h" 31 #include "gpu/command_buffer/common/id_allocator.h"
31 #include "gpu/command_buffer/service/buffer_manager.h" 32 #include "gpu/command_buffer/service/buffer_manager.h"
32 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
33 #include "gpu/command_buffer/service/context_group.h" 34 #include "gpu/command_buffer/service/context_group.h"
34 #include "gpu/command_buffer/service/feature_info.h" 35 #include "gpu/command_buffer/service/feature_info.h"
35 #include "gpu/command_buffer/service/framebuffer_manager.h" 36 #include "gpu/command_buffer/service/framebuffer_manager.h"
36 #include "gpu/command_buffer/service/gl_utils.h" 37 #include "gpu/command_buffer/service/gl_utils.h"
37 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 38 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
38 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 39 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
39 #include "gpu/command_buffer/service/gpu_switches.h" 40 #include "gpu/command_buffer/service/gpu_switches.h"
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1169
1169 // Wrapper for glViewport 1170 // Wrapper for glViewport
1170 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height); 1171 void DoViewport(GLint x, GLint y, GLsizei width, GLsizei height);
1171 1172
1172 // Wrapper for glUseProgram 1173 // Wrapper for glUseProgram
1173 void DoUseProgram(GLuint program); 1174 void DoUseProgram(GLuint program);
1174 1175
1175 // Wrapper for glValidateProgram. 1176 // Wrapper for glValidateProgram.
1176 void DoValidateProgram(GLuint program_client_id); 1177 void DoValidateProgram(GLuint program_client_id);
1177 1178
1179 void DoInsertEventMarkerEXT(GLsizei length, const GLchar* marker);
1180 void DoPushGroupMarkerEXT(GLsizei length, const GLchar* group);
1181 void DoPopGroupMarkerEXT(void);
1182
1178 // Gets the number of values that will be returned by glGetXXX. Returns 1183 // Gets the number of values that will be returned by glGetXXX. Returns
1179 // false if pname is unknown. 1184 // false if pname is unknown.
1180 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); 1185 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values);
1181 1186
1182 // Gets the GLError and stores it in our wrapper. Effectively 1187 // Gets the GLError and stores it in our wrapper. Effectively
1183 // this lets us peek at the error without losing it. 1188 // this lets us peek at the error without losing it.
1184 GLenum PeekGLError(); 1189 GLenum PeekGLError();
1185 1190
1186 // Copies the real GL errors to the wrapper. This is so we can 1191 // Copies the real GL errors to the wrapper. This is so we can
1187 // make sure there are no native GL errors before calling some GL function 1192 // make sure there are no native GL errors before calling some GL function
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 GLsizei width, GLsizei height, GLenum format, size_t size); 1353 GLsizei width, GLsizei height, GLenum format, size_t size);
1349 bool ValidateCompressedTexSubDimensions( 1354 bool ValidateCompressedTexSubDimensions(
1350 const char* function_name, 1355 const char* function_name,
1351 GLenum target, GLint level, GLint xoffset, GLint yoffset, 1356 GLenum target, GLint level, GLint xoffset, GLint yoffset,
1352 GLsizei width, GLsizei height, GLenum format, 1357 GLsizei width, GLsizei height, GLenum format,
1353 TextureManager::TextureInfo* texture); 1358 TextureManager::TextureInfo* texture);
1354 1359
1355 void LogMessage(const std::string& msg); 1360 void LogMessage(const std::string& msg);
1356 void RenderWarning(const std::string& msg); 1361 void RenderWarning(const std::string& msg);
1357 void PerformanceWarning(const std::string& msg); 1362 void PerformanceWarning(const std::string& msg);
1363 const std::string& GetLogPrefix() const;
1358 1364
1359 bool ShouldDeferDraws() { 1365 bool ShouldDeferDraws() {
1360 return !offscreen_target_frame_buffer_.get() && 1366 return !offscreen_target_frame_buffer_.get() &&
1361 bound_draw_framebuffer_ == NULL && 1367 bound_draw_framebuffer_ == NULL &&
1362 surface_->DeferDraws(); 1368 surface_->DeferDraws();
1363 } 1369 }
1364 1370
1365 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); 1371 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info);
1366 1372
1367 // Generate a member function prototype for each command in an automated and 1373 // Generate a member function prototype for each command in an automated and
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 bool bufferdata_faster_than_buffersubdata_; 1526 bool bufferdata_faster_than_buffersubdata_;
1521 1527
1522 // The last error message set. 1528 // The last error message set.
1523 std::string last_error_; 1529 std::string last_error_;
1524 1530
1525 int log_message_count_; 1531 int log_message_count_;
1526 1532
1527 // The current decoder error. 1533 // The current decoder error.
1528 error::Error current_decoder_error_; 1534 error::Error current_decoder_error_;
1529 1535
1536 DebugMarkerManager debug_marker_manager_;
1537 std::string this_in_hex_;
1538
1530 bool use_shader_translator_; 1539 bool use_shader_translator_;
1531 scoped_refptr<ShaderTranslator> vertex_translator_; 1540 scoped_refptr<ShaderTranslator> vertex_translator_;
1532 scoped_refptr<ShaderTranslator> fragment_translator_; 1541 scoped_refptr<ShaderTranslator> fragment_translator_;
1533 1542
1534 DisallowedFeatures disallowed_features_; 1543 DisallowedFeatures disallowed_features_;
1535 1544
1536 // Cached from ContextGroup 1545 // Cached from ContextGroup
1537 const Validators* validators_; 1546 const Validators* validators_;
1538 FeatureInfo::Ref feature_info_; 1547 FeatureInfo::Ref feature_info_;
1539 1548
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 derivatives_explicitly_enabled_(false), 1984 derivatives_explicitly_enabled_(false),
1976 compile_shader_always_succeeds_(false), 1985 compile_shader_always_succeeds_(false),
1977 viewport_x_(0), 1986 viewport_x_(0),
1978 viewport_y_(0), 1987 viewport_y_(0),
1979 viewport_width_(0), 1988 viewport_width_(0),
1980 viewport_height_(0), 1989 viewport_height_(0),
1981 viewport_max_width_(0), 1990 viewport_max_width_(0),
1982 viewport_max_height_(0) { 1991 viewport_max_height_(0) {
1983 DCHECK(group); 1992 DCHECK(group);
1984 1993
1994 GLES2DecoderImpl* this_temp = this;
1995 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp));
1996
1985 attrib_0_value_.v[0] = 0.0f; 1997 attrib_0_value_.v[0] = 0.0f;
1986 attrib_0_value_.v[1] = 0.0f; 1998 attrib_0_value_.v[1] = 0.0f;
1987 attrib_0_value_.v[2] = 0.0f; 1999 attrib_0_value_.v[2] = 0.0f;
1988 attrib_0_value_.v[3] = 1.0f; 2000 attrib_0_value_.v[3] = 1.0f;
1989 2001
1990 // The shader translator is used for WebGL even when running on EGL 2002 // The shader translator is used for WebGL even when running on EGL
1991 // because additional restrictions are needed (like only enabling 2003 // because additional restrictions are needed (like only enabling
1992 // GL_OES_standard_derivatives on demand). It is used for the unit 2004 // GL_OES_standard_derivatives on demand). It is used for the unit
1993 // tests because 2005 // tests because
1994 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the 2006 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 // by a (malicious) client at any time, so if validation has to happen, it 3205 // by a (malicious) client at any time, so if validation has to happen, it
3194 // should operate on a copy of them. 3206 // should operate on a copy of them.
3195 error::Error GLES2DecoderImpl::DoCommand( 3207 error::Error GLES2DecoderImpl::DoCommand(
3196 unsigned int command, 3208 unsigned int command,
3197 unsigned int arg_count, 3209 unsigned int arg_count,
3198 const void* cmd_data) { 3210 const void* cmd_data) {
3199 error::Error result = error::kNoError; 3211 error::Error result = error::kNoError;
3200 if (log_commands()) { 3212 if (log_commands()) {
3201 // TODO(notme): Change this to a LOG/VLOG that works in release. Tried 3213 // TODO(notme): Change this to a LOG/VLOG that works in release. Tried
3202 // LOG(INFO), tried VLOG(1), no luck. 3214 // LOG(INFO), tried VLOG(1), no luck.
3203 LOG(ERROR) << "[" << this << "]" << "cmd: " << GetCommandName(command); 3215 LOG(ERROR) << "[" << GetLogPrefix() << "]" << "cmd: "
3216 << GetCommandName(command);
3204 } 3217 }
3205 unsigned int command_index = command - kStartPoint - 1; 3218 unsigned int command_index = command - kStartPoint - 1;
3206 if (command_index < arraysize(g_command_info)) { 3219 if (command_index < arraysize(g_command_info)) {
3207 const CommandInfo& info = g_command_info[command_index]; 3220 const CommandInfo& info = g_command_info[command_index];
3208 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); 3221 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
3209 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || 3222 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
3210 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { 3223 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) {
3211 uint32 immediate_data_size = 3224 uint32 immediate_data_size =
3212 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT 3225 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT
3213 switch (command) { 3226 switch (command) {
3214 #define GLES2_CMD_OP(name) \ 3227 #define GLES2_CMD_OP(name) \
3215 case name::kCmdId: \ 3228 case name::kCmdId: \
3216 result = Handle ## name( \ 3229 result = Handle ## name( \
3217 immediate_data_size, \ 3230 immediate_data_size, \
3218 *static_cast<const name*>(cmd_data)); \ 3231 *static_cast<const name*>(cmd_data)); \
3219 break; \ 3232 break; \
3220 3233
3221 GLES2_COMMAND_LIST(GLES2_CMD_OP) 3234 GLES2_COMMAND_LIST(GLES2_CMD_OP)
3222 #undef GLES2_CMD_OP 3235 #undef GLES2_CMD_OP
3223 } 3236 }
3224 if (debug()) { 3237 if (debug()) {
3225 GLenum error; 3238 GLenum error;
3226 while ((error = glGetError()) != GL_NO_ERROR) { 3239 while ((error = glGetError()) != GL_NO_ERROR) {
3227 LOG(ERROR) << "[" << this << "] " 3240 LOG(ERROR) << "[" << GetLogPrefix() << "] "
3228 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : " 3241 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : "
3229 << GetCommandName(command); 3242 << GetCommandName(command);
3230 SetGLError(error, "DoCommand", "GL error from driver"); 3243 SetGLError(error, "DoCommand", "GL error from driver");
3231 } 3244 }
3232 } 3245 }
3233 } else { 3246 } else {
3234 result = error::kInvalidArguments; 3247 result = error::kInvalidArguments;
3235 } 3248 }
3236 } else { 3249 } else {
3237 result = DoCommonCommand(command, arg_count, cmd_data); 3250 result = DoCommonCommand(command, arg_count, cmd_data);
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
5088 if (error != GL_NO_ERROR) { 5101 if (error != GL_NO_ERROR) {
5089 SetGLError(error, "", ""); 5102 SetGLError(error, "", "");
5090 } 5103 }
5091 return error; 5104 return error;
5092 } 5105 }
5093 5106
5094 void GLES2DecoderImpl::SetGLError( 5107 void GLES2DecoderImpl::SetGLError(
5095 GLenum error, const char* function_name, const char* msg) { 5108 GLenum error, const char* function_name, const char* msg) {
5096 if (msg) { 5109 if (msg) {
5097 last_error_ = msg; 5110 last_error_ = msg;
5098 LogMessage(std::string("GL ERROR :") + 5111 LogMessage(GetLogPrefix() + ": " + std::string("GL ERROR :") +
5099 GLES2Util::GetStringEnum(error) + " : " + 5112 GLES2Util::GetStringEnum(error) + " : " +
5100 function_name + ": " + msg); 5113 function_name + ": " + msg);
5101 } 5114 }
5102 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 5115 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
5103 } 5116 }
5104 5117
5118 const std::string& GLES2DecoderImpl::GetLogPrefix() const {
5119 const std::string& prefix(debug_marker_manager_.GetMarker());
5120 return prefix.empty() ? this_in_hex_ : prefix;
5121 }
5122
5105 void GLES2DecoderImpl::LogMessage(const std::string& msg) { 5123 void GLES2DecoderImpl::LogMessage(const std::string& msg) {
5106 if (log_message_count_ < kMaxLogMessages || 5124 if (log_message_count_ < kMaxLogMessages ||
5107 CommandLine::ForCurrentProcess()->HasSwitch( 5125 CommandLine::ForCurrentProcess()->HasSwitch(
5108 switches::kDisableGLErrorLimit)) { 5126 switches::kDisableGLErrorLimit)) {
5109 ++log_message_count_; 5127 ++log_message_count_;
5110 // LOG this unless logging is turned off as any chromium code that 5128 // LOG this unless logging is turned off as any chromium code that
5111 // generates these errors probably has a bug. 5129 // generates these errors probably has a bug.
5112 if (log_synthesized_gl_errors()) { 5130 if (log_synthesized_gl_errors()) {
5113 LOG(ERROR) << msg; 5131 LOG(ERROR) << msg;
5114 } 5132 }
(...skipping 4070 matching lines...) Expand 10 before | Expand all | Expand 10 after
9185 9203
9186 if (!texture_manager()->Restore(info, definition.release())) { 9204 if (!texture_manager()->Restore(info, definition.release())) {
9187 SetGLError(GL_INVALID_OPERATION, 9205 SetGLError(GL_INVALID_OPERATION,
9188 "glConsumeTextureCHROMIUM", "invalid texture"); 9206 "glConsumeTextureCHROMIUM", "invalid texture");
9189 return; 9207 return;
9190 } 9208 }
9191 9209
9192 BindAndApplyTextureParameters(info); 9210 BindAndApplyTextureParameters(info);
9193 } 9211 }
9194 9212
9213 void GLES2DecoderImpl::DoInsertEventMarkerEXT(
9214 GLsizei length, const GLchar* marker) {
9215 if (!marker) {
9216 marker = "";
9217 }
9218 debug_marker_manager_.SetMarker(
9219 length ? std::string(marker, length) : std::string(marker));
9220 }
9221
9222 void GLES2DecoderImpl::DoPushGroupMarkerEXT(
9223 GLsizei length, const GLchar* marker) {
9224 if (!marker) {
9225 marker = "";
9226 }
9227 debug_marker_manager_.PushGroup(
9228 length ? std::string(marker, length) : std::string(marker));
9229 }
9230
9231 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) {
9232 debug_marker_manager_.PopGroup();
9233 }
9234
9235
9195 // Include the auto-generated part of this file. We split this because it means 9236 // Include the auto-generated part of this file. We split this because it means
9196 // we can easily edit the non-auto generated parts right here in this file 9237 // we can easily edit the non-auto generated parts right here in this file
9197 // instead of having to edit some template or the code generator. 9238 // instead of having to edit some template or the code generator.
9198 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9239 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9199 9240
9200 } // namespace gles2 9241 } // namespace gles2
9201 } // namespace gpu 9242 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698