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

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

Issue 558513003: command_buffer: Batch command processing to reduce handler overheads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 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 #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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 public ErrorStateClient { 565 public ErrorStateClient {
566 public: 566 public:
567 explicit GLES2DecoderImpl(ContextGroup* group); 567 explicit GLES2DecoderImpl(ContextGroup* group);
568 virtual ~GLES2DecoderImpl(); 568 virtual ~GLES2DecoderImpl();
569 569
570 // Overridden from AsyncAPIInterface. 570 // Overridden from AsyncAPIInterface.
571 virtual Error DoCommand(unsigned int command, 571 virtual Error DoCommand(unsigned int command,
572 unsigned int arg_count, 572 unsigned int arg_count,
573 const void* args) OVERRIDE; 573 const void* args) OVERRIDE;
574 574
575 virtual error::Error DoCommands(unsigned int num_commands,
576 const void* buffer,
577 int num_entries,
578 int* entries_processed) OVERRIDE;
579
575 // Overridden from AsyncAPIInterface. 580 // Overridden from AsyncAPIInterface.
576 virtual const char* GetCommandName(unsigned int command_id) const OVERRIDE; 581 virtual const char* GetCommandName(unsigned int command_id) const OVERRIDE;
577 582
578 // Overridden from GLES2Decoder. 583 // Overridden from GLES2Decoder.
579 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, 584 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
580 const scoped_refptr<gfx::GLContext>& context, 585 const scoped_refptr<gfx::GLContext>& context,
581 bool offscreen, 586 bool offscreen,
582 const gfx::Size& size, 587 const gfx::Size& size,
583 const DisallowedFeatures& disallowed_features, 588 const DisallowedFeatures& disallowed_features,
584 const std::vector<int32>& attribs) OVERRIDE; 589 const std::vector<int32>& attribs) OVERRIDE;
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 error::Error WillAccessBoundFramebufferForRead() { 1637 error::Error WillAccessBoundFramebufferForRead() {
1633 if (ShouldDeferReads()) 1638 if (ShouldDeferReads())
1634 return error::kDeferCommandUntilLater; 1639 return error::kDeferCommandUntilLater;
1635 if (!offscreen_target_frame_buffer_.get() && 1640 if (!offscreen_target_frame_buffer_.get() &&
1636 !framebuffer_state_.bound_read_framebuffer.get() && 1641 !framebuffer_state_.bound_read_framebuffer.get() &&
1637 !surface_->SetBackbufferAllocation(true)) 1642 !surface_->SetBackbufferAllocation(true))
1638 return error::kLostContext; 1643 return error::kLostContext;
1639 return error::kNoError; 1644 return error::kNoError;
1640 } 1645 }
1641 1646
1647 // Set remaining commands to process to 0 to force DoCommands to return
1648 // and allow context preemption and GPU watchdog checks in GpuScheduler().
1649 void ExitCommandProcessingEarly() { commands_to_process_ = 0; }
1650
1642 void ProcessPendingReadPixels(); 1651 void ProcessPendingReadPixels();
1643 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); 1652 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer);
1644 1653
1645 // Generate a member function prototype for each command in an automated and 1654 // Generate a member function prototype for each command in an automated and
1646 // typesafe way. 1655 // typesafe way.
1647 #define GLES2_CMD_OP(name) \ 1656 #define GLES2_CMD_OP(name) \
1648 Error Handle##name(uint32 immediate_data_size, const void* data); 1657 Error Handle##name(uint32 immediate_data_size, const void* data);
1649 1658
1650 GLES2_COMMAND_LIST(GLES2_CMD_OP) 1659 GLES2_COMMAND_LIST(GLES2_CMD_OP)
1651 1660
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 scoped_refptr<ShaderTranslator> fragment_translator_; 1762 scoped_refptr<ShaderTranslator> fragment_translator_;
1754 1763
1755 DisallowedFeatures disallowed_features_; 1764 DisallowedFeatures disallowed_features_;
1756 1765
1757 // Cached from ContextGroup 1766 // Cached from ContextGroup
1758 const Validators* validators_; 1767 const Validators* validators_;
1759 scoped_refptr<FeatureInfo> feature_info_; 1768 scoped_refptr<FeatureInfo> feature_info_;
1760 1769
1761 int frame_number_; 1770 int frame_number_;
1762 1771
1772 // Number of commands remaining to be processed in DoCommands().
1773 int commands_to_process_;
1774
1763 bool has_robustness_extension_; 1775 bool has_robustness_extension_;
1764 GLenum reset_status_; 1776 GLenum reset_status_;
1765 bool reset_by_robustness_extension_; 1777 bool reset_by_robustness_extension_;
1766 bool supports_post_sub_buffer_; 1778 bool supports_post_sub_buffer_;
1767 1779
1768 // These flags are used to override the state of the shared feature_info_ 1780 // These flags are used to override the state of the shared feature_info_
1769 // member. Because the same FeatureInfo instance may be shared among many 1781 // member. Because the same FeatureInfo instance may be shared among many
1770 // contexts, the assumptions on the availablity of extensions in WebGL 1782 // contexts, the assumptions on the availablity of extensions in WebGL
1771 // contexts may be broken. These flags override the shared state to preserve 1783 // contexts may be broken. These flags override the shared state to preserve
1772 // WebGL semantics. 1784 // WebGL semantics.
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after
3741 return error::kNoError; 3753 return error::kNoError;
3742 } 3754 }
3743 3755
3744 const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const { 3756 const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const {
3745 if (command_id > kStartPoint && command_id < kNumCommands) { 3757 if (command_id > kStartPoint && command_id < kNumCommands) {
3746 return gles2::GetCommandName(static_cast<CommandId>(command_id)); 3758 return gles2::GetCommandName(static_cast<CommandId>(command_id));
3747 } 3759 }
3748 return GetCommonCommandName(static_cast<cmd::CommandId>(command_id)); 3760 return GetCommonCommandName(static_cast<cmd::CommandId>(command_id));
3749 } 3761 }
3750 3762
3751 // Decode command with its arguments, and call the corresponding GL function. 3763 // Decode a command, and call the corresponding GL functions.
3752 // Note: args is a pointer to the command buffer. As such, it could be changed 3764 // NOTE: DoCommand() is slower than calling DoCommands() on larger batches
3753 // by a (malicious) client at any time, so if validation has to happen, it 3765 // of commands at once, and is now only used for tests that need to track
3754 // should operate on a copy of them. 3766 // individual commands.
3755 error::Error GLES2DecoderImpl::DoCommand( 3767 error::Error GLES2DecoderImpl::DoCommand(unsigned int command,
3756 unsigned int command, 3768 unsigned int arg_count,
3757 unsigned int arg_count, 3769 const void* cmd_data) {
3758 const void* cmd_data) { 3770 return DoCommands(1, cmd_data, arg_count + 1, 0);
3771 }
3772
3773 // Decode multiple commands, and call the corresponding GL functions.
3774 // NOTE: 'buffer' is a pointer to the command buffer. As such, it could be
3775 // changed by a (malicious) client at any time, so if validation has to happen,
3776 // it should operate on a copy of them.
3777 // NOTE: This is duplicating code from AsyncAPIInterface::DoCommands() in the
3778 // interest of performance in this critical execution loop.
3779 error::Error GLES2DecoderImpl::DoCommands(unsigned int num_commands,
3780 const void* buffer,
3781 int num_entries,
3782 int* entries_processed) {
3783 commands_to_process_ = num_commands;
3759 error::Error result = error::kNoError; 3784 error::Error result = error::kNoError;
3760 if (log_commands()) { 3785 const CommandBufferEntry* cmd_data =
3761 // TODO(notme): Change this to a LOG/VLOG that works in release. Tried 3786 static_cast<const CommandBufferEntry*>(buffer);
3762 // VLOG(1), no luck. 3787 int process_pos = 0;
3763 LOG(ERROR) << "[" << logger_.GetLogPrefix() << "]" << "cmd: " 3788 unsigned int command = 0;
3789
3790 while (process_pos < num_entries && result == error::kNoError &&
3791 commands_to_process_--) {
3792 const unsigned int size = cmd_data->value_header.size;
3793 command = cmd_data->value_header.command;
3794
3795 if (size == 0) {
3796 result = error::kInvalidSize;
3797 break;
3798 }
3799
3800 if (static_cast<int>(size) + process_pos > num_entries) {
3801 result = error::kOutOfBounds;
3802 break;
3803 }
3804
3805 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cb_command"),
3806 GetCommandName(command));
3807
3808 if (log_commands()) {
3809 LOG(ERROR) << "[" << logger_.GetLogPrefix() << "]"
3810 << "cmd: " << GetCommandName(command);
3811 }
3812
3813 const unsigned int arg_count = size - 1;
3814 unsigned int command_index = command - kStartPoint - 1;
3815 if (command_index < arraysize(command_info)) {
3816 const CommandInfo& info = command_info[command_index];
3817 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
3818 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
3819 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) {
3820 bool doing_gpu_trace = false;
3821 if (gpu_trace_commands_) {
3822 if (CMD_FLAG_GET_TRACE_LEVEL(info.cmd_flags) <= gpu_trace_level_) {
3823 doing_gpu_trace = true;
3824 gpu_tracer_->Begin(GetCommandName(command), kTraceDecoder);
3825 }
3826 }
3827
3828 uint32 immediate_data_size = (arg_count - info_arg_count) *
3829 sizeof(CommandBufferEntry); // NOLINT
3830
3831 result = (this->*info.cmd_handler)(immediate_data_size, cmd_data);
3832
3833 if (doing_gpu_trace)
3834 gpu_tracer_->End(kTraceDecoder);
3835
3836 if (debug()) {
3837 GLenum error;
3838 while ((error = glGetError()) != GL_NO_ERROR) {
3839 LOG(ERROR) << "[" << logger_.GetLogPrefix() << "] "
3840 << "GL ERROR: " << GLES2Util::GetStringEnum(error)
3841 << " : " << GetCommandName(command);
3842 LOCAL_SET_GL_ERROR(error, "DoCommand", "GL error from driver");
3843 }
3844 }
3845 } else {
3846 result = error::kInvalidArguments;
3847 }
3848 } else {
3849 result = DoCommonCommand(command, arg_count, cmd_data);
3850 }
3851 if (result == error::kNoError &&
3852 current_decoder_error_ != error::kNoError) {
3853 result = current_decoder_error_;
3854 current_decoder_error_ = error::kNoError;
3855 }
3856
3857 if (result != error::kDeferCommandUntilLater) {
3858 process_pos += size;
3859 cmd_data += size;
3860 }
3861 }
3862
3863 if (entries_processed)
3864 *entries_processed = process_pos;
3865
3866 if (error::IsError(result)) {
3867 LOG(ERROR) << "Error: " << result << " for Command "
3764 << GetCommandName(command); 3868 << GetCommandName(command);
3765 } 3869 }
3766 unsigned int command_index = command - kStartPoint - 1;
3767 if (command_index < arraysize(command_info)) {
3768 const CommandInfo& info = command_info[command_index];
3769 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
3770 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
3771 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) {
3772 bool doing_gpu_trace = false;
3773 if (gpu_trace_commands_) {
3774 if (CMD_FLAG_GET_TRACE_LEVEL(info.cmd_flags) <= gpu_trace_level_) {
3775 doing_gpu_trace = true;
3776 gpu_tracer_->Begin(GetCommandName(command), kTraceDecoder);
3777 }
3778 }
3779 3870
3780 uint32 immediate_data_size =
3781 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT
3782
3783 result = (this->*info.cmd_handler)(immediate_data_size, cmd_data);
3784
3785 if (doing_gpu_trace)
3786 gpu_tracer_->End(kTraceDecoder);
3787
3788 if (debug()) {
3789 GLenum error;
3790 while ((error = glGetError()) != GL_NO_ERROR) {
3791 LOG(ERROR) << "[" << logger_.GetLogPrefix() << "] "
3792 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : "
3793 << GetCommandName(command);
3794 LOCAL_SET_GL_ERROR(error, "DoCommand", "GL error from driver");
3795 }
3796 }
3797 } else {
3798 result = error::kInvalidArguments;
3799 }
3800 } else {
3801 result = DoCommonCommand(command, arg_count, cmd_data);
3802 }
3803 if (result == error::kNoError && current_decoder_error_ != error::kNoError) {
3804 result = current_decoder_error_;
3805 current_decoder_error_ = error::kNoError;
3806 }
3807 return result; 3871 return result;
3808 } 3872 }
3809 3873
3810 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) { 3874 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) {
3811 buffer_manager()->RemoveBuffer(client_id); 3875 buffer_manager()->RemoveBuffer(client_id);
3812 } 3876 }
3813 3877
3814 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { 3878 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) {
3815 if (GetProgram(client_id)) { 3879 if (GetProgram(client_id)) {
3816 return false; 3880 return false;
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after
5691 workarounds().count_all_in_varyings_packing ? 5755 workarounds().count_all_in_varyings_packing ?
5692 Program::kCountAll : Program::kCountOnlyStaticallyUsed, 5756 Program::kCountAll : Program::kCountOnlyStaticallyUsed,
5693 shader_cache_callback_)) { 5757 shader_cache_callback_)) {
5694 if (program == state_.current_program.get()) { 5758 if (program == state_.current_program.get()) {
5695 if (workarounds().use_current_program_after_successful_link) 5759 if (workarounds().use_current_program_after_successful_link)
5696 glUseProgram(program->service_id()); 5760 glUseProgram(program->service_id());
5697 if (workarounds().clear_uniforms_before_first_program_use) 5761 if (workarounds().clear_uniforms_before_first_program_use)
5698 program_manager()->ClearUniforms(program); 5762 program_manager()->ClearUniforms(program);
5699 } 5763 }
5700 } 5764 }
5765
5766 // LinkProgram can be very slow. Exit command processing to allow for
5767 // context preemption and GPU watchdog checks.
5768 ExitCommandProcessingEarly();
5701 }; 5769 };
5702 5770
5703 void GLES2DecoderImpl::DoTexParameterf( 5771 void GLES2DecoderImpl::DoTexParameterf(
5704 GLenum target, GLenum pname, GLfloat param) { 5772 GLenum target, GLenum pname, GLfloat param) {
5705 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( 5773 TextureRef* texture = texture_manager()->GetTextureInfoForTarget(
5706 &state_, target); 5774 &state_, target);
5707 if (!texture) { 5775 if (!texture) {
5708 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); 5776 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture");
5709 return; 5777 return;
5710 } 5778 }
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6819 if (use_shader_translator_) { 6887 if (use_shader_translator_) {
6820 translator = shader->shader_type() == GL_VERTEX_SHADER ? 6888 translator = shader->shader_type() == GL_VERTEX_SHADER ?
6821 vertex_translator_.get() : fragment_translator_.get(); 6889 vertex_translator_.get() : fragment_translator_.get();
6822 } 6890 }
6823 6891
6824 program_manager()->DoCompileShader( 6892 program_manager()->DoCompileShader(
6825 shader, 6893 shader,
6826 translator, 6894 translator,
6827 feature_info_->feature_flags().angle_translated_shader_source ? 6895 feature_info_->feature_flags().angle_translated_shader_source ?
6828 ProgramManager::kANGLE : ProgramManager::kGL); 6896 ProgramManager::kANGLE : ProgramManager::kGL);
6829 }; 6897
6898 // CompileShader can be very slow. Exit command processing to allow for
6899 // context preemption and GPU watchdog checks.
6900 ExitCommandProcessingEarly();
6901 }
6830 6902
6831 void GLES2DecoderImpl::DoGetShaderiv( 6903 void GLES2DecoderImpl::DoGetShaderiv(
6832 GLuint shader_id, GLenum pname, GLint* params) { 6904 GLuint shader_id, GLenum pname, GLint* params) {
6833 Shader* shader = GetShaderInfoNotProgram(shader_id, "glGetShaderiv"); 6905 Shader* shader = GetShaderInfoNotProgram(shader_id, "glGetShaderiv");
6834 if (!shader) { 6906 if (!shader) {
6835 return; 6907 return;
6836 } 6908 }
6837 switch (pname) { 6909 switch (pname) {
6838 case GL_SHADER_SOURCE_LENGTH: 6910 case GL_SHADER_SOURCE_LENGTH:
6839 *params = shader->source() ? shader->source()->size() + 1 : 0; 6911 *params = shader->source() ? shader->source()->size() + 1 : 0;
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
8318 } 8390 }
8319 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); 8391 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D");
8320 glCompressedTexImage2D( 8392 glCompressedTexImage2D(
8321 target, level, internal_format, width, height, border, image_size, data); 8393 target, level, internal_format, width, height, border, image_size, data);
8322 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D"); 8394 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D");
8323 if (error == GL_NO_ERROR) { 8395 if (error == GL_NO_ERROR) {
8324 texture_manager()->SetLevelInfo( 8396 texture_manager()->SetLevelInfo(
8325 texture_ref, target, level, internal_format, 8397 texture_ref, target, level, internal_format,
8326 width, height, 1, border, 0, 0, true); 8398 width, height, 1, border, 0, 0, true);
8327 } 8399 }
8400
8401 // This may be a slow command. Exit command processing to allow for
8402 // context preemption and GPU watchdog checks.
8403 ExitCommandProcessingEarly();
8328 return error::kNoError; 8404 return error::kNoError;
8329 } 8405 }
8330 8406
8331 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D( 8407 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D(
8332 uint32 immediate_data_size, 8408 uint32 immediate_data_size,
8333 const void* cmd_data) { 8409 const void* cmd_data) {
8334 const gles2::cmds::CompressedTexImage2D& c = 8410 const gles2::cmds::CompressedTexImage2D& c =
8335 *static_cast<const gles2::cmds::CompressedTexImage2D*>(cmd_data); 8411 *static_cast<const gles2::cmds::CompressedTexImage2D*>(cmd_data);
8336 GLenum target = static_cast<GLenum>(c.target); 8412 GLenum target = static_cast<GLenum>(c.target);
8337 GLint level = static_cast<GLint>(c.level); 8413 GLint level = static_cast<GLint>(c.level);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
8465 if (!pixels) { 8541 if (!pixels) {
8466 return error::kOutOfBounds; 8542 return error::kOutOfBounds;
8467 } 8543 }
8468 } 8544 }
8469 8545
8470 TextureManager::DoTextImage2DArguments args = { 8546 TextureManager::DoTextImage2DArguments args = {
8471 target, level, internal_format, width, height, border, format, type, 8547 target, level, internal_format, width, height, border, format, type,
8472 pixels, pixels_size}; 8548 pixels, pixels_size};
8473 texture_manager()->ValidateAndDoTexImage2D( 8549 texture_manager()->ValidateAndDoTexImage2D(
8474 &texture_state_, &state_, &framebuffer_state_, args); 8550 &texture_state_, &state_, &framebuffer_state_, args);
8551
8552 // This may be a slow command. Exit command processing to allow for
8553 // context preemption and GPU watchdog checks.
8554 ExitCommandProcessingEarly();
8475 return error::kNoError; 8555 return error::kNoError;
8476 } 8556 }
8477 8557
8478 void GLES2DecoderImpl::DoCompressedTexSubImage2D( 8558 void GLES2DecoderImpl::DoCompressedTexSubImage2D(
8479 GLenum target, 8559 GLenum target,
8480 GLint level, 8560 GLint level,
8481 GLint xoffset, 8561 GLint xoffset,
8482 GLint yoffset, 8562 GLint yoffset,
8483 GLsizei width, 8563 GLsizei width,
8484 GLsizei height, 8564 GLsizei height,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
8523 return; 8603 return;
8524 } 8604 }
8525 8605
8526 8606
8527 // Note: There is no need to deal with texture cleared tracking here 8607 // Note: There is no need to deal with texture cleared tracking here
8528 // because the validation above means you can only get here if the level 8608 // because the validation above means you can only get here if the level
8529 // is already a matching compressed format and in that case 8609 // is already a matching compressed format and in that case
8530 // CompressedTexImage2D already cleared the texture. 8610 // CompressedTexImage2D already cleared the texture.
8531 glCompressedTexSubImage2D( 8611 glCompressedTexSubImage2D(
8532 target, level, xoffset, yoffset, width, height, format, image_size, data); 8612 target, level, xoffset, yoffset, width, height, format, image_size, data);
8613
8614 // This may be a slow command. Exit command processing to allow for
8615 // context preemption and GPU watchdog checks.
8616 ExitCommandProcessingEarly();
8533 } 8617 }
8534 8618
8535 static void Clip( 8619 static void Clip(
8536 GLint start, GLint range, GLint sourceRange, 8620 GLint start, GLint range, GLint sourceRange,
8537 GLint* out_start, GLint* out_range) { 8621 GLint* out_start, GLint* out_range) {
8538 DCHECK(out_start); 8622 DCHECK(out_start);
8539 DCHECK(out_range); 8623 DCHECK(out_range);
8540 if (start < 0) { 8624 if (start < 0) {
8541 range += start; 8625 range += start;
8542 start = 0; 8626 start = 0;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
8668 ScopedModifyPixels modify(texture_ref); 8752 ScopedModifyPixels modify(texture_ref);
8669 glCopyTexImage2D(target, level, internal_format, 8753 glCopyTexImage2D(target, level, internal_format,
8670 copyX, copyY, copyWidth, copyHeight, border); 8754 copyX, copyY, copyWidth, copyHeight, border);
8671 } 8755 }
8672 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); 8756 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D");
8673 if (error == GL_NO_ERROR) { 8757 if (error == GL_NO_ERROR) {
8674 texture_manager()->SetLevelInfo( 8758 texture_manager()->SetLevelInfo(
8675 texture_ref, target, level, internal_format, width, height, 1, 8759 texture_ref, target, level, internal_format, width, height, 1,
8676 border, internal_format, GL_UNSIGNED_BYTE, true); 8760 border, internal_format, GL_UNSIGNED_BYTE, true);
8677 } 8761 }
8762
8763 // This may be a slow command. Exit command processing to allow for
8764 // context preemption and GPU watchdog checks.
8765 ExitCommandProcessingEarly();
8678 } 8766 }
8679 8767
8680 void GLES2DecoderImpl::DoCopyTexSubImage2D( 8768 void GLES2DecoderImpl::DoCopyTexSubImage2D(
8681 GLenum target, 8769 GLenum target,
8682 GLint level, 8770 GLint level,
8683 GLint xoffset, 8771 GLint xoffset,
8684 GLint yoffset, 8772 GLint yoffset,
8685 GLint x, 8773 GLint x,
8686 GLint y, 8774 GLint y,
8687 GLsizei width, 8775 GLsizei width,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
8778 if (copyHeight > 0 && copyWidth > 0) { 8866 if (copyHeight > 0 && copyWidth > 0) {
8779 GLint dx = copyX - x; 8867 GLint dx = copyX - x;
8780 GLint dy = copyY - y; 8868 GLint dy = copyY - y;
8781 GLint destX = xoffset + dx; 8869 GLint destX = xoffset + dx;
8782 GLint destY = yoffset + dy; 8870 GLint destY = yoffset + dy;
8783 ScopedModifyPixels modify(texture_ref); 8871 ScopedModifyPixels modify(texture_ref);
8784 glCopyTexSubImage2D(target, level, 8872 glCopyTexSubImage2D(target, level,
8785 destX, destY, copyX, copyY, 8873 destX, destY, copyX, copyY,
8786 copyWidth, copyHeight); 8874 copyWidth, copyHeight);
8787 } 8875 }
8876
8877 // This may be a slow command. Exit command processing to allow for
8878 // context preemption and GPU watchdog checks.
8879 ExitCommandProcessingEarly();
8788 } 8880 }
8789 8881
8790 bool GLES2DecoderImpl::ValidateTexSubImage2D( 8882 bool GLES2DecoderImpl::ValidateTexSubImage2D(
8791 error::Error* error, 8883 error::Error* error,
8792 const char* function_name, 8884 const char* function_name,
8793 GLenum target, 8885 GLenum target,
8794 GLint level, 8886 GLint level,
8795 GLint xoffset, 8887 GLint xoffset,
8796 GLint yoffset, 8888 GLint yoffset,
8797 GLsizei width, 8889 GLsizei width,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
8908 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need 9000 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need
8909 // to look it up. 9001 // to look it up.
8910 glTexImage2D( 9002 glTexImage2D(
8911 target, level, internal_format, width, height, 0, format, type, data); 9003 target, level, internal_format, width, height, 0, format, type, data);
8912 } else { 9004 } else {
8913 ScopedTextureUploadTimer timer(&texture_state_); 9005 ScopedTextureUploadTimer timer(&texture_state_);
8914 glTexSubImage2D( 9006 glTexSubImage2D(
8915 target, level, xoffset, yoffset, width, height, format, type, data); 9007 target, level, xoffset, yoffset, width, height, format, type, data);
8916 } 9008 }
8917 texture_manager()->SetLevelCleared(texture_ref, target, level, true); 9009 texture_manager()->SetLevelCleared(texture_ref, target, level, true);
9010
9011 // This may be a slow command. Exit command processing to allow for
9012 // context preemption and GPU watchdog checks.
9013 ExitCommandProcessingEarly();
8918 return error::kNoError; 9014 return error::kNoError;
8919 } 9015 }
8920 9016
8921 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32 immediate_data_size, 9017 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32 immediate_data_size,
8922 const void* cmd_data) { 9018 const void* cmd_data) {
8923 const gles2::cmds::TexSubImage2D& c = 9019 const gles2::cmds::TexSubImage2D& c =
8924 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); 9020 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data);
8925 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D", 9021 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D",
8926 "width", c.width, "height", c.height); 9022 "width", c.width, "height", c.height);
8927 GLboolean internal = static_cast<GLboolean>(c.internal); 9023 GLboolean internal = static_cast<GLboolean>(c.internal);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
9394 // single D3D device for all contexts. 9490 // single D3D device for all contexts.
9395 if (!feature_info_->feature_flags().is_angle) 9491 if (!feature_info_->feature_flags().is_angle)
9396 glFlush(); 9492 glFlush();
9397 } 9493 }
9398 } else { 9494 } else {
9399 if (!surface_->SwapBuffers()) { 9495 if (!surface_->SwapBuffers()) {
9400 LOG(ERROR) << "Context lost because SwapBuffers failed."; 9496 LOG(ERROR) << "Context lost because SwapBuffers failed.";
9401 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 9497 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
9402 } 9498 }
9403 } 9499 }
9500
9501 // This may be a slow command. Exit command processing to allow for
9502 // context preemption and GPU watchdog checks.
9503 ExitCommandProcessingEarly();
9404 } 9504 }
9405 9505
9406 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( 9506 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM(
9407 uint32 immediate_data_size, 9507 uint32 immediate_data_size,
9408 const void* cmd_data) { 9508 const void* cmd_data) {
9409 const gles2::cmds::EnableFeatureCHROMIUM& c = 9509 const gles2::cmds::EnableFeatureCHROMIUM& c =
9410 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data); 9510 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data);
9411 Bucket* bucket = GetBucket(c.bucket_id); 9511 Bucket* bucket = GetBucket(c.bucket_id);
9412 if (!bucket || bucket->size() == 0) { 9512 if (!bucket || bucket->size() == 0) {
9413 return error::kInvalidArguments; 9513 return error::kInvalidArguments;
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
11163 } 11263 }
11164 } 11264 }
11165 11265
11166 // Include the auto-generated part of this file. We split this because it means 11266 // Include the auto-generated part of this file. We split this because it means
11167 // we can easily edit the non-auto generated parts right here in this file 11267 // we can easily edit the non-auto generated parts right here in this file
11168 // instead of having to edit some template or the code generator. 11268 // instead of having to edit some template or the code generator.
11169 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11269 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11170 11270
11171 } // namespace gles2 11271 } // namespace gles2
11172 } // namespace gpu 11272 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/common_decoder_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698