Chromium Code Reviews| 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 #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> |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "gpu/command_buffer/service/buffer_manager.h" | 32 #include "gpu/command_buffer/service/buffer_manager.h" |
| 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 34 #include "gpu/command_buffer/service/context_group.h" | 34 #include "gpu/command_buffer/service/context_group.h" |
| 35 #include "gpu/command_buffer/service/context_state.h" | 35 #include "gpu/command_buffer/service/context_state.h" |
| 36 #include "gpu/command_buffer/service/feature_info.h" | 36 #include "gpu/command_buffer/service/feature_info.h" |
| 37 #include "gpu/command_buffer/service/framebuffer_manager.h" | 37 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 38 #include "gpu/command_buffer/service/gl_utils.h" | 38 #include "gpu/command_buffer/service/gl_utils.h" |
| 39 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 39 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 40 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 40 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 41 #include "gpu/command_buffer/service/gpu_switches.h" | 41 #include "gpu/command_buffer/service/gpu_switches.h" |
| 42 #include "gpu/command_buffer/service/gpu_trace.h" | 42 #include "gpu/command_buffer/service/gpu_tracer.h" |
| 43 #include "gpu/command_buffer/service/image_manager.h" | 43 #include "gpu/command_buffer/service/image_manager.h" |
| 44 #include "gpu/command_buffer/service/mailbox_manager.h" | 44 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 45 #include "gpu/command_buffer/service/memory_tracking.h" | 45 #include "gpu/command_buffer/service/memory_tracking.h" |
| 46 #include "gpu/command_buffer/service/program_manager.h" | 46 #include "gpu/command_buffer/service/program_manager.h" |
| 47 #include "gpu/command_buffer/service/query_manager.h" | 47 #include "gpu/command_buffer/service/query_manager.h" |
| 48 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 48 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 49 #include "gpu/command_buffer/service/shader_manager.h" | 49 #include "gpu/command_buffer/service/shader_manager.h" |
| 50 #include "gpu/command_buffer/service/shader_translator.h" | 50 #include "gpu/command_buffer/service/shader_translator.h" |
| 51 #include "gpu/command_buffer/service/shader_translator_cache.h" | 51 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 52 #include "gpu/command_buffer/service/stream_texture.h" | 52 #include "gpu/command_buffer/service/stream_texture.h" |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1577 | 1577 |
| 1578 // Cached values of the currently assigned viewport dimensions. | 1578 // Cached values of the currently assigned viewport dimensions. |
| 1579 GLsizei viewport_max_width_; | 1579 GLsizei viewport_max_width_; |
| 1580 GLsizei viewport_max_height_; | 1580 GLsizei viewport_max_height_; |
| 1581 | 1581 |
| 1582 // Command buffer stats. | 1582 // Command buffer stats. |
| 1583 int texture_upload_count_; | 1583 int texture_upload_count_; |
| 1584 base::TimeDelta total_texture_upload_time_; | 1584 base::TimeDelta total_texture_upload_time_; |
| 1585 base::TimeDelta total_processing_commands_time_; | 1585 base::TimeDelta total_processing_commands_time_; |
| 1586 | 1586 |
| 1587 std::stack<linked_ptr<GPUTrace> > gpu_trace_stack_; | 1587 scoped_ptr<GPUTracer> gpu_tracer_; |
| 1588 | 1588 |
| 1589 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1589 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
| 1590 }; | 1590 }; |
| 1591 | 1591 |
| 1592 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1592 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
| 1593 : decoder_(decoder) { | 1593 : decoder_(decoder) { |
| 1594 decoder_->CopyRealGLErrorsToWrapper(); | 1594 decoder_->CopyRealGLErrorsToWrapper(); |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1597 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2008 const scoped_refptr<gfx::GLContext>& context, | 2008 const scoped_refptr<gfx::GLContext>& context, |
| 2009 bool offscreen, | 2009 bool offscreen, |
| 2010 const gfx::Size& size, | 2010 const gfx::Size& size, |
| 2011 const DisallowedFeatures& disallowed_features, | 2011 const DisallowedFeatures& disallowed_features, |
| 2012 const char* allowed_extensions, | 2012 const char* allowed_extensions, |
| 2013 const std::vector<int32>& attribs) { | 2013 const std::vector<int32>& attribs) { |
| 2014 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2014 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
| 2015 DCHECK(context->IsCurrent(surface.get())); | 2015 DCHECK(context->IsCurrent(surface.get())); |
| 2016 DCHECK(!context_.get()); | 2016 DCHECK(!context_.get()); |
| 2017 | 2017 |
| 2018 gpu_tracer_ = GPUTracer::Create(); | |
| 2019 | |
| 2018 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2020 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2019 switches::kEnableGPUDebugging)) { | 2021 switches::kEnableGPUDebugging)) { |
| 2020 set_debug(true); | 2022 set_debug(true); |
| 2021 } | 2023 } |
| 2022 | 2024 |
| 2023 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2025 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2024 switches::kEnableGPUCommandLogging)) { | 2026 switches::kEnableGPUCommandLogging)) { |
| 2025 set_log_commands(true); | 2027 set_log_commands(true); |
| 2026 } | 2028 } |
| 2027 | 2029 |
| (...skipping 4411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6439 } | 6441 } |
| 6440 | 6442 |
| 6441 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6443 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| 6442 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { | 6444 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { |
| 6443 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 6445 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
| 6444 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { | 6446 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { |
| 6445 SetGLError(GL_INVALID_OPERATION, | 6447 SetGLError(GL_INVALID_OPERATION, |
| 6446 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 6448 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
| 6447 return error::kNoError; | 6449 return error::kNoError; |
| 6448 } | 6450 } |
| 6451 | |
| 6452 gpu_tracer_->Process(); | |
|
apatrick
2012/12/03 22:05:41
How about contexts that we never call SwapBuffers
dsinclair
2012/12/04 15:59:27
Ah, crap. I didn't know that those didn't call Swa
| |
| 6453 | |
| 6449 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { | 6454 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { |
| 6450 return error::kNoError; | 6455 return error::kNoError; |
| 6451 } else { | 6456 } else { |
| 6452 LOG(ERROR) << "Context lost because PostSubBuffer failed."; | 6457 LOG(ERROR) << "Context lost because PostSubBuffer failed."; |
| 6453 return error::kLostContext; | 6458 return error::kLostContext; |
| 6454 } | 6459 } |
| 6455 } | 6460 } |
| 6456 | 6461 |
| 6457 error::Error GLES2DecoderImpl::GetAttribLocationHelper( | 6462 error::Error GLES2DecoderImpl::GetAttribLocationHelper( |
| 6458 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 6463 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| (...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8124 #endif | 8129 #endif |
| 8125 } | 8130 } |
| 8126 | 8131 |
| 8127 error::Error GLES2DecoderImpl::HandleSwapBuffers( | 8132 error::Error GLES2DecoderImpl::HandleSwapBuffers( |
| 8128 uint32 immediate_data_size, const gles2::SwapBuffers& c) { | 8133 uint32 immediate_data_size, const gles2::SwapBuffers& c) { |
| 8129 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 8134 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
| 8130 if (!is_offscreen && surface_->DeferSwapBuffers()) { | 8135 if (!is_offscreen && surface_->DeferSwapBuffers()) { |
| 8131 return error::kDeferCommandUntilLater; | 8136 return error::kDeferCommandUntilLater; |
| 8132 } | 8137 } |
| 8133 | 8138 |
| 8139 gpu_tracer_->Process(); | |
| 8140 | |
| 8134 int this_frame_number = frame_number_++; | 8141 int this_frame_number = frame_number_++; |
| 8135 // TRACE_EVENT for gpu tests: | 8142 // TRACE_EVENT for gpu tests: |
| 8136 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", | 8143 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", |
| 8137 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), | 8144 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), |
| 8138 "width", (is_offscreen ? offscreen_size_.width() : | 8145 "width", (is_offscreen ? offscreen_size_.width() : |
| 8139 surface_->GetSize().width())); | 8146 surface_->GetSize().width())); |
| 8140 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", | 8147 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", |
| 8141 "offscreen", is_offscreen, | 8148 "offscreen", is_offscreen, |
| 8142 "frame", this_frame_number); | 8149 "frame", this_frame_number); |
| 8143 // If offscreen then don't actually SwapBuffers to the display. Just copy | 8150 // If offscreen then don't actually SwapBuffers to the display. Just copy |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9288 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( | 9295 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( |
| 9289 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { | 9296 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { |
| 9290 Bucket* bucket = GetBucket(c.bucket_id); | 9297 Bucket* bucket = GetBucket(c.bucket_id); |
| 9291 if (!bucket || bucket->size() == 0) { | 9298 if (!bucket || bucket->size() == 0) { |
| 9292 return error::kInvalidArguments; | 9299 return error::kInvalidArguments; |
| 9293 } | 9300 } |
| 9294 std::string command_name; | 9301 std::string command_name; |
| 9295 if (!bucket->GetAsString(&command_name)) { | 9302 if (!bucket->GetAsString(&command_name)) { |
| 9296 return error::kInvalidArguments; | 9303 return error::kInvalidArguments; |
| 9297 } | 9304 } |
| 9298 | 9305 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this); |
| 9299 linked_ptr<GPUTrace> trace(new GPUTrace(command_name)); | 9306 if (!gpu_tracer_->Begin(command_name)) { |
| 9300 trace->EnableStartTrace(); | 9307 SetGLError(GL_INVALID_OPERATION, |
| 9301 gpu_trace_stack_.push(trace); | 9308 "glTraceBeginCHROMIUM", "unable to create begin trace"); |
| 9302 | 9309 return error::kNoError; |
| 9310 } | |
| 9303 return error::kNoError; | 9311 return error::kNoError; |
| 9304 } | 9312 } |
| 9305 | 9313 |
| 9306 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { | 9314 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { |
| 9307 if (gpu_trace_stack_.empty()) { | 9315 if (gpu_tracer_->CurrentName().empty()) { |
| 9308 SetGLError(GL_INVALID_OPERATION, | 9316 SetGLError(GL_INVALID_OPERATION, |
| 9309 "glTraceEndCHROMIUM", "no trace begin found"); | 9317 "glTraceEndCHROMIUM", "no trace begin found"); |
| 9310 return; | 9318 return; |
| 9311 } | 9319 } |
| 9312 | 9320 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); |
| 9313 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top(); | 9321 gpu_tracer_->End(); |
| 9314 trace->EnableEndTrace(); | |
| 9315 gpu_trace_stack_.pop(); | |
| 9316 } | 9322 } |
| 9317 | 9323 |
| 9318 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( | 9324 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( |
| 9319 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { | 9325 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { |
| 9320 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); | 9326 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); |
| 9321 | 9327 |
| 9322 // TODO: This is a copy of HandleTexImage2D validation. Merge | 9328 // TODO: This is a copy of HandleTexImage2D validation. Merge |
| 9323 // as much of it as possible. | 9329 // as much of it as possible. |
| 9324 tex_image_2d_failed_ = true; | 9330 tex_image_2d_failed_ = true; |
| 9325 GLenum target = static_cast<GLenum>(c.target); | 9331 GLenum target = static_cast<GLenum>(c.target); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9405 return error::kNoError; | 9411 return error::kNoError; |
| 9406 } | 9412 } |
| 9407 | 9413 |
| 9408 // Include the auto-generated part of this file. We split this because it means | 9414 // Include the auto-generated part of this file. We split this because it means |
| 9409 // we can easily edit the non-auto generated parts right here in this file | 9415 // we can easily edit the non-auto generated parts right here in this file |
| 9410 // instead of having to edit some template or the code generator. | 9416 // instead of having to edit some template or the code generator. |
| 9411 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9417 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9412 | 9418 |
| 9413 } // namespace gles2 | 9419 } // namespace gles2 |
| 9414 } // namespace gpu | 9420 } // namespace gpu |
| OLD | NEW |