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

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

Issue 2021603002: gpu: Add a new extension CHROMIUM_deschedule. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 <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
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
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
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
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
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
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 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
13687 "glDescheduleUntilFinishedCHROMIUM",
13688 "Not fully implemented.");
13689 return error::kNoError;
13690 }
13691
13692 deschedule_until_finished_fence_.reset(gl::GLFence::Create());
13693 DCHECK(deschedule_until_finished_fence_);
13694 if (deschedule_until_finished_fence_->HasCompleted()) {
13695 deschedule_until_finished_fence_.reset();
13696 return error::kNoError;
13697 }
13698
13699 deschedule_until_finished_callback_.Run();
13700 return error::kDeferLaterCommands;
13701 }
13702
13656 error::Error GLES2DecoderImpl::HandleInsertFenceSyncCHROMIUM( 13703 error::Error GLES2DecoderImpl::HandleInsertFenceSyncCHROMIUM(
13657 uint32_t immediate_data_size, 13704 uint32_t immediate_data_size,
13658 const void* cmd_data) { 13705 const void* cmd_data) {
13659 const gles2::cmds::InsertFenceSyncCHROMIUM& c = 13706 const gles2::cmds::InsertFenceSyncCHROMIUM& c =
13660 *static_cast<const gles2::cmds::InsertFenceSyncCHROMIUM*>(cmd_data); 13707 *static_cast<const gles2::cmds::InsertFenceSyncCHROMIUM*>(cmd_data);
13661 13708
13662 const uint64_t release_count = c.release_count(); 13709 const uint64_t release_count = c.release_count();
13663 if (!fence_sync_release_callback_.is_null()) 13710 if (!fence_sync_release_callback_.is_null())
13664 fence_sync_release_callback_.Run(release_count); 13711 fence_sync_release_callback_.Run(release_count);
13665 return error::kNoError; 13712 return error::kNoError;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
13772 pending_readpixel_fences_.front()->fence->HasCompleted())) { 13819 pending_readpixel_fences_.front()->fence->HasCompleted())) {
13773 std::vector<base::Closure> callbacks = 13820 std::vector<base::Closure> callbacks =
13774 pending_readpixel_fences_.front()->callbacks; 13821 pending_readpixel_fences_.front()->callbacks;
13775 pending_readpixel_fences_.pop(); 13822 pending_readpixel_fences_.pop();
13776 for (size_t i = 0; i < callbacks.size(); i++) { 13823 for (size_t i = 0; i < callbacks.size(); i++) {
13777 callbacks[i].Run(); 13824 callbacks[i].Run();
13778 } 13825 }
13779 } 13826 }
13780 } 13827 }
13781 13828
13829 void GLES2DecoderImpl::ProcessDescheduleUntilFinished() {
13830 if (!deschedule_until_finished_fence_)
13831 return;
13832
13833 if (!deschedule_until_finished_fence_->HasCompleted())
13834 return;
13835
13836 deschedule_until_finished_fence_.reset();
13837 reschedule_after_finished_callback_.Run();
13838 }
13839
13782 bool GLES2DecoderImpl::HasMoreIdleWork() const { 13840 bool GLES2DecoderImpl::HasMoreIdleWork() const {
13783 return !pending_readpixel_fences_.empty() || 13841 return deschedule_until_finished_fence_ ||
13842 !pending_readpixel_fences_.empty() ||
13784 gpu_tracer_->HasTracesToProcess(); 13843 gpu_tracer_->HasTracesToProcess();
13785 } 13844 }
13786 13845
13787 void GLES2DecoderImpl::PerformIdleWork() { 13846 void GLES2DecoderImpl::PerformIdleWork() {
13788 gpu_tracer_->ProcessTraces(); 13847 gpu_tracer_->ProcessTraces();
13789 ProcessPendingReadPixels(false); 13848 ProcessPendingReadPixels(false);
13849 ProcessDescheduleUntilFinished();
13790 } 13850 }
13791 13851
13792 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32_t immediate_data_size, 13852 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32_t immediate_data_size,
13793 const void* cmd_data) { 13853 const void* cmd_data) {
13794 const gles2::cmds::BeginQueryEXT& c = 13854 const gles2::cmds::BeginQueryEXT& c =
13795 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); 13855 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data);
13796 GLenum target = static_cast<GLenum>(c.target); 13856 GLenum target = static_cast<GLenum>(c.target);
13797 GLuint client_id = static_cast<GLuint>(c.id); 13857 GLuint client_id = static_cast<GLuint>(c.id);
13798 int32_t sync_shm_id = static_cast<int32_t>(c.sync_data_shm_id); 13858 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); 13859 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
16825 } 16885 }
16826 16886
16827 // Include the auto-generated part of this file. We split this because it means 16887 // 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 16888 // 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. 16889 // instead of having to edit some template or the code generator.
16830 #include "base/macros.h" 16890 #include "base/macros.h"
16831 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16891 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16832 16892
16833 } // namespace gles2 16893 } // namespace gles2
16834 } // namespace gpu 16894 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('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