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 <cmath> | 10 #include <cmath> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/numerics/safe_math.h" | 22 #include "base/numerics/safe_math.h" |
23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
24 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
25 #include "base/trace_event/trace_event_synthetic_delay.h" | 25 #include "base/trace_event/trace_event_synthetic_delay.h" |
26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
27 #define GLES2_GPU_SERVICE 1 | 27 #define GLES2_GPU_SERVICE 1 |
28 #include "gpu/command_buffer/common/debug_marker_manager.h" | 28 #include "gpu/command_buffer/common/debug_marker_manager.h" |
29 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 29 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
30 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 30 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
31 #include "gpu/command_buffer/common/mailbox.h" | 31 #include "gpu/command_buffer/common/mailbox.h" |
32 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" | |
33 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | |
34 #include "gpu/command_buffer/service/buffer_manager.h" | 32 #include "gpu/command_buffer/service/buffer_manager.h" |
35 #include "gpu/command_buffer/service/context_group.h" | 33 #include "gpu/command_buffer/service/context_group.h" |
36 #include "gpu/command_buffer/service/context_state.h" | 34 #include "gpu/command_buffer/service/context_state.h" |
37 #include "gpu/command_buffer/service/error_state.h" | 35 #include "gpu/command_buffer/service/error_state.h" |
38 #include "gpu/command_buffer/service/feature_info.h" | 36 #include "gpu/command_buffer/service/feature_info.h" |
39 #include "gpu/command_buffer/service/framebuffer_manager.h" | 37 #include "gpu/command_buffer/service/framebuffer_manager.h" |
40 #include "gpu/command_buffer/service/gl_utils.h" | 38 #include "gpu/command_buffer/service/gl_utils.h" |
41 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" | 39 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" |
42 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 40 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
43 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 41 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 549 |
552 struct FenceCallback { | 550 struct FenceCallback { |
553 FenceCallback() | 551 FenceCallback() |
554 : fence(gfx::GLFence::Create()) { | 552 : fence(gfx::GLFence::Create()) { |
555 DCHECK(fence); | 553 DCHECK(fence); |
556 } | 554 } |
557 std::vector<base::Closure> callbacks; | 555 std::vector<base::Closure> callbacks; |
558 scoped_ptr<gfx::GLFence> fence; | 556 scoped_ptr<gfx::GLFence> fence; |
559 }; | 557 }; |
560 | 558 |
561 class AsyncUploadTokenCompletionObserver | |
562 : public AsyncPixelTransferCompletionObserver { | |
563 public: | |
564 explicit AsyncUploadTokenCompletionObserver(uint32 async_upload_token) | |
565 : async_upload_token_(async_upload_token) { | |
566 } | |
567 | |
568 void DidComplete(const AsyncMemoryParams& mem_params) override { | |
569 DCHECK(mem_params.buffer().get()); | |
570 void* data = mem_params.GetDataAddress(); | |
571 AsyncUploadSync* sync = static_cast<AsyncUploadSync*>(data); | |
572 sync->SetAsyncUploadToken(async_upload_token_); | |
573 } | |
574 | |
575 private: | |
576 ~AsyncUploadTokenCompletionObserver() override {} | |
577 | |
578 uint32 async_upload_token_; | |
579 | |
580 DISALLOW_COPY_AND_ASSIGN(AsyncUploadTokenCompletionObserver); | |
581 }; | |
582 | |
583 // } // anonymous namespace. | 559 // } // anonymous namespace. |
584 | 560 |
585 // static | 561 // static |
586 const unsigned int GLES2Decoder::kDefaultStencilMask = | 562 const unsigned int GLES2Decoder::kDefaultStencilMask = |
587 static_cast<unsigned int>(-1); | 563 static_cast<unsigned int>(-1); |
588 | 564 |
589 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, | 565 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, |
590 uint32* service_texture_id) { | 566 uint32* service_texture_id) { |
591 return false; | 567 return false; |
592 } | 568 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 677 |
702 void BeginDecoding() override; | 678 void BeginDecoding() override; |
703 void EndDecoding() override; | 679 void EndDecoding() override; |
704 | 680 |
705 ErrorState* GetErrorState() override; | 681 ErrorState* GetErrorState() override; |
706 const ContextState* GetContextState() override { return &state_; } | 682 const ContextState* GetContextState() override { return &state_; } |
707 | 683 |
708 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; | 684 void SetShaderCacheCallback(const ShaderCacheCallback& callback) override; |
709 void SetWaitSyncPointCallback(const WaitSyncPointCallback& callback) override; | 685 void SetWaitSyncPointCallback(const WaitSyncPointCallback& callback) override; |
710 | 686 |
711 AsyncPixelTransferManager* GetAsyncPixelTransferManager() override; | |
712 void ResetAsyncPixelTransferManagerForTest() override; | |
713 void SetAsyncPixelTransferManagerForTest( | |
714 AsyncPixelTransferManager* manager) override; | |
715 void SetIgnoreCachedStateForTest(bool ignore) override; | 687 void SetIgnoreCachedStateForTest(bool ignore) override; |
716 void ProcessFinishedAsyncTransfers(); | 688 void ProcessFinishedAsyncTransfers(); |
717 | 689 |
718 bool GetServiceTextureId(uint32 client_texture_id, | 690 bool GetServiceTextureId(uint32 client_texture_id, |
719 uint32* service_texture_id) override; | 691 uint32* service_texture_id) override; |
720 | 692 |
721 uint32 GetTextureUploadCount() override; | 693 uint32 GetTextureUploadCount() override; |
722 base::TimeDelta GetTotalTextureUploadTime() override; | 694 base::TimeDelta GetTotalTextureUploadTime() override; |
723 base::TimeDelta GetTotalProcessingCommandsTime() override; | 695 base::TimeDelta GetTotalProcessingCommandsTime() override; |
724 void AddProcessingCommandsTime(base::TimeDelta) override; | 696 void AddProcessingCommandsTime(base::TimeDelta) override; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 761 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
790 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 762 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
791 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 763 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
792 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 764 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
793 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 765 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
794 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 766 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
795 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 767 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
796 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 768 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
797 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 769 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
798 | 770 |
799 // Helper for async upload token completion notification callback. | |
800 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, | |
801 uint32 sync_data_shm_id, | |
802 uint32 sync_data_shm_offset); | |
803 | |
804 | |
805 | |
806 // Workarounds | 771 // Workarounds |
807 void OnFboChanged() const; | 772 void OnFboChanged() const; |
808 void OnUseFramebuffer() const; | 773 void OnUseFramebuffer() const; |
809 | 774 |
810 error::ContextLostReason GetContextLostReasonFromResetStatus( | 775 error::ContextLostReason GetContextLostReasonFromResetStatus( |
811 GLenum reset_status) const; | 776 GLenum reset_status) const; |
812 | 777 |
813 // TODO(gman): Cache these pointers? | 778 // TODO(gman): Cache these pointers? |
814 BufferManager* buffer_manager() { | 779 BufferManager* buffer_manager() { |
815 return group_->buffer_manager(); | 780 return group_->buffer_manager(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 GLint xoffset, | 980 GLint xoffset, |
1016 GLint yoffset, | 981 GLint yoffset, |
1017 GLint zoffset, | 982 GLint zoffset, |
1018 GLsizei width, | 983 GLsizei width, |
1019 GLsizei height, | 984 GLsizei height, |
1020 GLsizei depth, | 985 GLsizei depth, |
1021 GLenum format, | 986 GLenum format, |
1022 GLenum type, | 987 GLenum type, |
1023 const void * data); | 988 const void * data); |
1024 | 989 |
1025 // Extra validation for async tex(Sub)Image2D. | |
1026 bool ValidateAsyncTransfer( | |
1027 const char* function_name, | |
1028 TextureRef* texture_ref, | |
1029 GLenum target, | |
1030 GLint level, | |
1031 const void * data); | |
1032 | |
1033 // Wrapper for TexImageIOSurface2DCHROMIUM. | 990 // Wrapper for TexImageIOSurface2DCHROMIUM. |
1034 void DoTexImageIOSurface2DCHROMIUM( | 991 void DoTexImageIOSurface2DCHROMIUM( |
1035 GLenum target, | 992 GLenum target, |
1036 GLsizei width, | 993 GLsizei width, |
1037 GLsizei height, | 994 GLsizei height, |
1038 GLuint io_surface_id, | 995 GLuint io_surface_id, |
1039 GLuint plane); | 996 GLuint plane); |
1040 | 997 |
1041 void DoCopyTextureCHROMIUM(GLenum target, | 998 void DoCopyTextureCHROMIUM(GLenum target, |
1042 GLuint source_id, | 999 GLuint source_id, |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 scoped_ptr<VertexArrayManager> vertex_array_manager_; | 1933 scoped_ptr<VertexArrayManager> vertex_array_manager_; |
1977 | 1934 |
1978 scoped_ptr<ImageManager> image_manager_; | 1935 scoped_ptr<ImageManager> image_manager_; |
1979 | 1936 |
1980 base::Callback<void(gfx::Size, float)> resize_callback_; | 1937 base::Callback<void(gfx::Size, float)> resize_callback_; |
1981 | 1938 |
1982 WaitSyncPointCallback wait_sync_point_callback_; | 1939 WaitSyncPointCallback wait_sync_point_callback_; |
1983 | 1940 |
1984 ShaderCacheCallback shader_cache_callback_; | 1941 ShaderCacheCallback shader_cache_callback_; |
1985 | 1942 |
1986 scoped_ptr<AsyncPixelTransferManager> async_pixel_transfer_manager_; | |
1987 | |
1988 // The format of the back buffer_ | 1943 // The format of the back buffer_ |
1989 GLenum back_buffer_color_format_; | 1944 GLenum back_buffer_color_format_; |
1990 bool back_buffer_has_depth_; | 1945 bool back_buffer_has_depth_; |
1991 bool back_buffer_has_stencil_; | 1946 bool back_buffer_has_stencil_; |
1992 | 1947 |
1993 // Tracks read buffer and draw buffer for backbuffer, whether it's onscreen | 1948 // Tracks read buffer and draw buffer for backbuffer, whether it's onscreen |
1994 // or offscreen. | 1949 // or offscreen. |
1995 // TODO(zmo): when ES3 APIs are exposed to Nacl, make sure read_buffer_ | 1950 // TODO(zmo): when ES3 APIs are exposed to Nacl, make sure read_buffer_ |
1996 // setting is set correctly when SwapBuffers(). | 1951 // setting is set correctly when SwapBuffers(). |
1997 GLenum back_buffer_read_buffer_; | 1952 GLenum back_buffer_read_buffer_; |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3046 context_->SetUnbindFboOnMakeCurrent(); | 3001 context_->SetUnbindFboOnMakeCurrent(); |
3047 } | 3002 } |
3048 | 3003 |
3049 // Only compositor contexts are known to use only the subset of GL | 3004 // Only compositor contexts are known to use only the subset of GL |
3050 // that can be safely migrated between the iGPU and the dGPU. Mark | 3005 // that can be safely migrated between the iGPU and the dGPU. Mark |
3051 // those contexts as safe to forcibly transition between the GPUs. | 3006 // those contexts as safe to forcibly transition between the GPUs. |
3052 // http://crbug.com/180876, http://crbug.com/227228 | 3007 // http://crbug.com/180876, http://crbug.com/227228 |
3053 if (!offscreen) | 3008 if (!offscreen) |
3054 context_->SetSafeToForceGpuSwitch(); | 3009 context_->SetSafeToForceGpuSwitch(); |
3055 | 3010 |
3056 async_pixel_transfer_manager_.reset( | |
3057 AsyncPixelTransferManager::Create(context.get())); | |
3058 async_pixel_transfer_manager_->Initialize(texture_manager()); | |
3059 | |
3060 if (workarounds().gl_clear_broken) { | 3011 if (workarounds().gl_clear_broken) { |
3061 DCHECK(!clear_framebuffer_blit_.get()); | 3012 DCHECK(!clear_framebuffer_blit_.get()); |
3062 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glClearWorkaroundInit"); | 3013 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glClearWorkaroundInit"); |
3063 clear_framebuffer_blit_.reset(new ClearFramebufferResourceManager(this)); | 3014 clear_framebuffer_blit_.reset(new ClearFramebufferResourceManager(this)); |
3064 if (LOCAL_PEEK_GL_ERROR("glClearWorkaroundInit") != GL_NO_ERROR) | 3015 if (LOCAL_PEEK_GL_ERROR("glClearWorkaroundInit") != GL_NO_ERROR) |
3065 return false; | 3016 return false; |
3066 } | 3017 } |
3067 | 3018 |
3068 framebuffer_manager()->AddObserver(this); | 3019 framebuffer_manager()->AddObserver(this); |
3069 | 3020 |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3607 | 3558 |
3608 framebuffer_state_.clear_state_dirty = true; | 3559 framebuffer_state_.clear_state_dirty = true; |
3609 | 3560 |
3610 return true; | 3561 return true; |
3611 } | 3562 } |
3612 | 3563 |
3613 void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() { | 3564 void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() { |
3614 ProcessPendingReadPixels(false); | 3565 ProcessPendingReadPixels(false); |
3615 if (engine() && query_manager_.get()) | 3566 if (engine() && query_manager_.get()) |
3616 query_manager_->ProcessPendingTransferQueries(); | 3567 query_manager_->ProcessPendingTransferQueries(); |
3617 | |
3618 // TODO(epenner): Is there a better place to do this? | |
3619 // This needs to occur before we execute any batch of commands | |
3620 // from the client, as the client may have recieved an async | |
3621 // completion while issuing those commands. | |
3622 // "DidFlushStart" would be ideal if we had such a callback. | |
3623 async_pixel_transfer_manager_->BindCompletedAsyncTransfers(); | |
3624 } | 3568 } |
3625 | 3569 |
3626 static void RebindCurrentFramebuffer( | 3570 static void RebindCurrentFramebuffer( |
3627 GLenum target, | 3571 GLenum target, |
3628 Framebuffer* framebuffer, | 3572 Framebuffer* framebuffer, |
3629 GLuint back_buffer_service_id) { | 3573 GLuint back_buffer_service_id) { |
3630 GLuint framebuffer_id = framebuffer ? framebuffer->service_id() : 0; | 3574 GLuint framebuffer_id = framebuffer ? framebuffer->service_id() : 0; |
3631 | 3575 |
3632 if (framebuffer_id == 0) { | 3576 if (framebuffer_id == 0) { |
3633 framebuffer_id = back_buffer_service_id; | 3577 framebuffer_id = back_buffer_service_id; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3897 void GLES2DecoderImpl::SetShaderCacheCallback( | 3841 void GLES2DecoderImpl::SetShaderCacheCallback( |
3898 const ShaderCacheCallback& callback) { | 3842 const ShaderCacheCallback& callback) { |
3899 shader_cache_callback_ = callback; | 3843 shader_cache_callback_ = callback; |
3900 } | 3844 } |
3901 | 3845 |
3902 void GLES2DecoderImpl::SetWaitSyncPointCallback( | 3846 void GLES2DecoderImpl::SetWaitSyncPointCallback( |
3903 const WaitSyncPointCallback& callback) { | 3847 const WaitSyncPointCallback& callback) { |
3904 wait_sync_point_callback_ = callback; | 3848 wait_sync_point_callback_ = callback; |
3905 } | 3849 } |
3906 | 3850 |
3907 AsyncPixelTransferManager* | |
3908 GLES2DecoderImpl::GetAsyncPixelTransferManager() { | |
3909 return async_pixel_transfer_manager_.get(); | |
3910 } | |
3911 | |
3912 void GLES2DecoderImpl::ResetAsyncPixelTransferManagerForTest() { | |
3913 async_pixel_transfer_manager_.reset(); | |
3914 } | |
3915 | |
3916 void GLES2DecoderImpl::SetAsyncPixelTransferManagerForTest( | |
3917 AsyncPixelTransferManager* manager) { | |
3918 async_pixel_transfer_manager_ = make_scoped_ptr(manager); | |
3919 } | |
3920 | |
3921 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, | 3851 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, |
3922 uint32* service_texture_id) { | 3852 uint32* service_texture_id) { |
3923 TextureRef* texture_ref = texture_manager()->GetTexture(client_texture_id); | 3853 TextureRef* texture_ref = texture_manager()->GetTexture(client_texture_id); |
3924 if (texture_ref) { | 3854 if (texture_ref) { |
3925 *service_texture_id = texture_ref->service_id(); | 3855 *service_texture_id = texture_ref->service_id(); |
3926 return true; | 3856 return true; |
3927 } | 3857 } |
3928 return false; | 3858 return false; |
3929 } | 3859 } |
3930 | 3860 |
3931 uint32 GLES2DecoderImpl::GetTextureUploadCount() { | 3861 uint32 GLES2DecoderImpl::GetTextureUploadCount() { |
3932 return texture_state_.texture_upload_count + | 3862 return texture_state_.texture_upload_count; |
3933 async_pixel_transfer_manager_->GetTextureUploadCount(); | |
3934 } | 3863 } |
3935 | 3864 |
3936 base::TimeDelta GLES2DecoderImpl::GetTotalTextureUploadTime() { | 3865 base::TimeDelta GLES2DecoderImpl::GetTotalTextureUploadTime() { |
3937 return texture_state_.total_texture_upload_time + | 3866 return texture_state_.total_texture_upload_time; |
3938 async_pixel_transfer_manager_->GetTotalTextureUploadTime(); | |
3939 } | 3867 } |
3940 | 3868 |
3941 base::TimeDelta GLES2DecoderImpl::GetTotalProcessingCommandsTime() { | 3869 base::TimeDelta GLES2DecoderImpl::GetTotalProcessingCommandsTime() { |
3942 return total_processing_commands_time_; | 3870 return total_processing_commands_time_; |
3943 } | 3871 } |
3944 | 3872 |
3945 void GLES2DecoderImpl::AddProcessingCommandsTime(base::TimeDelta time) { | 3873 void GLES2DecoderImpl::AddProcessingCommandsTime(base::TimeDelta time) { |
3946 total_processing_commands_time_ += time; | 3874 total_processing_commands_time_ += time; |
3947 } | 3875 } |
3948 | 3876 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4073 offscreen_saved_frame_buffer_.reset(); | 4001 offscreen_saved_frame_buffer_.reset(); |
4074 offscreen_saved_color_texture_.reset(); | 4002 offscreen_saved_color_texture_.reset(); |
4075 offscreen_resolved_frame_buffer_.reset(); | 4003 offscreen_resolved_frame_buffer_.reset(); |
4076 offscreen_resolved_color_texture_.reset(); | 4004 offscreen_resolved_color_texture_.reset(); |
4077 | 4005 |
4078 // Need to release these before releasing |group_| which may own the | 4006 // Need to release these before releasing |group_| which may own the |
4079 // ShaderTranslatorCache. | 4007 // ShaderTranslatorCache. |
4080 fragment_translator_ = NULL; | 4008 fragment_translator_ = NULL; |
4081 vertex_translator_ = NULL; | 4009 vertex_translator_ = NULL; |
4082 | 4010 |
4083 // Should destroy the transfer manager before the texture manager held | |
4084 // by the context group. | |
4085 async_pixel_transfer_manager_.reset(); | |
4086 | |
4087 // Destroy the GPU Tracer which may own some in process GPU Timings. | 4011 // Destroy the GPU Tracer which may own some in process GPU Timings. |
4088 if (gpu_tracer_) { | 4012 if (gpu_tracer_) { |
4089 gpu_tracer_->Destroy(have_context); | 4013 gpu_tracer_->Destroy(have_context); |
4090 gpu_tracer_.reset(); | 4014 gpu_tracer_.reset(); |
4091 } | 4015 } |
4092 | 4016 |
4093 if (group_.get()) { | 4017 if (group_.get()) { |
4094 framebuffer_manager()->RemoveObserver(this); | 4018 framebuffer_manager()->RemoveObserver(this); |
4095 group_->Destroy(this, have_context); | 4019 group_->Destroy(this, have_context); |
4096 group_ = NULL; | 4020 group_ = NULL; |
(...skipping 6200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10297 Texture* texture = texture_ref->texture(); | 10221 Texture* texture = texture_ref->texture(); |
10298 GLenum type = 0; | 10222 GLenum type = 0; |
10299 GLenum format = 0; | 10223 GLenum format = 0; |
10300 if (!texture->GetLevelType(target, level, &type, &format) || | 10224 if (!texture->GetLevelType(target, level, &type, &format) || |
10301 !texture->ValidForTexture( | 10225 !texture->ValidForTexture( |
10302 target, level, xoffset, yoffset, 0, width, height, 1, type)) { | 10226 target, level, xoffset, yoffset, 0, width, height, 1, type)) { |
10303 LOCAL_SET_GL_ERROR( | 10227 LOCAL_SET_GL_ERROR( |
10304 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); | 10228 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); |
10305 return; | 10229 return; |
10306 } | 10230 } |
10307 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { | |
10308 LOCAL_SET_GL_ERROR( | |
10309 GL_INVALID_OPERATION, | |
10310 "glCopyTexSubImage2D", "async upload pending for texture"); | |
10311 return; | |
10312 } | |
10313 | 10231 |
10314 // Check we have compatible formats. | 10232 // Check we have compatible formats. |
10315 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 10233 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
10316 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 10234 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
10317 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); | 10235 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); |
10318 | 10236 |
10319 if (!channels_needed || | 10237 if (!channels_needed || |
10320 (channels_needed & channels_exist) != channels_needed) { | 10238 (channels_needed & channels_exist) != channels_needed) { |
10321 LOCAL_SET_GL_ERROR( | 10239 LOCAL_SET_GL_ERROR( |
10322 GL_INVALID_OPERATION, "glCopyTexSubImage2D", "incompatible format"); | 10240 GL_INVALID_OPERATION, "glCopyTexSubImage2D", "incompatible format"); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10459 if (!texture_manager()->ValidateTextureParameters(state_.GetErrorState(), | 10377 if (!texture_manager()->ValidateTextureParameters(state_.GetErrorState(), |
10460 function_name, format, type, internal_format, level)) { | 10378 function_name, format, type, internal_format, level)) { |
10461 return false; | 10379 return false; |
10462 } | 10380 } |
10463 if (type != current_type) { | 10381 if (type != current_type) { |
10464 LOCAL_SET_GL_ERROR( | 10382 LOCAL_SET_GL_ERROR( |
10465 GL_INVALID_OPERATION, | 10383 GL_INVALID_OPERATION, |
10466 function_name, "type does not match type of texture."); | 10384 function_name, "type does not match type of texture."); |
10467 return false; | 10385 return false; |
10468 } | 10386 } |
10469 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { | |
10470 LOCAL_SET_GL_ERROR( | |
10471 GL_INVALID_OPERATION, | |
10472 function_name, "async upload pending for texture"); | |
10473 return false; | |
10474 } | |
10475 if (!texture->ValidForTexture( | 10387 if (!texture->ValidForTexture( |
10476 target, level, xoffset, yoffset, 0, width, height, 1, type)) { | 10388 target, level, xoffset, yoffset, 0, width, height, 1, type)) { |
10477 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions."); | 10389 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions."); |
10478 return false; | 10390 return false; |
10479 } | 10391 } |
10480 if ((GLES2Util::GetChannelsForFormat(format) & | 10392 if ((GLES2Util::GetChannelsForFormat(format) & |
10481 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 | 10393 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 |
10482 && !feature_info_->IsES3Enabled()) { | 10394 && !feature_info_->IsES3Enabled()) { |
10483 LOCAL_SET_GL_ERROR( | 10395 LOCAL_SET_GL_ERROR( |
10484 GL_INVALID_OPERATION, | 10396 GL_INVALID_OPERATION, |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11730 pending_readpixel_fences_.front()->callbacks; | 11642 pending_readpixel_fences_.front()->callbacks; |
11731 pending_readpixel_fences_.pop(); | 11643 pending_readpixel_fences_.pop(); |
11732 for (size_t i = 0; i < callbacks.size(); i++) { | 11644 for (size_t i = 0; i < callbacks.size(); i++) { |
11733 callbacks[i].Run(); | 11645 callbacks[i].Run(); |
11734 } | 11646 } |
11735 } | 11647 } |
11736 } | 11648 } |
11737 | 11649 |
11738 bool GLES2DecoderImpl::HasMoreIdleWork() { | 11650 bool GLES2DecoderImpl::HasMoreIdleWork() { |
11739 return !pending_readpixel_fences_.empty() || | 11651 return !pending_readpixel_fences_.empty() || |
11740 async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers() || | 11652 gpu_tracer_->HasTracesToProcess(); |
11741 gpu_tracer_->HasTracesToProcess(); | |
11742 } | 11653 } |
11743 | 11654 |
11744 void GLES2DecoderImpl::PerformIdleWork() { | 11655 void GLES2DecoderImpl::PerformIdleWork() { |
11745 gpu_tracer_->ProcessTraces(); | 11656 gpu_tracer_->ProcessTraces(); |
11746 ProcessPendingReadPixels(false); | 11657 ProcessPendingReadPixels(false); |
11747 if (!async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers()) | |
11748 return; | |
11749 async_pixel_transfer_manager_->ProcessMorePendingTransfers(); | |
11750 ProcessFinishedAsyncTransfers(); | |
11751 } | 11658 } |
11752 | 11659 |
11753 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32 immediate_data_size, | 11660 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(uint32 immediate_data_size, |
11754 const void* cmd_data) { | 11661 const void* cmd_data) { |
11755 const gles2::cmds::BeginQueryEXT& c = | 11662 const gles2::cmds::BeginQueryEXT& c = |
11756 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); | 11663 *static_cast<const gles2::cmds::BeginQueryEXT*>(cmd_data); |
11757 GLenum target = static_cast<GLenum>(c.target); | 11664 GLenum target = static_cast<GLenum>(c.target); |
11758 GLuint client_id = static_cast<GLuint>(c.id); | 11665 GLuint client_id = static_cast<GLuint>(c.id); |
11759 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); | 11666 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); |
11760 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); | 11667 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); |
11761 | 11668 |
11762 switch (target) { | 11669 switch (target) { |
11763 case GL_COMMANDS_ISSUED_CHROMIUM: | 11670 case GL_COMMANDS_ISSUED_CHROMIUM: |
11764 case GL_LATENCY_QUERY_CHROMIUM: | 11671 case GL_LATENCY_QUERY_CHROMIUM: |
11765 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: | |
11766 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: | 11672 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
11767 case GL_GET_ERROR_QUERY_CHROMIUM: | 11673 case GL_GET_ERROR_QUERY_CHROMIUM: |
11768 break; | 11674 break; |
11769 case GL_COMMANDS_COMPLETED_CHROMIUM: | 11675 case GL_COMMANDS_COMPLETED_CHROMIUM: |
11770 if (!features().chromium_sync_query) { | 11676 if (!features().chromium_sync_query) { |
11771 LOCAL_SET_GL_ERROR( | 11677 LOCAL_SET_GL_ERROR( |
11772 GL_INVALID_OPERATION, "glBeginQueryEXT", | 11678 GL_INVALID_OPERATION, "glBeginQueryEXT", |
11773 "not enabled for commands completed queries"); | 11679 "not enabled for commands completed queries"); |
11774 return error::kNoError; | 11680 return error::kNoError; |
11775 } | 11681 } |
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13765 | 13671 |
13766 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM | 13672 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM |
13767 ? state_.projection_matrix | 13673 ? state_.projection_matrix |
13768 : state_.modelview_matrix; | 13674 : state_.modelview_matrix; |
13769 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); | 13675 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); |
13770 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV | 13676 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV |
13771 // since the values of the _NV and _CHROMIUM tokens match. | 13677 // since the values of the _NV and _CHROMIUM tokens match. |
13772 glMatrixLoadIdentityEXT(matrix_mode); | 13678 glMatrixLoadIdentityEXT(matrix_mode); |
13773 } | 13679 } |
13774 | 13680 |
13775 bool GLES2DecoderImpl::ValidateAsyncTransfer( | |
13776 const char* function_name, | |
13777 TextureRef* texture_ref, | |
13778 GLenum target, | |
13779 GLint level, | |
13780 const void * data) { | |
13781 // We only support async uploads to 2D textures for now. | |
13782 if (GL_TEXTURE_2D != target) { | |
13783 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | |
13784 return false; | |
13785 } | |
13786 // We only support uploads to level zero for now. | |
13787 if (level != 0) { | |
13788 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "level != 0"); | |
13789 return false; | |
13790 } | |
13791 // A transfer buffer must be bound, even for asyncTexImage2D. | |
13792 if (data == NULL) { | |
13793 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, "buffer == 0"); | |
13794 return false; | |
13795 } | |
13796 // We only support one async transfer in progress. | |
13797 if (!texture_ref || | |
13798 async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { | |
13799 LOCAL_SET_GL_ERROR( | |
13800 GL_INVALID_OPERATION, | |
13801 function_name, "transfer already in progress"); | |
13802 return false; | |
13803 } | |
13804 return true; | |
13805 } | |
13806 | |
13807 base::Closure GLES2DecoderImpl::AsyncUploadTokenCompletionClosure( | |
13808 uint32 async_upload_token, | |
13809 uint32 sync_data_shm_id, | |
13810 uint32 sync_data_shm_offset) { | |
13811 scoped_refptr<gpu::Buffer> buffer = GetSharedMemoryBuffer(sync_data_shm_id); | |
13812 if (!buffer.get() || | |
13813 !buffer->GetDataAddress(sync_data_shm_offset, sizeof(AsyncUploadSync))) | |
13814 return base::Closure(); | |
13815 | |
13816 AsyncMemoryParams mem_params(buffer, | |
13817 sync_data_shm_offset, | |
13818 sizeof(AsyncUploadSync)); | |
13819 | |
13820 scoped_refptr<AsyncUploadTokenCompletionObserver> observer( | |
13821 new AsyncUploadTokenCompletionObserver(async_upload_token)); | |
13822 | |
13823 return base::Bind( | |
13824 &AsyncPixelTransferManager::AsyncNotifyCompletion, | |
13825 base::Unretained(GetAsyncPixelTransferManager()), | |
13826 mem_params, | |
13827 observer); | |
13828 } | |
13829 | |
13830 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( | |
13831 uint32 immediate_data_size, | |
13832 const void* cmd_data) { | |
13833 const gles2::cmds::AsyncTexImage2DCHROMIUM& c = | |
13834 *static_cast<const gles2::cmds::AsyncTexImage2DCHROMIUM*>(cmd_data); | |
13835 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); | |
13836 GLenum target = static_cast<GLenum>(c.target); | |
13837 GLint level = static_cast<GLint>(c.level); | |
13838 GLenum internal_format = static_cast<GLenum>(c.internalformat); | |
13839 GLsizei width = static_cast<GLsizei>(c.width); | |
13840 GLsizei height = static_cast<GLsizei>(c.height); | |
13841 GLint border = static_cast<GLint>(c.border); | |
13842 GLenum format = static_cast<GLenum>(c.format); | |
13843 GLenum type = static_cast<GLenum>(c.type); | |
13844 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); | |
13845 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); | |
13846 uint32 pixels_size; | |
13847 uint32 async_upload_token = static_cast<uint32>(c.async_upload_token); | |
13848 uint32 sync_data_shm_id = static_cast<uint32>(c.sync_data_shm_id); | |
13849 uint32 sync_data_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); | |
13850 | |
13851 base::ScopedClosureRunner scoped_completion_callback; | |
13852 if (async_upload_token) { | |
13853 base::Closure completion_closure = | |
13854 AsyncUploadTokenCompletionClosure(async_upload_token, | |
13855 sync_data_shm_id, | |
13856 sync_data_shm_offset); | |
13857 if (completion_closure.is_null()) | |
13858 return error::kInvalidArguments; | |
13859 | |
13860 scoped_completion_callback.Reset(completion_closure); | |
13861 } | |
13862 | |
13863 // TODO(epenner): Move this and copies of this memory validation | |
13864 // into ValidateTexImage2D step. | |
13865 if (!GLES2Util::ComputeImageDataSizes( | |
13866 width, height, 1, format, type, state_.unpack_alignment, &pixels_size, | |
13867 NULL, NULL)) { | |
13868 return error::kOutOfBounds; | |
13869 } | |
13870 const void* pixels = NULL; | |
13871 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { | |
13872 pixels = GetSharedMemoryAs<const void*>( | |
13873 pixels_shm_id, pixels_shm_offset, pixels_size); | |
13874 if (!pixels) { | |
13875 return error::kOutOfBounds; | |
13876 } | |
13877 } | |
13878 | |
13879 TextureManager::DoTexImageArguments args = { | |
13880 target, level, internal_format, width, height, 1, border, format, type, | |
13881 pixels, pixels_size, TextureManager::DoTexImageArguments::kTexImage2D }; | |
13882 TextureRef* texture_ref; | |
13883 // All the normal glTexSubImage2D validation. | |
13884 if (!texture_manager()->ValidateTexImage( | |
13885 &state_, "glAsyncTexImage2DCHROMIUM", args, &texture_ref)) { | |
13886 return error::kNoError; | |
13887 } | |
13888 | |
13889 // Extra async validation. | |
13890 Texture* texture = texture_ref->texture(); | |
13891 if (!ValidateAsyncTransfer( | |
13892 "glAsyncTexImage2DCHROMIUM", texture_ref, target, level, pixels)) | |
13893 return error::kNoError; | |
13894 | |
13895 // Don't allow async redefinition of a textures. | |
13896 if (texture->IsDefined()) { | |
13897 LOCAL_SET_GL_ERROR( | |
13898 GL_INVALID_OPERATION, | |
13899 "glAsyncTexImage2DCHROMIUM", "already defined"); | |
13900 return error::kNoError; | |
13901 } | |
13902 | |
13903 if (!EnsureGPUMemoryAvailable(pixels_size)) { | |
13904 LOCAL_SET_GL_ERROR( | |
13905 GL_OUT_OF_MEMORY, "glAsyncTexImage2DCHROMIUM", "out of memory"); | |
13906 return error::kNoError; | |
13907 } | |
13908 | |
13909 // Setup the parameters. | |
13910 AsyncTexImage2DParams tex_params = { | |
13911 target, level, static_cast<GLenum>(internal_format), | |
13912 width, height, border, format, type}; | |
13913 AsyncMemoryParams mem_params( | |
13914 GetSharedMemoryBuffer(c.pixels_shm_id), c.pixels_shm_offset, pixels_size); | |
13915 | |
13916 // Set up the async state if needed, and make the texture | |
13917 // immutable so the async state stays valid. The level info | |
13918 // is set up lazily when the transfer completes. | |
13919 AsyncPixelTransferDelegate* delegate = | |
13920 async_pixel_transfer_manager_->CreatePixelTransferDelegate(texture_ref, | |
13921 tex_params); | |
13922 texture->SetImmutable(true); | |
13923 | |
13924 delegate->AsyncTexImage2D( | |
13925 tex_params, | |
13926 mem_params, | |
13927 base::Bind(&TextureManager::SetLevelInfoFromParams, | |
13928 // The callback is only invoked if the transfer delegate still | |
13929 // exists, which implies through manager->texture_ref->state | |
13930 // ownership that both of these pointers are valid. | |
13931 base::Unretained(texture_manager()), | |
13932 base::Unretained(texture_ref), | |
13933 tex_params)); | |
13934 return error::kNoError; | |
13935 } | |
13936 | |
13937 error::Error GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM( | |
13938 uint32 immediate_data_size, | |
13939 const void* cmd_data) { | |
13940 const gles2::cmds::AsyncTexSubImage2DCHROMIUM& c = | |
13941 *static_cast<const gles2::cmds::AsyncTexSubImage2DCHROMIUM*>(cmd_data); | |
13942 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM"); | |
13943 GLenum target = static_cast<GLenum>(c.target); | |
13944 GLint level = static_cast<GLint>(c.level); | |
13945 GLint xoffset = static_cast<GLint>(c.xoffset); | |
13946 GLint yoffset = static_cast<GLint>(c.yoffset); | |
13947 GLsizei width = static_cast<GLsizei>(c.width); | |
13948 GLsizei height = static_cast<GLsizei>(c.height); | |
13949 GLenum format = static_cast<GLenum>(c.format); | |
13950 GLenum type = static_cast<GLenum>(c.type); | |
13951 uint32 async_upload_token = static_cast<uint32>(c.async_upload_token); | |
13952 uint32 sync_data_shm_id = static_cast<uint32>(c.sync_data_shm_id); | |
13953 uint32 sync_data_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); | |
13954 | |
13955 base::ScopedClosureRunner scoped_completion_callback; | |
13956 if (async_upload_token) { | |
13957 base::Closure completion_closure = | |
13958 AsyncUploadTokenCompletionClosure(async_upload_token, | |
13959 sync_data_shm_id, | |
13960 sync_data_shm_offset); | |
13961 if (completion_closure.is_null()) | |
13962 return error::kInvalidArguments; | |
13963 | |
13964 scoped_completion_callback.Reset(completion_closure); | |
13965 } | |
13966 | |
13967 // TODO(epenner): Move this and copies of this memory validation | |
13968 // into ValidateTexSubImage2D step. | |
13969 uint32 data_size; | |
13970 if (!GLES2Util::ComputeImageDataSizes( | |
13971 width, height, 1, format, type, state_.unpack_alignment, &data_size, | |
13972 NULL, NULL)) { | |
13973 return error::kOutOfBounds; | |
13974 } | |
13975 const void* pixels = GetSharedMemoryAs<const void*>( | |
13976 c.data_shm_id, c.data_shm_offset, data_size); | |
13977 | |
13978 // All the normal glTexSubImage2D validation. | |
13979 error::Error error = error::kNoError; | |
13980 if (!ValidateTexSubImage2D(&error, "glAsyncTexSubImage2DCHROMIUM", | |
13981 target, level, xoffset, yoffset, width, height, format, type, pixels)) { | |
13982 return error; | |
13983 } | |
13984 | |
13985 // Extra async validation. | |
13986 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | |
13987 &state_, target); | |
13988 Texture* texture = texture_ref->texture(); | |
13989 if (!ValidateAsyncTransfer( | |
13990 "glAsyncTexSubImage2DCHROMIUM", texture_ref, target, level, pixels)) | |
13991 return error::kNoError; | |
13992 | |
13993 // Guarantee async textures are always 'cleared' as follows: | |
13994 // - AsyncTexImage2D can not redefine an existing texture | |
13995 // - AsyncTexImage2D must initialize the entire image via non-null buffer. | |
13996 // - AsyncTexSubImage2D clears synchronously if not already cleared. | |
13997 // - Textures become immutable after an async call. | |
13998 // This way we know in all cases that an async texture is always clear. | |
13999 if (!texture->SafeToRenderFrom()) { | |
14000 if (!texture_manager()->ClearTextureLevel(this, texture_ref, | |
14001 target, level)) { | |
14002 LOCAL_SET_GL_ERROR( | |
14003 GL_OUT_OF_MEMORY, | |
14004 "glAsyncTexSubImage2DCHROMIUM", "dimensions too big"); | |
14005 return error::kNoError; | |
14006 } | |
14007 } | |
14008 | |
14009 // Setup the parameters. | |
14010 AsyncTexSubImage2DParams tex_params = {target, level, xoffset, yoffset, | |
14011 width, height, format, type}; | |
14012 AsyncMemoryParams mem_params( | |
14013 GetSharedMemoryBuffer(c.data_shm_id), c.data_shm_offset, data_size); | |
14014 AsyncPixelTransferDelegate* delegate = | |
14015 async_pixel_transfer_manager_->GetPixelTransferDelegate(texture_ref); | |
14016 if (!delegate) { | |
14017 // TODO(epenner): We may want to enforce exclusive use | |
14018 // of async APIs in which case this should become an error, | |
14019 // (the texture should have been async defined). | |
14020 AsyncTexImage2DParams define_params = {target, level, | |
14021 0, 0, 0, 0, 0, 0}; | |
14022 texture->GetLevelSize( | |
14023 target, level, &define_params.width, &define_params.height, nullptr); | |
14024 texture->GetLevelType( | |
14025 target, level, &define_params.type, &define_params.internal_format); | |
14026 // Set up the async state if needed, and make the texture | |
14027 // immutable so the async state stays valid. | |
14028 delegate = async_pixel_transfer_manager_->CreatePixelTransferDelegate( | |
14029 texture_ref, define_params); | |
14030 texture->SetImmutable(true); | |
14031 } | |
14032 | |
14033 delegate->AsyncTexSubImage2D(tex_params, mem_params); | |
14034 return error::kNoError; | |
14035 } | |
14036 | |
14037 error::Error GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM( | |
14038 uint32 immediate_data_size, | |
14039 const void* cmd_data) { | |
14040 const gles2::cmds::WaitAsyncTexImage2DCHROMIUM& c = | |
14041 *static_cast<const gles2::cmds::WaitAsyncTexImage2DCHROMIUM*>(cmd_data); | |
14042 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM"); | |
14043 GLenum target = static_cast<GLenum>(c.target); | |
14044 | |
14045 if (GL_TEXTURE_2D != target) { | |
14046 LOCAL_SET_GL_ERROR( | |
14047 GL_INVALID_ENUM, "glWaitAsyncTexImage2DCHROMIUM", "target"); | |
14048 return error::kNoError; | |
14049 } | |
14050 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | |
14051 &state_, target); | |
14052 if (!texture_ref) { | |
14053 LOCAL_SET_GL_ERROR( | |
14054 GL_INVALID_OPERATION, | |
14055 "glWaitAsyncTexImage2DCHROMIUM", "unknown texture"); | |
14056 return error::kNoError; | |
14057 } | |
14058 AsyncPixelTransferDelegate* delegate = | |
14059 async_pixel_transfer_manager_->GetPixelTransferDelegate(texture_ref); | |
14060 if (!delegate) { | |
14061 LOCAL_SET_GL_ERROR( | |
14062 GL_INVALID_OPERATION, | |
14063 "glWaitAsyncTexImage2DCHROMIUM", "No async transfer started"); | |
14064 return error::kNoError; | |
14065 } | |
14066 delegate->WaitForTransferCompletion(); | |
14067 ProcessFinishedAsyncTransfers(); | |
14068 return error::kNoError; | |
14069 } | |
14070 | |
14071 error::Error GLES2DecoderImpl::HandleWaitAllAsyncTexImage2DCHROMIUM( | |
14072 uint32 immediate_data_size, | |
14073 const void* data) { | |
14074 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleWaitAsyncTexImage2DCHROMIUM"); | |
14075 | |
14076 GetAsyncPixelTransferManager()->WaitAllAsyncTexImage2D(); | |
14077 ProcessFinishedAsyncTransfers(); | |
14078 return error::kNoError; | |
14079 } | |
14080 | |
14081 error::Error GLES2DecoderImpl::HandleUniformBlockBinding( | 13681 error::Error GLES2DecoderImpl::HandleUniformBlockBinding( |
14082 uint32_t immediate_data_size, const void* cmd_data) { | 13682 uint32_t immediate_data_size, const void* cmd_data) { |
14083 if (!unsafe_es3_apis_enabled()) | 13683 if (!unsafe_es3_apis_enabled()) |
14084 return error::kUnknownCommand; | 13684 return error::kUnknownCommand; |
14085 const gles2::cmds::UniformBlockBinding& c = | 13685 const gles2::cmds::UniformBlockBinding& c = |
14086 *static_cast<const gles2::cmds::UniformBlockBinding*>(cmd_data); | 13686 *static_cast<const gles2::cmds::UniformBlockBinding*>(cmd_data); |
14087 GLuint client_id = c.program; | 13687 GLuint client_id = c.program; |
14088 GLuint index = static_cast<GLuint>(c.index); | 13688 GLuint index = static_cast<GLuint>(c.index); |
14089 GLuint binding = static_cast<GLuint>(c.binding); | 13689 GLuint binding = static_cast<GLuint>(c.binding); |
14090 Program* program = GetProgramInfoNotShader( | 13690 Program* program = GetProgramInfoNotShader( |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14787 return error::kNoError; | 14387 return error::kNoError; |
14788 } | 14388 } |
14789 | 14389 |
14790 // Include the auto-generated part of this file. We split this because it means | 14390 // Include the auto-generated part of this file. We split this because it means |
14791 // we can easily edit the non-auto generated parts right here in this file | 14391 // we can easily edit the non-auto generated parts right here in this file |
14792 // instead of having to edit some template or the code generator. | 14392 // instead of having to edit some template or the code generator. |
14793 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 14393 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
14794 | 14394 |
14795 } // namespace gles2 | 14395 } // namespace gles2 |
14796 } // namespace gpu | 14396 } // namespace gpu |
OLD | NEW |