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

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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 GLsizei height); 977 GLsizei height);
973 978
974 // Wrapper for TexImageIOSurface2DCHROMIUM. 979 // Wrapper for TexImageIOSurface2DCHROMIUM.
975 void DoTexImageIOSurface2DCHROMIUM( 980 void DoTexImageIOSurface2DCHROMIUM(
976 GLenum target, 981 GLenum target,
977 GLsizei width, 982 GLsizei width,
978 GLsizei height, 983 GLsizei height,
979 GLuint io_surface_id, 984 GLuint io_surface_id,
980 GLuint plane); 985 GLuint plane);
981 986
987 void DoDescheduleUntilFinishedCHROMIUM();
988
982 void DoCopyTextureCHROMIUM(GLuint source_id, 989 void DoCopyTextureCHROMIUM(GLuint source_id,
983 GLuint dest_id, 990 GLuint dest_id,
984 GLenum internal_format, 991 GLenum internal_format,
985 GLenum dest_type, 992 GLenum dest_type,
986 GLboolean unpack_flip_y, 993 GLboolean unpack_flip_y,
987 GLboolean unpack_premultiply_alpha, 994 GLboolean unpack_premultiply_alpha,
988 GLboolean unpack_unmultiply_alpha); 995 GLboolean unpack_unmultiply_alpha);
989 996
990 void DoCopySubTextureCHROMIUM(GLuint source_id, 997 void DoCopySubTextureCHROMIUM(GLuint source_id,
991 GLuint dest_id, 998 GLuint dest_id,
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 back_buffer_color_format_ == GL_RGBA8); 1962 back_buffer_color_format_ == GL_RGBA8);
1956 } 1963 }
1957 1964
1958 // Set remaining commands to process to 0 to force DoCommands to return 1965 // Set remaining commands to process to 0 to force DoCommands to return
1959 // and allow context preemption and GPU watchdog checks in CommandExecutor(). 1966 // and allow context preemption and GPU watchdog checks in CommandExecutor().
1960 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } 1967 void ExitCommandProcessingEarly() { commands_to_process_ = 0; }
1961 1968
1962 void ProcessPendingReadPixels(bool did_finish); 1969 void ProcessPendingReadPixels(bool did_finish);
1963 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); 1970 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer);
1964 1971
1972 // Checks to see if the inserted fence has completed.
1973 void ProcessDescheduleUntilFinished();
1974
1965 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id, 1975 void DoBindFragmentInputLocationCHROMIUM(GLuint program_id,
1966 GLint location, 1976 GLint location,
1967 const std::string& name); 1977 const std::string& name);
1968 1978
1969 // If |texture_manager_version_| doesn't match the current version, then this 1979 // If |texture_manager_version_| doesn't match the current version, then this
1970 // will rebind all external textures to match their current service_id. 1980 // will rebind all external textures to match their current service_id.
1971 void RestoreAllExternalTextureBindingsIfNeeded() override; 1981 void RestoreAllExternalTextureBindingsIfNeeded() override;
1972 1982
1973 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit); 1983 const SamplerState& GetSamplerStateForTextureUnit(GLenum target, GLuint unit);
1974 1984
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 GLenum offscreen_saved_color_format_; 2104 GLenum offscreen_saved_color_format_;
2095 2105
2096 std::unique_ptr<QueryManager> query_manager_; 2106 std::unique_ptr<QueryManager> query_manager_;
2097 2107
2098 std::unique_ptr<VertexArrayManager> vertex_array_manager_; 2108 std::unique_ptr<VertexArrayManager> vertex_array_manager_;
2099 2109
2100 std::unique_ptr<ImageManager> image_manager_; 2110 std::unique_ptr<ImageManager> image_manager_;
2101 2111
2102 FenceSyncReleaseCallback fence_sync_release_callback_; 2112 FenceSyncReleaseCallback fence_sync_release_callback_;
2103 WaitFenceSyncCallback wait_fence_sync_callback_; 2113 WaitFenceSyncCallback wait_fence_sync_callback_;
2114 NoParamCallback deschedule_until_finished_callback_;
2115 NoParamCallback reschedule_after_finished_callback_;
2104 2116
2105 ShaderCacheCallback shader_cache_callback_; 2117 ShaderCacheCallback shader_cache_callback_;
2106 2118
2107 // The format of the back buffer_ 2119 // The format of the back buffer_
2108 GLenum back_buffer_color_format_; 2120 GLenum back_buffer_color_format_;
2109 bool back_buffer_has_depth_; 2121 bool back_buffer_has_depth_;
2110 bool back_buffer_has_stencil_; 2122 bool back_buffer_has_stencil_;
2111 2123
2112 // Tracks read buffer and draw buffer for backbuffer, whether it's onscreen 2124 // Tracks read buffer and draw buffer for backbuffer, whether it's onscreen
2113 // or offscreen. 2125 // or offscreen.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 2201
2190 std::unique_ptr<GPUTracer> gpu_tracer_; 2202 std::unique_ptr<GPUTracer> gpu_tracer_;
2191 std::unique_ptr<GPUStateTracer> gpu_state_tracer_; 2203 std::unique_ptr<GPUStateTracer> gpu_state_tracer_;
2192 const unsigned char* gpu_decoder_category_; 2204 const unsigned char* gpu_decoder_category_;
2193 int gpu_trace_level_; 2205 int gpu_trace_level_;
2194 bool gpu_trace_commands_; 2206 bool gpu_trace_commands_;
2195 bool gpu_debug_commands_; 2207 bool gpu_debug_commands_;
2196 2208
2197 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; 2209 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_;
2198 2210
2211 // After this fence is inserted, both the GpuChannelMessageQueue and
2212 // CommandExecutor are descheduled. Once the fence has completed, both get
2213 // rescheduled.
2214 std::unique_ptr<gl::GLFence> deschedule_until_finished_fence_;
2215
2199 // Used to validate multisample renderbuffers if needed 2216 // Used to validate multisample renderbuffers if needed
2200 GLuint validation_texture_; 2217 GLuint validation_texture_;
2201 GLuint validation_fbo_multisample_; 2218 GLuint validation_fbo_multisample_;
2202 GLuint validation_fbo_; 2219 GLuint validation_fbo_;
2203 2220
2204 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)( 2221 typedef gpu::gles2::GLES2Decoder::Error (GLES2DecoderImpl::*CmdHandler)(
2205 uint32_t immediate_data_size, 2222 uint32_t immediate_data_size,
2206 const void* data); 2223 const void* data);
2207 2224
2208 // A struct to hold info about each command. 2225 // A struct to hold info about each command.
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
4170 void GLES2DecoderImpl::SetFenceSyncReleaseCallback( 4187 void GLES2DecoderImpl::SetFenceSyncReleaseCallback(
4171 const FenceSyncReleaseCallback& callback) { 4188 const FenceSyncReleaseCallback& callback) {
4172 fence_sync_release_callback_ = callback; 4189 fence_sync_release_callback_ = callback;
4173 } 4190 }
4174 4191
4175 void GLES2DecoderImpl::SetWaitFenceSyncCallback( 4192 void GLES2DecoderImpl::SetWaitFenceSyncCallback(
4176 const WaitFenceSyncCallback& callback) { 4193 const WaitFenceSyncCallback& callback) {
4177 wait_fence_sync_callback_ = callback; 4194 wait_fence_sync_callback_ = callback;
4178 } 4195 }
4179 4196
4197 void GLES2DecoderImpl::SetDescheduleUntilFinishedCallback(
4198 const NoParamCallback& callback) {
4199 deschedule_until_finished_callback_ = callback;
4200 }
4201
4202 void GLES2DecoderImpl::SetRescheduleAfterFinishedCallback(
4203 const NoParamCallback& callback) {
4204 reschedule_after_finished_callback_ = callback;
4205 }
4206
4180 bool GLES2DecoderImpl::GetServiceTextureId(uint32_t client_texture_id, 4207 bool GLES2DecoderImpl::GetServiceTextureId(uint32_t client_texture_id,
4181 uint32_t* service_texture_id) { 4208 uint32_t* service_texture_id) {
4182 TextureRef* texture_ref = texture_manager()->GetTexture(client_texture_id); 4209 TextureRef* texture_ref = texture_manager()->GetTexture(client_texture_id);
4183 if (texture_ref) { 4210 if (texture_ref) {
4184 *service_texture_id = texture_ref->service_id(); 4211 *service_texture_id = texture_ref->service_id();
4185 return true; 4212 return true;
4186 } 4213 }
4187 return false; 4214 return false;
4188 } 4215 }
4189 4216
(...skipping 9582 matching lines...) Expand 10 before | Expand all | Expand 10 after
13772 pending_readpixel_fences_.front()->fence->HasCompleted())) { 13799 pending_readpixel_fences_.front()->fence->HasCompleted())) {
13773 std::vector<base::Closure> callbacks = 13800 std::vector<base::Closure> callbacks =
13774 pending_readpixel_fences_.front()->callbacks; 13801 pending_readpixel_fences_.front()->callbacks;
13775 pending_readpixel_fences_.pop(); 13802 pending_readpixel_fences_.pop();
13776 for (size_t i = 0; i < callbacks.size(); i++) { 13803 for (size_t i = 0; i < callbacks.size(); i++) {
13777 callbacks[i].Run(); 13804 callbacks[i].Run();
13778 } 13805 }
13779 } 13806 }
13780 } 13807 }
13781 13808
13809 void GLES2DecoderImpl::ProcessDescheduleUntilFinished() {
13810 if (!deschedule_until_finished_fence_)
13811 return;
13812
13813 if (!deschedule_until_finished_fence_->HasCompleted())
13814 return;
13815
13816 deschedule_until_finished_fence_.reset();
13817 reschedule_after_finished_callback_.Run();
13818 }
13819
13782 bool GLES2DecoderImpl::HasMoreIdleWork() const { 13820 bool GLES2DecoderImpl::HasMoreIdleWork() const {
13783 return !pending_readpixel_fences_.empty() || 13821 return deschedule_until_finished_fence_ ||
13822 !pending_readpixel_fences_.empty() ||
13784 gpu_tracer_->HasTracesToProcess(); 13823 gpu_tracer_->HasTracesToProcess();
13785 } 13824 }
13786 13825
13787 void GLES2DecoderImpl::PerformIdleWork() { 13826 void GLES2DecoderImpl::PerformIdleWork() {
13788 gpu_tracer_->ProcessTraces(); 13827 gpu_tracer_->ProcessTraces();
13789 ProcessPendingReadPixels(false); 13828 ProcessPendingReadPixels(false);
13829 ProcessDescheduleUntilFinished();
13790 } 13830 }
13791 13831
13792 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32_t immediate_data_size, 13832 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32_t immediate_data_size,
13793 const void* cmd_data) { 13833 const void* cmd_data) {
13794 const gles2::cmds::BeginQueryEXT& c = 13834 const gles2::cmds::BeginQueryEXT& c =
13795 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); 13835 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data);
13796 GLenum target = static_cast<GLenum>(c.target); 13836 GLenum target = static_cast<GLenum>(c.target);
13797 GLuint client_id = static_cast<GLuint>(c.id); 13837 GLuint client_id = static_cast<GLuint>(c.id);
13798 int32_t sync_shm_id = static_cast<int32_t>(c.sync_data_shm_id); 13838 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); 13839 uint32_t sync_shm_offset = static_cast<uint32_t>(c.sync_data_shm_offset);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
14271 14311
14272 if (!valid_format) { 14312 if (!valid_format) {
14273 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 14313 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
14274 "invalid internal format"); 14314 "invalid internal format");
14275 return false; 14315 return false;
14276 } 14316 }
14277 14317
14278 return true; 14318 return true;
14279 } 14319 }
14280 14320
14321 void GLES2DecoderImpl::DoDescheduleUntilFinishedCHROMIUM() {
14322 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoDescheduleUntilFinishedCHROMIUM");
14323 if (deschedule_until_finished_callback_.is_null() ||
14324 reschedule_after_finished_callback_.is_null()) {
14325 return;
14326 }
14327
14328 deschedule_until_finished_fence_.reset(gl::GLFence::Create());
14329 DCHECK(deschedule_until_finished_fence_);
14330 if (deschedule_until_finished_fence_->HasCompleted()) {
14331 deschedule_until_finished_fence_.reset();
14332 return;
14333 }
14334
14335 deschedule_until_finished_callback_.Run();
14336 }
14337
14281 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 14338 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
14282 GLuint source_id, 14339 GLuint source_id,
14283 GLuint dest_id, 14340 GLuint dest_id,
14284 GLenum internal_format, 14341 GLenum internal_format,
14285 GLenum dest_type, 14342 GLenum dest_type,
14286 GLboolean unpack_flip_y, 14343 GLboolean unpack_flip_y,
14287 GLboolean unpack_premultiply_alpha, 14344 GLboolean unpack_premultiply_alpha,
14288 GLboolean unpack_unmultiply_alpha) { 14345 GLboolean unpack_unmultiply_alpha) {
14289 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 14346 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
14290 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; 14347 static const char kFunctionName[] = "glCopyTextureCHROMIUM";
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698