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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 |
3764 << GetCommandName(command); | 3789 while (process_pos < num_entries && result == error::kNoError && |
3790 commands_to_process_--) { | |
3791 CommandHeader header = cmd_data->value_header; | |
3792 if (header.size == 0) { | |
piman
2014/09/09 00:59:01
nit: It was already before, but it's easier to see
vmiura
2014/09/09 01:38:56
Done.
| |
3793 DVLOG(1) << "Error: zero sized command in command buffer"; | |
3794 if (entries_processed) | |
3795 *entries_processed = process_pos; | |
3796 return error::kInvalidSize; | |
3797 } | |
3798 | |
3799 if (static_cast<int>(header.size) + process_pos > num_entries) { | |
3800 DVLOG(1) << "Error: get offset out of bounds"; | |
3801 if (entries_processed) | |
3802 *entries_processed = process_pos; | |
3803 return error::kOutOfBounds; | |
3804 } | |
3805 | |
3806 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cb_command"), | |
3807 GetCommandName(header.command)); | |
3808 | |
3809 { | |
piman
2014/09/09 00:59:01
nit: do you need this scope? I don't think you're
vmiura
2014/09/09 01:38:56
Done.
| |
3810 const unsigned int command = header.command; | |
3811 const unsigned int arg_count = header.size - 1; | |
3812 | |
3813 if (log_commands()) { | |
3814 // TODO(notme): Change this to a LOG/VLOG that works in release. Tried | |
3815 // VLOG(1), no luck. | |
3816 LOG(ERROR) << "[" << logger_.GetLogPrefix() << "]" | |
3817 << "cmd: " << GetCommandName(command); | |
3818 } | |
3819 unsigned int command_index = command - kStartPoint - 1; | |
3820 if (command_index < arraysize(command_info)) { | |
3821 const CommandInfo& info = command_info[command_index]; | |
3822 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); | |
3823 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || | |
3824 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { | |
3825 bool doing_gpu_trace = false; | |
3826 if (gpu_trace_commands_) { | |
3827 if (CMD_FLAG_GET_TRACE_LEVEL(info.cmd_flags) <= gpu_trace_level_) { | |
3828 doing_gpu_trace = true; | |
3829 gpu_tracer_->Begin(GetCommandName(command), kTraceDecoder); | |
3830 } | |
3831 } | |
3832 | |
3833 uint32 immediate_data_size = (arg_count - info_arg_count) * | |
3834 sizeof(CommandBufferEntry); // NOLINT | |
3835 | |
3836 result = (this->*info.cmd_handler)(immediate_data_size, cmd_data); | |
3837 | |
3838 if (doing_gpu_trace) | |
3839 gpu_tracer_->End(kTraceDecoder); | |
3840 | |
3841 if (debug()) { | |
3842 GLenum error; | |
3843 while ((error = glGetError()) != GL_NO_ERROR) { | |
3844 LOG(ERROR) << "[" << logger_.GetLogPrefix() << "] " | |
3845 << "GL ERROR: " << GLES2Util::GetStringEnum(error) | |
3846 << " : " << GetCommandName(command); | |
3847 LOCAL_SET_GL_ERROR(error, "DoCommand", "GL error from driver"); | |
3848 } | |
3849 } | |
3850 } else { | |
3851 result = error::kInvalidArguments; | |
3852 } | |
3853 } else { | |
3854 result = DoCommonCommand(command, arg_count, cmd_data); | |
3855 } | |
3856 if (result == error::kNoError && | |
3857 current_decoder_error_ != error::kNoError) { | |
3858 result = current_decoder_error_; | |
3859 current_decoder_error_ = error::kNoError; | |
3860 } | |
3861 } | |
3862 | |
3863 if (result != error::kDeferCommandUntilLater) { | |
3864 process_pos += header.size; | |
3865 cmd_data += header.size; | |
3866 } | |
3765 } | 3867 } |
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 | 3868 |
3780 uint32 immediate_data_size = | 3869 if (entries_processed) |
3781 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT | 3870 *entries_processed = process_pos; |
3782 | 3871 |
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; | 3872 return result; |
3808 } | 3873 } |
3809 | 3874 |
3810 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) { | 3875 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) { |
3811 buffer_manager()->RemoveBuffer(client_id); | 3876 buffer_manager()->RemoveBuffer(client_id); |
3812 } | 3877 } |
3813 | 3878 |
3814 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { | 3879 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { |
3815 if (GetProgram(client_id)) { | 3880 if (GetProgram(client_id)) { |
3816 return false; | 3881 return false; |
(...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5691 workarounds().count_all_in_varyings_packing ? | 5756 workarounds().count_all_in_varyings_packing ? |
5692 Program::kCountAll : Program::kCountOnlyStaticallyUsed, | 5757 Program::kCountAll : Program::kCountOnlyStaticallyUsed, |
5693 shader_cache_callback_)) { | 5758 shader_cache_callback_)) { |
5694 if (program == state_.current_program.get()) { | 5759 if (program == state_.current_program.get()) { |
5695 if (workarounds().use_current_program_after_successful_link) | 5760 if (workarounds().use_current_program_after_successful_link) |
5696 glUseProgram(program->service_id()); | 5761 glUseProgram(program->service_id()); |
5697 if (workarounds().clear_uniforms_before_first_program_use) | 5762 if (workarounds().clear_uniforms_before_first_program_use) |
5698 program_manager()->ClearUniforms(program); | 5763 program_manager()->ClearUniforms(program); |
5699 } | 5764 } |
5700 } | 5765 } |
5766 | |
5767 // LinkProgram can be very slow. Exit command processing to allow for | |
5768 // context preemption and GPU watchdog checks. | |
5769 ExitCommandProcessingEarly(); | |
5701 }; | 5770 }; |
5702 | 5771 |
5703 void GLES2DecoderImpl::DoTexParameterf( | 5772 void GLES2DecoderImpl::DoTexParameterf( |
5704 GLenum target, GLenum pname, GLfloat param) { | 5773 GLenum target, GLenum pname, GLfloat param) { |
5705 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( | 5774 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( |
5706 &state_, target); | 5775 &state_, target); |
5707 if (!texture) { | 5776 if (!texture) { |
5708 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); | 5777 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); |
5709 return; | 5778 return; |
5710 } | 5779 } |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6819 if (use_shader_translator_) { | 6888 if (use_shader_translator_) { |
6820 translator = shader->shader_type() == GL_VERTEX_SHADER ? | 6889 translator = shader->shader_type() == GL_VERTEX_SHADER ? |
6821 vertex_translator_.get() : fragment_translator_.get(); | 6890 vertex_translator_.get() : fragment_translator_.get(); |
6822 } | 6891 } |
6823 | 6892 |
6824 program_manager()->DoCompileShader( | 6893 program_manager()->DoCompileShader( |
6825 shader, | 6894 shader, |
6826 translator, | 6895 translator, |
6827 feature_info_->feature_flags().angle_translated_shader_source ? | 6896 feature_info_->feature_flags().angle_translated_shader_source ? |
6828 ProgramManager::kANGLE : ProgramManager::kGL); | 6897 ProgramManager::kANGLE : ProgramManager::kGL); |
6829 }; | 6898 |
6899 // CompileShader can be very slow. Exit command processing to allow for | |
6900 // context preemption and GPU watchdog checks. | |
6901 ExitCommandProcessingEarly(); | |
6902 } | |
6830 | 6903 |
6831 void GLES2DecoderImpl::DoGetShaderiv( | 6904 void GLES2DecoderImpl::DoGetShaderiv( |
6832 GLuint shader_id, GLenum pname, GLint* params) { | 6905 GLuint shader_id, GLenum pname, GLint* params) { |
6833 Shader* shader = GetShaderInfoNotProgram(shader_id, "glGetShaderiv"); | 6906 Shader* shader = GetShaderInfoNotProgram(shader_id, "glGetShaderiv"); |
6834 if (!shader) { | 6907 if (!shader) { |
6835 return; | 6908 return; |
6836 } | 6909 } |
6837 switch (pname) { | 6910 switch (pname) { |
6838 case GL_SHADER_SOURCE_LENGTH: | 6911 case GL_SHADER_SOURCE_LENGTH: |
6839 *params = shader->source() ? shader->source()->size() + 1 : 0; | 6912 *params = shader->source() ? shader->source()->size() + 1 : 0; |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8318 } | 8391 } |
8319 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); | 8392 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); |
8320 glCompressedTexImage2D( | 8393 glCompressedTexImage2D( |
8321 target, level, internal_format, width, height, border, image_size, data); | 8394 target, level, internal_format, width, height, border, image_size, data); |
8322 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D"); | 8395 GLenum error = LOCAL_PEEK_GL_ERROR("glCompressedTexImage2D"); |
8323 if (error == GL_NO_ERROR) { | 8396 if (error == GL_NO_ERROR) { |
8324 texture_manager()->SetLevelInfo( | 8397 texture_manager()->SetLevelInfo( |
8325 texture_ref, target, level, internal_format, | 8398 texture_ref, target, level, internal_format, |
8326 width, height, 1, border, 0, 0, true); | 8399 width, height, 1, border, 0, 0, true); |
8327 } | 8400 } |
8401 | |
8402 // This may be a slow command. Exit command processing to allow for | |
8403 // context preemption and GPU watchdog checks. | |
8404 ExitCommandProcessingEarly(); | |
8328 return error::kNoError; | 8405 return error::kNoError; |
8329 } | 8406 } |
8330 | 8407 |
8331 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D( | 8408 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D( |
8332 uint32 immediate_data_size, | 8409 uint32 immediate_data_size, |
8333 const void* cmd_data) { | 8410 const void* cmd_data) { |
8334 const gles2::cmds::CompressedTexImage2D& c = | 8411 const gles2::cmds::CompressedTexImage2D& c = |
8335 *static_cast<const gles2::cmds::CompressedTexImage2D*>(cmd_data); | 8412 *static_cast<const gles2::cmds::CompressedTexImage2D*>(cmd_data); |
8336 GLenum target = static_cast<GLenum>(c.target); | 8413 GLenum target = static_cast<GLenum>(c.target); |
8337 GLint level = static_cast<GLint>(c.level); | 8414 GLint level = static_cast<GLint>(c.level); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8465 if (!pixels) { | 8542 if (!pixels) { |
8466 return error::kOutOfBounds; | 8543 return error::kOutOfBounds; |
8467 } | 8544 } |
8468 } | 8545 } |
8469 | 8546 |
8470 TextureManager::DoTextImage2DArguments args = { | 8547 TextureManager::DoTextImage2DArguments args = { |
8471 target, level, internal_format, width, height, border, format, type, | 8548 target, level, internal_format, width, height, border, format, type, |
8472 pixels, pixels_size}; | 8549 pixels, pixels_size}; |
8473 texture_manager()->ValidateAndDoTexImage2D( | 8550 texture_manager()->ValidateAndDoTexImage2D( |
8474 &texture_state_, &state_, &framebuffer_state_, args); | 8551 &texture_state_, &state_, &framebuffer_state_, args); |
8552 | |
8553 // This may be a slow command. Exit command processing to allow for | |
8554 // context preemption and GPU watchdog checks. | |
8555 ExitCommandProcessingEarly(); | |
8475 return error::kNoError; | 8556 return error::kNoError; |
8476 } | 8557 } |
8477 | 8558 |
8478 void GLES2DecoderImpl::DoCompressedTexSubImage2D( | 8559 void GLES2DecoderImpl::DoCompressedTexSubImage2D( |
8479 GLenum target, | 8560 GLenum target, |
8480 GLint level, | 8561 GLint level, |
8481 GLint xoffset, | 8562 GLint xoffset, |
8482 GLint yoffset, | 8563 GLint yoffset, |
8483 GLsizei width, | 8564 GLsizei width, |
8484 GLsizei height, | 8565 GLsizei height, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8523 return; | 8604 return; |
8524 } | 8605 } |
8525 | 8606 |
8526 | 8607 |
8527 // Note: There is no need to deal with texture cleared tracking here | 8608 // 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 | 8609 // because the validation above means you can only get here if the level |
8529 // is already a matching compressed format and in that case | 8610 // is already a matching compressed format and in that case |
8530 // CompressedTexImage2D already cleared the texture. | 8611 // CompressedTexImage2D already cleared the texture. |
8531 glCompressedTexSubImage2D( | 8612 glCompressedTexSubImage2D( |
8532 target, level, xoffset, yoffset, width, height, format, image_size, data); | 8613 target, level, xoffset, yoffset, width, height, format, image_size, data); |
8614 | |
8615 // This may be a slow command. Exit command processing to allow for | |
8616 // context preemption and GPU watchdog checks. | |
8617 ExitCommandProcessingEarly(); | |
8533 } | 8618 } |
8534 | 8619 |
8535 static void Clip( | 8620 static void Clip( |
8536 GLint start, GLint range, GLint sourceRange, | 8621 GLint start, GLint range, GLint sourceRange, |
8537 GLint* out_start, GLint* out_range) { | 8622 GLint* out_start, GLint* out_range) { |
8538 DCHECK(out_start); | 8623 DCHECK(out_start); |
8539 DCHECK(out_range); | 8624 DCHECK(out_range); |
8540 if (start < 0) { | 8625 if (start < 0) { |
8541 range += start; | 8626 range += start; |
8542 start = 0; | 8627 start = 0; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8668 ScopedModifyPixels modify(texture_ref); | 8753 ScopedModifyPixels modify(texture_ref); |
8669 glCopyTexImage2D(target, level, internal_format, | 8754 glCopyTexImage2D(target, level, internal_format, |
8670 copyX, copyY, copyWidth, copyHeight, border); | 8755 copyX, copyY, copyWidth, copyHeight, border); |
8671 } | 8756 } |
8672 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); | 8757 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); |
8673 if (error == GL_NO_ERROR) { | 8758 if (error == GL_NO_ERROR) { |
8674 texture_manager()->SetLevelInfo( | 8759 texture_manager()->SetLevelInfo( |
8675 texture_ref, target, level, internal_format, width, height, 1, | 8760 texture_ref, target, level, internal_format, width, height, 1, |
8676 border, internal_format, GL_UNSIGNED_BYTE, true); | 8761 border, internal_format, GL_UNSIGNED_BYTE, true); |
8677 } | 8762 } |
8763 | |
8764 // This may be a slow command. Exit command processing to allow for | |
8765 // context preemption and GPU watchdog checks. | |
8766 ExitCommandProcessingEarly(); | |
8678 } | 8767 } |
8679 | 8768 |
8680 void GLES2DecoderImpl::DoCopyTexSubImage2D( | 8769 void GLES2DecoderImpl::DoCopyTexSubImage2D( |
8681 GLenum target, | 8770 GLenum target, |
8682 GLint level, | 8771 GLint level, |
8683 GLint xoffset, | 8772 GLint xoffset, |
8684 GLint yoffset, | 8773 GLint yoffset, |
8685 GLint x, | 8774 GLint x, |
8686 GLint y, | 8775 GLint y, |
8687 GLsizei width, | 8776 GLsizei width, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8778 if (copyHeight > 0 && copyWidth > 0) { | 8867 if (copyHeight > 0 && copyWidth > 0) { |
8779 GLint dx = copyX - x; | 8868 GLint dx = copyX - x; |
8780 GLint dy = copyY - y; | 8869 GLint dy = copyY - y; |
8781 GLint destX = xoffset + dx; | 8870 GLint destX = xoffset + dx; |
8782 GLint destY = yoffset + dy; | 8871 GLint destY = yoffset + dy; |
8783 ScopedModifyPixels modify(texture_ref); | 8872 ScopedModifyPixels modify(texture_ref); |
8784 glCopyTexSubImage2D(target, level, | 8873 glCopyTexSubImage2D(target, level, |
8785 destX, destY, copyX, copyY, | 8874 destX, destY, copyX, copyY, |
8786 copyWidth, copyHeight); | 8875 copyWidth, copyHeight); |
8787 } | 8876 } |
8877 | |
8878 // This may be a slow command. Exit command processing to allow for | |
8879 // context preemption and GPU watchdog checks. | |
8880 ExitCommandProcessingEarly(); | |
8788 } | 8881 } |
8789 | 8882 |
8790 bool GLES2DecoderImpl::ValidateTexSubImage2D( | 8883 bool GLES2DecoderImpl::ValidateTexSubImage2D( |
8791 error::Error* error, | 8884 error::Error* error, |
8792 const char* function_name, | 8885 const char* function_name, |
8793 GLenum target, | 8886 GLenum target, |
8794 GLint level, | 8887 GLint level, |
8795 GLint xoffset, | 8888 GLint xoffset, |
8796 GLint yoffset, | 8889 GLint yoffset, |
8797 GLsizei width, | 8890 GLsizei width, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8908 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need | 9001 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need |
8909 // to look it up. | 9002 // to look it up. |
8910 glTexImage2D( | 9003 glTexImage2D( |
8911 target, level, internal_format, width, height, 0, format, type, data); | 9004 target, level, internal_format, width, height, 0, format, type, data); |
8912 } else { | 9005 } else { |
8913 ScopedTextureUploadTimer timer(&texture_state_); | 9006 ScopedTextureUploadTimer timer(&texture_state_); |
8914 glTexSubImage2D( | 9007 glTexSubImage2D( |
8915 target, level, xoffset, yoffset, width, height, format, type, data); | 9008 target, level, xoffset, yoffset, width, height, format, type, data); |
8916 } | 9009 } |
8917 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 9010 texture_manager()->SetLevelCleared(texture_ref, target, level, true); |
9011 | |
9012 // This may be a slow command. Exit command processing to allow for | |
9013 // context preemption and GPU watchdog checks. | |
9014 ExitCommandProcessingEarly(); | |
8918 return error::kNoError; | 9015 return error::kNoError; |
8919 } | 9016 } |
8920 | 9017 |
8921 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32 immediate_data_size, | 9018 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32 immediate_data_size, |
8922 const void* cmd_data) { | 9019 const void* cmd_data) { |
8923 const gles2::cmds::TexSubImage2D& c = | 9020 const gles2::cmds::TexSubImage2D& c = |
8924 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); | 9021 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); |
8925 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D", | 9022 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D", |
8926 "width", c.width, "height", c.height); | 9023 "width", c.width, "height", c.height); |
8927 GLboolean internal = static_cast<GLboolean>(c.internal); | 9024 GLboolean internal = static_cast<GLboolean>(c.internal); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9394 // single D3D device for all contexts. | 9491 // single D3D device for all contexts. |
9395 if (!feature_info_->feature_flags().is_angle) | 9492 if (!feature_info_->feature_flags().is_angle) |
9396 glFlush(); | 9493 glFlush(); |
9397 } | 9494 } |
9398 } else { | 9495 } else { |
9399 if (!surface_->SwapBuffers()) { | 9496 if (!surface_->SwapBuffers()) { |
9400 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 9497 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
9401 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 9498 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
9402 } | 9499 } |
9403 } | 9500 } |
9501 | |
9502 // This may be a slow command. Exit command processing to allow for | |
9503 // context preemption and GPU watchdog checks. | |
9504 ExitCommandProcessingEarly(); | |
9404 } | 9505 } |
9405 | 9506 |
9406 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( | 9507 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( |
9407 uint32 immediate_data_size, | 9508 uint32 immediate_data_size, |
9408 const void* cmd_data) { | 9509 const void* cmd_data) { |
9409 const gles2::cmds::EnableFeatureCHROMIUM& c = | 9510 const gles2::cmds::EnableFeatureCHROMIUM& c = |
9410 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data); | 9511 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data); |
9411 Bucket* bucket = GetBucket(c.bucket_id); | 9512 Bucket* bucket = GetBucket(c.bucket_id); |
9412 if (!bucket || bucket->size() == 0) { | 9513 if (!bucket || bucket->size() == 0) { |
9413 return error::kInvalidArguments; | 9514 return error::kInvalidArguments; |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11163 } | 11264 } |
11164 } | 11265 } |
11165 | 11266 |
11166 // Include the auto-generated part of this file. We split this because it means | 11267 // 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 | 11268 // 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. | 11269 // instead of having to edit some template or the code generator. |
11169 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11270 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11170 | 11271 |
11171 } // namespace gles2 | 11272 } // namespace gles2 |
11172 } // namespace gpu | 11273 } // namespace gpu |
OLD | NEW |