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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 void EndDecoding() override; | 645 void EndDecoding() override; |
646 | 646 |
647 ErrorState* GetErrorState() override; | 647 ErrorState* GetErrorState() override; |
648 const ContextState* GetContextState() override { return &state_; } | 648 const ContextState* GetContextState() override { return &state_; } |
649 | 649 |
650 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; | 650 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; |
651 void SetFenceSyncReleaseCallback( | 651 void SetFenceSyncReleaseCallback( |
652 const FenceSyncReleaseCallback& callback) override; | 652 const FenceSyncReleaseCallback& callback) override; |
653 void SetWaitFenceSyncCallback(const WaitFenceSyncCallback& callback) override; | 653 void SetWaitFenceSyncCallback(const WaitFenceSyncCallback& callback) override; |
654 | 654 |
655 void SetDescheduleUntilFinishedCallback( | |
656 const NoParamCallback& callback) override; | |
657 void SetRescheduleAfterFinishedCallback( | |
658 const NoParamCallback& callback) override; | |
659 | |
655 void SetIgnoreCachedStateForTest(bool ignore) override; | 660 void SetIgnoreCachedStateForTest(bool ignore) override; |
656 void SetForceShaderNameHashingForTest(bool force) override; | 661 void SetForceShaderNameHashingForTest(bool force) override; |
657 uint32_t GetAndClearBackbufferClearBitsForTest() override; | 662 uint32_t GetAndClearBackbufferClearBitsForTest() override; |
658 void ProcessFinishedAsyncTransfers(); | 663 void ProcessFinishedAsyncTransfers(); |
659 | 664 |
660 bool GetServiceTextureId(uint32_t client_texture_id, | 665 bool GetServiceTextureId(uint32_t client_texture_id, |
661 uint32_t* service_texture_id) override; | 666 uint32_t* service_texture_id) override; |
662 | 667 |
663 uint32_t GetTextureUploadCount() override; | 668 uint32_t GetTextureUploadCount() override; |
664 base::TimeDelta GetTotalTextureUploadTime() override; | 669 base::TimeDelta GetTotalTextureUploadTime() override; |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1955 back_buffer_color_format_ == GL_RGBA8); | 1960 back_buffer_color_format_ == GL_RGBA8); |
1956 } | 1961 } |
1957 | 1962 |
1958 // Set remaining commands to process to 0 to force DoCommands to return | 1963 // Set remaining commands to process to 0 to force DoCommands to return |
1959 // and allow context preemption and GPU watchdog checks in CommandExecutor(). | 1964 // and allow context preemption and GPU watchdog checks in CommandExecutor(). |
1960 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } | 1965 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } |
1961 | 1966 |
1962 void ProcessPendingReadPixels(bool did_finish); | 1967 void ProcessPendingReadPixels(bool did_finish); |
1963 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); | 1968 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); |
1964 | 1969 |
1970 // Checks to see if the inserted fence has completed. | |
1971 void ProcessDescheduleUntilFinished(); | |
1972 | |
1965 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, | 1973 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, |
1966 GLint location, | 1974 GLint location, |
1967 const std::string& name); | 1975 const std::string& name); |
1968 | 1976 |
1969 // If |texture_manager_version_| doesn't match the current version, then this | 1977 // If |texture_manager_version_| doesn't match the current version, then this |
1970 // will rebind all external textures to match their current service_id. | 1978 // will rebind all external textures to match their current service_id. |
1971 void RestoreAllExternalTextureBindingsIfNeeded() override; | 1979 void RestoreAllExternalTextureBindingsIfNeeded() override; |
1972 | 1980 |
1973 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit); | 1981 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit); |
1974 | 1982 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2094 GLenum offscreen_saved_color_format_; | 2102 GLenum offscreen_saved_color_format_; |
2095 | 2103 |
2096 std::unique_ptr<QueryManager> query_manager_; | 2104 std::unique_ptr<QueryManager> query_manager_; |
2097 | 2105 |
2098 std::unique_ptr<VertexArrayManager> vertex_array_manager_; | 2106 std::unique_ptr<VertexArrayManager> vertex_array_manager_; |
2099 | 2107 |
2100 std::unique_ptr<ImageManager> image_manager_; | 2108 std::unique_ptr<ImageManager> image_manager_; |
2101 | 2109 |
2102 FenceSyncReleaseCallback fence_sync_release_callback_; | 2110 FenceSyncReleaseCallback fence_sync_release_callback_; |
2103 WaitFenceSyncCallback wait_fence_sync_callback_; | 2111 WaitFenceSyncCallback wait_fence_sync_callback_; |
2112 NoParamCallback deschedule_until_finished_callback_; | |
2113 NoParamCallback reschedule_after_finished_callback_; | |
2104 | 2114 |
2105 ShaderCacheCallback shader_cache_callback_; | 2115 ShaderCacheCallback shader_cache_callback_; |
2106 | 2116 |
2107 // The format of the back buffer_ | 2117 // The format of the back buffer_ |
2108 GLenum back_buffer_color_format_; | 2118 GLenum back_buffer_color_format_; |
2109 bool back_buffer_has_depth_; | 2119 bool back_buffer_has_depth_; |
2110 bool back_buffer_has_stencil_; | 2120 bool back_buffer_has_stencil_; |
2111 | 2121 |
2112 // Tracks read buffer and draw buffer for backbuffer, whether it's onscreen | 2122 // Tracks read buffer and draw buffer for backbuffer, whether it's onscreen |
2113 // or offscreen. | 2123 // or offscreen. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2189 | 2199 |
2190 std::unique_ptr<GPUTracer> gpu_tracer_; | 2200 std::unique_ptr<GPUTracer> gpu_tracer_; |
2191 std::unique_ptr<GPUStateTracer> gpu_state_tracer_; | 2201 std::unique_ptr<GPUStateTracer> gpu_state_tracer_; |
2192 const unsigned char* gpu_decoder_category_; | 2202 const unsigned char* gpu_decoder_category_; |
2193 int gpu_trace_level_; | 2203 int gpu_trace_level_; |
2194 bool gpu_trace_commands_; | 2204 bool gpu_trace_commands_; |
2195 bool gpu_debug_commands_; | 2205 bool gpu_debug_commands_; |
2196 | 2206 |
2197 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; | 2207 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; |
2198 | 2208 |
2209 // After this fence is inserted, both the GpuChannelMessageQueue and | |
2210 // CommandExecutor are descheduled. Once the fence has completed, both get | |
2211 // rescheduled. | |
2212 std::unique_ptr<gl::GLFence> deschedule_until_finished_fence_; | |
2213 | |
2199 // Used to validate multisample renderbuffers if needed | 2214 // Used to validate multisample renderbuffers if needed |
2200 GLuint validation_texture_; | 2215 GLuint validation_texture_; |
2201 GLuint validation_fbo_multisample_; | 2216 GLuint validation_fbo_multisample_; |
2202 GLuint validation_fbo_; | 2217 GLuint validation_fbo_; |
2203 | 2218 |
2204 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( | 2219 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( |
2205 uint32_t immediate_data_size, | 2220 uint32_t immediate_data_size, |
2206 const void* data); | 2221 const void* data); |
2207 | 2222 |
2208 // A struct to hold info about each command. | 2223 // A struct to hold info about each command. |
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4170 void GLES2DecoderImpl::SetFenceSyncReleaseCallback( | 4185 void GLES2DecoderImpl::SetFenceSyncReleaseCallback( |
4171 const FenceSyncReleaseCallback& callback) { | 4186 const FenceSyncReleaseCallback& callback) { |
4172 fence_sync_release_callback_ = callback; | 4187 fence_sync_release_callback_ = callback; |
4173 } | 4188 } |
4174 | 4189 |
4175 void GLES2DecoderImpl::SetWaitFenceSyncCallback( | 4190 void GLES2DecoderImpl::SetWaitFenceSyncCallback( |
4176 const WaitFenceSyncCallback& callback) { | 4191 const WaitFenceSyncCallback& callback) { |
4177 wait_fence_sync_callback_ = callback; | 4192 wait_fence_sync_callback_ = callback; |
4178 } | 4193 } |
4179 | 4194 |
4195 void GLES2DecoderImpl::SetDescheduleUntilFinishedCallback( | |
4196 const NoParamCallback& callback) { | |
4197 deschedule_until_finished_callback_ = callback; | |
4198 } | |
4199 | |
4200 void GLES2DecoderImpl::SetRescheduleAfterFinishedCallback( | |
4201 const NoParamCallback& callback) { | |
4202 reschedule_after_finished_callback_ = callback; | |
4203 } | |
4204 | |
4180 bool GLES2DecoderImpl::GetServiceTextureId(uint32_t client_texture_id, | 4205 bool GLES2DecoderImpl::GetServiceTextureId(uint32_t client_texture_id, |
4181 uint32_t* service_texture_id) { | 4206 uint32_t* service_texture_id) { |
4182 TextureRef* texture_ref = texture_manager()->GetTexture(client_texture_id); | 4207 TextureRef* texture_ref = texture_manager()->GetTexture(client_texture_id); |
4183 if (texture_ref) { | 4208 if (texture_ref) { |
4184 *service_texture_id = texture_ref->service_id(); | 4209 *service_texture_id = texture_ref->service_id(); |
4185 return true; | 4210 return true; |
4186 } | 4211 } |
4187 return false; | 4212 return false; |
4188 } | 4213 } |
4189 | 4214 |
(...skipping 9456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13646 default: | 13671 default: |
13647 NOTREACHED(); | 13672 NOTREACHED(); |
13648 return false; | 13673 return false; |
13649 } | 13674 } |
13650 reset_by_robustness_extension_ = true; | 13675 reset_by_robustness_extension_ = true; |
13651 return true; | 13676 return true; |
13652 } | 13677 } |
13653 return false; | 13678 return false; |
13654 } | 13679 } |
13655 | 13680 |
13681 error::Error GLES2DecoderImpl::HandleDescheduleUntilFinishedCHROMIUM( | |
13682 uint32_t immediate_data_size, | |
13683 const void* cmd_data) { | |
13684 if (deschedule_until_finished_callback_.is_null() || | |
13685 reschedule_after_finished_callback_.is_null()) { | |
13686 return error::kUnknownCommand; | |
erikchen
2016/06/01 00:41:58
I thought I was being clever by returning error::k
piman
2016/06/01 01:35:47
kNoError is fine, but could you generate a GL_INVA
| |
13687 } | |
13688 | |
13689 deschedule_until_finished_fence_.reset(gl::GLFence::Create()); | |
13690 DCHECK(deschedule_until_finished_fence_); | |
13691 if (deschedule_until_finished_fence_->HasCompleted()) { | |
13692 deschedule_until_finished_fence_.reset(); | |
13693 return error::kNoError; | |
13694 } | |
13695 | |
13696 deschedule_until_finished_callback_.Run(); | |
13697 return error::kDeferLaterCommands; | |
13698 } | |
13699 | |
13656 error::Error GLES2DecoderImpl::HandleInsertFenceSyncCHROMIUM( | 13700 error::Error GLES2DecoderImpl::HandleInsertFenceSyncCHROMIUM( |
13657 uint32_t immediate_data_size, | 13701 uint32_t immediate_data_size, |
13658 const void* cmd_data) { | 13702 const void* cmd_data) { |
13659 const gles2::cmds::InsertFenceSyncCHROMIUM& c = | 13703 const gles2::cmds::InsertFenceSyncCHROMIUM& c = |
13660 *static_cast<const gles2::cmds::InsertFenceSyncCHROMIUM*>(cmd_data); | 13704 *static_cast<const gles2::cmds::InsertFenceSyncCHROMIUM*>(cmd_data); |
13661 | 13705 |
13662 const uint64_t release_count = c.release_count(); | 13706 const uint64_t release_count = c.release_count(); |
13663 if (!fence_sync_release_callback_.is_null()) | 13707 if (!fence_sync_release_callback_.is_null()) |
13664 fence_sync_release_callback_.Run(release_count); | 13708 fence_sync_release_callback_.Run(release_count); |
13665 return error::kNoError; | 13709 return error::kNoError; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13772 pending_readpixel_fences_.front()->fence->HasCompleted())) { | 13816 pending_readpixel_fences_.front()->fence->HasCompleted())) { |
13773 std::vector<base::Closure> callbacks = | 13817 std::vector<base::Closure> callbacks = |
13774 pending_readpixel_fences_.front()->callbacks; | 13818 pending_readpixel_fences_.front()->callbacks; |
13775 pending_readpixel_fences_.pop(); | 13819 pending_readpixel_fences_.pop(); |
13776 for (size_t i = 0; i < callbacks.size(); i++) { | 13820 for (size_t i = 0; i < callbacks.size(); i++) { |
13777 callbacks[i].Run(); | 13821 callbacks[i].Run(); |
13778 } | 13822 } |
13779 } | 13823 } |
13780 } | 13824 } |
13781 | 13825 |
13826 void GLES2DecoderImpl::ProcessDescheduleUntilFinished() { | |
13827 if (!deschedule_until_finished_fence_) | |
13828 return; | |
13829 | |
13830 if (!deschedule_until_finished_fence_->HasCompleted()) | |
13831 return; | |
13832 | |
13833 deschedule_until_finished_fence_.reset(); | |
13834 reschedule_after_finished_callback_.Run(); | |
13835 } | |
13836 | |
13782 bool GLES2DecoderImpl::HasMoreIdleWork() const { | 13837 bool GLES2DecoderImpl::HasMoreIdleWork() const { |
13783 return !pending_readpixel_fences_.empty() || | 13838 return deschedule_until_finished_fence_ || |
13839 !pending_readpixel_fences_.empty() || | |
13784 gpu_tracer_->HasTracesToProcess(); | 13840 gpu_tracer_->HasTracesToProcess(); |
13785 } | 13841 } |
13786 | 13842 |
13787 void GLES2DecoderImpl::PerformIdleWork() { | 13843 void GLES2DecoderImpl::PerformIdleWork() { |
13788 gpu_tracer_->ProcessTraces(); | 13844 gpu_tracer_->ProcessTraces(); |
13789 ProcessPendingReadPixels(false); | 13845 ProcessPendingReadPixels(false); |
13846 ProcessDescheduleUntilFinished(); | |
13790 } | 13847 } |
13791 | 13848 |
13792 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32_t immediate_data_size, | 13849 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32_t immediate_data_size, |
13793 const void* cmd_data) { | 13850 const void* cmd_data) { |
13794 const gles2::cmds::BeginQueryEXT& c = | 13851 const gles2::cmds::BeginQueryEXT& c = |
13795 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); | 13852 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); |
13796 GLenum target = static_cast<GLenum>(c.target); | 13853 GLenum target = static_cast<GLenum>(c.target); |
13797 GLuint client_id = static_cast<GLuint>(c.id); | 13854 GLuint client_id = static_cast<GLuint>(c.id); |
13798 int32_t sync_shm_id = static_cast<int32_t>(c.sync_data_shm_id); | 13855 int32_t sync_shm_id = static_cast<int32_t>(c.sync_data_shm_id); |
13799 uint32_t sync_shm_offset = static_cast<uint32_t>(c.sync_data_shm_offset); | 13856 uint32_t sync_shm_offset = static_cast<uint32_t>(c.sync_data_shm_offset); |
(...skipping 3025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16825 } | 16882 } |
16826 | 16883 |
16827 // Include the auto-generated part of this file. We split this because it means | 16884 // Include the auto-generated part of this file. We split this because it means |
16828 // we can easily edit the non-auto generated parts right here in this file | 16885 // we can easily edit the non-auto generated parts right here in this file |
16829 // instead of having to edit some template or the code generator. | 16886 // instead of having to edit some template or the code generator. |
16830 #include "base/macros.h" | 16887 #include "base/macros.h" |
16831 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16888 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16832 | 16889 |
16833 } // namespace gles2 | 16890 } // namespace gles2 |
16834 } // namespace gpu | 16891 } // namespace gpu |
OLD | NEW |