| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 static bool StringIsValidForGLES(const char* str) { | 272 static bool StringIsValidForGLES(const char* str) { |
| 273 for (; *str; ++str) { | 273 for (; *str; ++str) { |
| 274 if (!CharacterIsValidForGLES(*str)) { | 274 if (!CharacterIsValidForGLES(*str)) { |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 return true; | 278 return true; |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Wrapper for glEnable/glDisable that doesn't suck. |
| 282 static void EnableDisable(GLenum pname, bool enable) { |
| 283 if (enable) { |
| 284 glEnable(pname); |
| 285 } else { |
| 286 glDisable(pname); |
| 287 } |
| 288 } |
| 289 |
| 281 // This class prevents any GL errors that occur when it is in scope from | 290 // This class prevents any GL errors that occur when it is in scope from |
| 282 // being reported to the client. | 291 // being reported to the client. |
| 283 class ScopedGLErrorSuppressor { | 292 class ScopedGLErrorSuppressor { |
| 284 public: | 293 public: |
| 285 explicit ScopedGLErrorSuppressor( | 294 explicit ScopedGLErrorSuppressor( |
| 286 const char* function_name, ErrorState* error_state); | 295 const char* function_name, ErrorState* error_state); |
| 287 ~ScopedGLErrorSuppressor(); | 296 ~ScopedGLErrorSuppressor(); |
| 288 private: | 297 private: |
| 289 const char* function_name_; | 298 const char* function_name_; |
| 290 ErrorState* error_state_; | 299 ErrorState* error_state_; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 virtual void SetShaderCacheCallback( | 654 virtual void SetShaderCacheCallback( |
| 646 const ShaderCacheCallback& callback) OVERRIDE; | 655 const ShaderCacheCallback& callback) OVERRIDE; |
| 647 virtual void SetWaitSyncPointCallback( | 656 virtual void SetWaitSyncPointCallback( |
| 648 const WaitSyncPointCallback& callback) OVERRIDE; | 657 const WaitSyncPointCallback& callback) OVERRIDE; |
| 649 | 658 |
| 650 virtual AsyncPixelTransferManager* | 659 virtual AsyncPixelTransferManager* |
| 651 GetAsyncPixelTransferManager() OVERRIDE; | 660 GetAsyncPixelTransferManager() OVERRIDE; |
| 652 virtual void ResetAsyncPixelTransferManagerForTest() OVERRIDE; | 661 virtual void ResetAsyncPixelTransferManagerForTest() OVERRIDE; |
| 653 virtual void SetAsyncPixelTransferManagerForTest( | 662 virtual void SetAsyncPixelTransferManagerForTest( |
| 654 AsyncPixelTransferManager* manager) OVERRIDE; | 663 AsyncPixelTransferManager* manager) OVERRIDE; |
| 655 virtual void SetIgnoreCachedStateForTest(bool ignore) OVERRIDE; | |
| 656 void ProcessFinishedAsyncTransfers(); | 664 void ProcessFinishedAsyncTransfers(); |
| 657 | 665 |
| 658 virtual bool GetServiceTextureId(uint32 client_texture_id, | 666 virtual bool GetServiceTextureId(uint32 client_texture_id, |
| 659 uint32* service_texture_id) OVERRIDE; | 667 uint32* service_texture_id) OVERRIDE; |
| 660 | 668 |
| 661 virtual uint32 GetTextureUploadCount() OVERRIDE; | 669 virtual uint32 GetTextureUploadCount() OVERRIDE; |
| 662 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE; | 670 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE; |
| 663 virtual base::TimeDelta GetTotalProcessingCommandsTime() OVERRIDE; | 671 virtual base::TimeDelta GetTotalProcessingCommandsTime() OVERRIDE; |
| 664 virtual void AddProcessingCommandsTime(base::TimeDelta) OVERRIDE; | 672 virtual void AddProcessingCommandsTime(base::TimeDelta) OVERRIDE; |
| 665 | 673 |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1917 return; | 1925 return; |
| 1918 } | 1926 } |
| 1919 } | 1927 } |
| 1920 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); | 1928 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); |
| 1921 } else { | 1929 } else { |
| 1922 targetid = decoder_->offscreen_saved_frame_buffer_->id(); | 1930 targetid = decoder_->offscreen_saved_frame_buffer_->id(); |
| 1923 } | 1931 } |
| 1924 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); | 1932 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); |
| 1925 const int width = decoder_->offscreen_size_.width(); | 1933 const int width = decoder_->offscreen_size_.width(); |
| 1926 const int height = decoder_->offscreen_size_.height(); | 1934 const int height = decoder_->offscreen_size_.height(); |
| 1927 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 1935 glDisable(GL_SCISSOR_TEST); |
| 1928 decoder->BlitFramebufferHelper(0, | 1936 decoder->BlitFramebufferHelper(0, |
| 1929 0, | 1937 0, |
| 1930 width, | 1938 width, |
| 1931 height, | 1939 height, |
| 1932 0, | 1940 0, |
| 1933 0, | 1941 0, |
| 1934 width, | 1942 width, |
| 1935 height, | 1943 height, |
| 1936 GL_COLOR_BUFFER_BIT, | 1944 GL_COLOR_BUFFER_BIT, |
| 1937 GL_NEAREST); | 1945 GL_NEAREST); |
| 1938 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 1946 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
| 1939 } | 1947 } |
| 1940 | 1948 |
| 1941 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 1949 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { |
| 1942 if (!resolve_and_bind_) | 1950 if (!resolve_and_bind_) |
| 1943 return; | 1951 return; |
| 1944 | 1952 |
| 1945 ScopedGLErrorSuppressor suppressor( | 1953 ScopedGLErrorSuppressor suppressor( |
| 1946 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); | 1954 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); |
| 1947 decoder_->RestoreCurrentFramebufferBindings(); | 1955 decoder_->RestoreCurrentFramebufferBindings(); |
| 1948 if (decoder_->state_.enable_flags.scissor_test) { | 1956 if (decoder_->state_.enable_flags.scissor_test) { |
| 1949 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 1957 glEnable(GL_SCISSOR_TEST); |
| 1950 } | 1958 } |
| 1951 } | 1959 } |
| 1952 | 1960 |
| 1953 BackTexture::BackTexture( | 1961 BackTexture::BackTexture( |
| 1954 MemoryTracker* memory_tracker, | 1962 MemoryTracker* memory_tracker, |
| 1955 ContextState* state) | 1963 ContextState* state) |
| 1956 : memory_tracker_(memory_tracker, MemoryTracker::kUnmanaged), | 1964 : memory_tracker_(memory_tracker, MemoryTracker::kUnmanaged), |
| 1957 state_(state), | 1965 state_(state), |
| 1958 bytes_allocated_(0), | 1966 bytes_allocated_(0), |
| 1959 id_(0) { | 1967 id_(0) { |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 OnFboChanged(); | 3063 OnFboChanged(); |
| 3056 } | 3064 } |
| 3057 | 3065 |
| 3058 bool GLES2DecoderImpl::CheckFramebufferValid( | 3066 bool GLES2DecoderImpl::CheckFramebufferValid( |
| 3059 Framebuffer* framebuffer, | 3067 Framebuffer* framebuffer, |
| 3060 GLenum target, const char* func_name) { | 3068 GLenum target, const char* func_name) { |
| 3061 if (!framebuffer) { | 3069 if (!framebuffer) { |
| 3062 if (backbuffer_needs_clear_bits_) { | 3070 if (backbuffer_needs_clear_bits_) { |
| 3063 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( | 3071 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( |
| 3064 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); | 3072 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); |
| 3065 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 3073 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 3066 glClearStencil(0); | 3074 glClearStencil(0); |
| 3067 glStencilMask(-1); | 3075 glStencilMask(-1); |
| 3068 glClearDepth(1.0f); | 3076 glClearDepth(1.0f); |
| 3069 state_.SetDeviceDepthMask(GL_TRUE); | 3077 glDepthMask(true); |
| 3070 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 3078 glDisable(GL_SCISSOR_TEST); |
| 3071 glClear(backbuffer_needs_clear_bits_); | 3079 glClear(backbuffer_needs_clear_bits_); |
| 3072 backbuffer_needs_clear_bits_ = 0; | 3080 backbuffer_needs_clear_bits_ = 0; |
| 3073 RestoreClearState(); | 3081 RestoreClearState(); |
| 3074 } | 3082 } |
| 3075 return true; | 3083 return true; |
| 3076 } | 3084 } |
| 3077 | 3085 |
| 3078 if (framebuffer_manager()->IsComplete(framebuffer)) { | 3086 if (framebuffer_manager()->IsComplete(framebuffer)) { |
| 3079 return true; | 3087 return true; |
| 3080 } | 3088 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3563 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 3571 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
| 3564 << "because offscreen FBO was incomplete."; | 3572 << "because offscreen FBO was incomplete."; |
| 3565 return false; | 3573 return false; |
| 3566 } | 3574 } |
| 3567 | 3575 |
| 3568 // Clear the target frame buffer. | 3576 // Clear the target frame buffer. |
| 3569 { | 3577 { |
| 3570 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); | 3578 ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); |
| 3571 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( | 3579 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( |
| 3572 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); | 3580 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); |
| 3573 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 3581 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 3574 glClearStencil(0); | 3582 glClearStencil(0); |
| 3575 state_.SetDeviceStencilMaskSeparate(GL_FRONT, -1); | 3583 glStencilMaskSeparate(GL_FRONT, -1); |
| 3576 state_.SetDeviceStencilMaskSeparate(GL_BACK, -1); | 3584 glStencilMaskSeparate(GL_BACK, -1); |
| 3577 glClearDepth(0); | 3585 glClearDepth(0); |
| 3578 state_.SetDeviceDepthMask(GL_TRUE); | 3586 glDepthMask(GL_TRUE); |
| 3579 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 3587 glDisable(GL_SCISSOR_TEST); |
| 3580 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 3588 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 3581 RestoreClearState(); | 3589 RestoreClearState(); |
| 3582 } | 3590 } |
| 3583 | 3591 |
| 3584 // Destroy the offscreen resolved framebuffers. | 3592 // Destroy the offscreen resolved framebuffers. |
| 3585 if (offscreen_resolved_frame_buffer_.get()) | 3593 if (offscreen_resolved_frame_buffer_.get()) |
| 3586 offscreen_resolved_frame_buffer_->Destroy(); | 3594 offscreen_resolved_frame_buffer_->Destroy(); |
| 3587 if (offscreen_resolved_color_texture_.get()) | 3595 if (offscreen_resolved_color_texture_.get()) |
| 3588 offscreen_resolved_color_texture_->Destroy(); | 3596 offscreen_resolved_color_texture_->Destroy(); |
| 3589 offscreen_resolved_color_texture_.reset(); | 3597 offscreen_resolved_color_texture_.reset(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3832 } | 3840 } |
| 3833 if (offscreen_target_frame_buffer_.get()) { | 3841 if (offscreen_target_frame_buffer_.get()) { |
| 3834 return offscreen_target_stencil_format_ != 0 || | 3842 return offscreen_target_stencil_format_ != 0 || |
| 3835 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; | 3843 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; |
| 3836 } | 3844 } |
| 3837 return back_buffer_has_stencil_; | 3845 return back_buffer_has_stencil_; |
| 3838 } | 3846 } |
| 3839 | 3847 |
| 3840 void GLES2DecoderImpl::ApplyDirtyState() { | 3848 void GLES2DecoderImpl::ApplyDirtyState() { |
| 3841 if (framebuffer_state_.clear_state_dirty) { | 3849 if (framebuffer_state_.clear_state_dirty) { |
| 3842 bool have_alpha = BoundFramebufferHasColorAttachmentWithAlpha(true); | 3850 glColorMask( |
| 3843 state_.SetDeviceColorMask(state_.color_mask_red, | 3851 state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue, |
| 3844 state_.color_mask_green, | 3852 state_.color_mask_alpha && |
| 3845 state_.color_mask_blue, | 3853 BoundFramebufferHasColorAttachmentWithAlpha(true)); |
| 3846 state_.color_mask_alpha && have_alpha); | |
| 3847 | |
| 3848 bool have_depth = BoundFramebufferHasDepthAttachment(); | 3854 bool have_depth = BoundFramebufferHasDepthAttachment(); |
| 3849 state_.SetDeviceDepthMask(state_.depth_mask && have_depth); | 3855 glDepthMask(state_.depth_mask && have_depth); |
| 3850 | 3856 EnableDisable(GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); |
| 3851 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3857 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
| 3852 state_.SetDeviceStencilMaskSeparate( | 3858 glStencilMaskSeparate( |
| 3853 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); | 3859 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); |
| 3854 state_.SetDeviceStencilMaskSeparate( | 3860 glStencilMaskSeparate( |
| 3855 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); | 3861 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); |
| 3856 | 3862 EnableDisable( |
| 3857 state_.SetDeviceCapabilityState( | |
| 3858 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); | |
| 3859 state_.SetDeviceCapabilityState( | |
| 3860 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); | 3863 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); |
| 3864 EnableDisable(GL_CULL_FACE, state_.enable_flags.cull_face); |
| 3865 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| 3866 EnableDisable(GL_BLEND, state_.enable_flags.blend); |
| 3861 framebuffer_state_.clear_state_dirty = false; | 3867 framebuffer_state_.clear_state_dirty = false; |
| 3862 } | 3868 } |
| 3863 } | 3869 } |
| 3864 | 3870 |
| 3865 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { | 3871 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { |
| 3866 return (offscreen_target_frame_buffer_.get()) | 3872 return (offscreen_target_frame_buffer_.get()) |
| 3867 ? offscreen_target_frame_buffer_->id() | 3873 ? offscreen_target_frame_buffer_->id() |
| 3868 : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0); | 3874 : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0); |
| 3869 } | 3875 } |
| 3870 | 3876 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3923 glDisableVertexAttribArray(i); | 3929 glDisableVertexAttribArray(i); |
| 3924 if(features().angle_instanced_arrays) | 3930 if(features().angle_instanced_arrays) |
| 3925 glVertexAttribDivisorANGLE(i, 0); | 3931 glVertexAttribDivisorANGLE(i, 0); |
| 3926 } | 3932 } |
| 3927 } | 3933 } |
| 3928 | 3934 |
| 3929 void GLES2DecoderImpl::RestoreAllAttributes() const { | 3935 void GLES2DecoderImpl::RestoreAllAttributes() const { |
| 3930 state_.RestoreVertexAttribs(); | 3936 state_.RestoreVertexAttribs(); |
| 3931 } | 3937 } |
| 3932 | 3938 |
| 3933 void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) { | |
| 3934 state_.SetIgnoreCachedStateForTest(ignore); | |
| 3935 } | |
| 3936 | |
| 3937 void GLES2DecoderImpl::OnFboChanged() const { | 3939 void GLES2DecoderImpl::OnFboChanged() const { |
| 3938 if (workarounds().restore_scissor_on_fbo_change) | 3940 if (workarounds().restore_scissor_on_fbo_change) |
| 3939 state_.fbo_binding_for_scissor_workaround_dirty_ = true; | 3941 state_.fbo_binding_for_scissor_workaround_dirty_ = true; |
| 3940 } | 3942 } |
| 3941 | 3943 |
| 3942 // Called after the FBO is checked for completeness. | 3944 // Called after the FBO is checked for completeness. |
| 3943 void GLES2DecoderImpl::OnUseFramebuffer() const { | 3945 void GLES2DecoderImpl::OnUseFramebuffer() const { |
| 3944 if (state_.fbo_binding_for_scissor_workaround_dirty_) { | 3946 if (state_.fbo_binding_for_scissor_workaround_dirty_) { |
| 3945 state_.fbo_binding_for_scissor_workaround_dirty_ = false; | 3947 state_.fbo_binding_for_scissor_workaround_dirty_ = false; |
| 3946 // The driver forgets the correct scissor when modifying the FBO binding. | 3948 // The driver forgets the correct scissor when modifying the FBO binding. |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5020 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); | 5022 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); |
| 5021 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id()); | 5023 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, framebuffer->service_id()); |
| 5022 } | 5024 } |
| 5023 GLbitfield clear_bits = 0; | 5025 GLbitfield clear_bits = 0; |
| 5024 if (framebuffer->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { | 5026 if (framebuffer->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { |
| 5025 glClearColor( | 5027 glClearColor( |
| 5026 0.0f, 0.0f, 0.0f, | 5028 0.0f, 0.0f, 0.0f, |
| 5027 (GLES2Util::GetChannelsForFormat( | 5029 (GLES2Util::GetChannelsForFormat( |
| 5028 framebuffer->GetColorAttachmentFormat()) & 0x0008) != 0 ? 0.0f : | 5030 framebuffer->GetColorAttachmentFormat()) & 0x0008) != 0 ? 0.0f : |
| 5029 1.0f); | 5031 1.0f); |
| 5030 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 5032 glColorMask(true, true, true, true); |
| 5031 clear_bits |= GL_COLOR_BUFFER_BIT; | 5033 clear_bits |= GL_COLOR_BUFFER_BIT; |
| 5032 } | 5034 } |
| 5033 | 5035 |
| 5034 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || | 5036 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || |
| 5035 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | 5037 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { |
| 5036 glClearStencil(0); | 5038 glClearStencil(0); |
| 5037 glStencilMask(-1); | 5039 glStencilMask(-1); |
| 5038 clear_bits |= GL_STENCIL_BUFFER_BIT; | 5040 clear_bits |= GL_STENCIL_BUFFER_BIT; |
| 5039 } | 5041 } |
| 5040 | 5042 |
| 5041 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) || | 5043 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) || |
| 5042 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | 5044 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { |
| 5043 glClearDepth(1.0f); | 5045 glClearDepth(1.0f); |
| 5044 state_.SetDeviceDepthMask(GL_TRUE); | 5046 glDepthMask(true); |
| 5045 clear_bits |= GL_DEPTH_BUFFER_BIT; | 5047 clear_bits |= GL_DEPTH_BUFFER_BIT; |
| 5046 } | 5048 } |
| 5047 | 5049 |
| 5048 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 5050 glDisable(GL_SCISSOR_TEST); |
| 5049 glClear(clear_bits); | 5051 glClear(clear_bits); |
| 5050 | 5052 |
| 5051 framebuffer_manager()->MarkAttachmentsAsCleared( | 5053 framebuffer_manager()->MarkAttachmentsAsCleared( |
| 5052 framebuffer, renderbuffer_manager(), texture_manager()); | 5054 framebuffer, renderbuffer_manager(), texture_manager()); |
| 5053 | 5055 |
| 5054 RestoreClearState(); | 5056 RestoreClearState(); |
| 5055 | 5057 |
| 5056 if (target == GL_READ_FRAMEBUFFER_EXT) { | 5058 if (target == GL_READ_FRAMEBUFFER_EXT) { |
| 5057 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, framebuffer->service_id()); | 5059 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, framebuffer->service_id()); |
| 5058 Framebuffer* draw_framebuffer = | 5060 Framebuffer* draw_framebuffer = |
| 5059 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 5061 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
| 5060 GLuint service_id = draw_framebuffer ? draw_framebuffer->service_id() : | 5062 GLuint service_id = draw_framebuffer ? draw_framebuffer->service_id() : |
| 5061 GetBackbufferServiceId(); | 5063 GetBackbufferServiceId(); |
| 5062 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id); | 5064 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id); |
| 5063 } | 5065 } |
| 5064 } | 5066 } |
| 5065 | 5067 |
| 5066 void GLES2DecoderImpl::RestoreClearState() { | 5068 void GLES2DecoderImpl::RestoreClearState() { |
| 5067 framebuffer_state_.clear_state_dirty = true; | 5069 framebuffer_state_.clear_state_dirty = true; |
| 5068 glClearColor( | 5070 glClearColor( |
| 5069 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, | 5071 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, |
| 5070 state_.color_clear_alpha); | 5072 state_.color_clear_alpha); |
| 5071 glClearStencil(state_.stencil_clear); | 5073 glClearStencil(state_.stencil_clear); |
| 5072 glClearDepth(state_.depth_clear); | 5074 glClearDepth(state_.depth_clear); |
| 5073 if (state_.enable_flags.scissor_test) { | 5075 if (state_.enable_flags.scissor_test) { |
| 5074 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 5076 glEnable(GL_SCISSOR_TEST); |
| 5075 } | 5077 } |
| 5076 } | 5078 } |
| 5077 | 5079 |
| 5078 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { | 5080 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { |
| 5079 Framebuffer* framebuffer = | 5081 Framebuffer* framebuffer = |
| 5080 GetFramebufferInfoForTarget(target); | 5082 GetFramebufferInfoForTarget(target); |
| 5081 if (!framebuffer) { | 5083 if (!framebuffer) { |
| 5082 return GL_FRAMEBUFFER_COMPLETE; | 5084 return GL_FRAMEBUFFER_COMPLETE; |
| 5083 } | 5085 } |
| 5084 GLenum completeness = framebuffer->IsPossiblyComplete(); | 5086 GLenum completeness = framebuffer->IsPossiblyComplete(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5241 LOCAL_SET_GL_ERROR( | 5243 LOCAL_SET_GL_ERROR( |
| 5242 GL_INVALID_OPERATION, | 5244 GL_INVALID_OPERATION, |
| 5243 "glBlitFramebufferCHROMIUM", "function not available"); | 5245 "glBlitFramebufferCHROMIUM", "function not available"); |
| 5244 return; | 5246 return; |
| 5245 } | 5247 } |
| 5246 | 5248 |
| 5247 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) { | 5249 if (!CheckBoundFramebuffersValid("glBlitFramebufferCHROMIUM")) { |
| 5248 return; | 5250 return; |
| 5249 } | 5251 } |
| 5250 | 5252 |
| 5251 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 5253 glDisable(GL_SCISSOR_TEST); |
| 5252 BlitFramebufferHelper( | 5254 BlitFramebufferHelper( |
| 5253 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 5255 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 5254 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 5256 EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| 5255 state_.enable_flags.scissor_test); | |
| 5256 } | 5257 } |
| 5257 | 5258 |
| 5258 void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper( | 5259 void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper( |
| 5259 const FeatureInfo* feature_info, | 5260 const FeatureInfo* feature_info, |
| 5260 GLenum target, | 5261 GLenum target, |
| 5261 GLsizei samples, | 5262 GLsizei samples, |
| 5262 GLenum internal_format, | 5263 GLenum internal_format, |
| 5263 GLsizei width, | 5264 GLsizei width, |
| 5264 GLsizei height) { | 5265 GLsizei height) { |
| 5265 // TODO(sievers): This could be resolved at the GL binding level, but the | 5266 // TODO(sievers): This could be resolved at the GL binding level, but the |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5484 } | 5485 } |
| 5485 | 5486 |
| 5486 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); | 5487 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); |
| 5487 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 5488 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 5488 GL_RENDERBUFFER, renderbuffer); | 5489 GL_RENDERBUFFER, renderbuffer); |
| 5489 | 5490 |
| 5490 // Cache current state and reset it to the values we require. | 5491 // Cache current state and reset it to the values we require. |
| 5491 GLboolean scissor_enabled = false; | 5492 GLboolean scissor_enabled = false; |
| 5492 glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled); | 5493 glGetBooleanv(GL_SCISSOR_TEST, &scissor_enabled); |
| 5493 if (scissor_enabled) | 5494 if (scissor_enabled) |
| 5494 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 5495 glDisable(GL_SCISSOR_TEST); |
| 5495 | 5496 |
| 5496 GLboolean color_mask[4] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}; | 5497 GLboolean color_mask[4] = {true, true, true, true}; |
| 5497 glGetBooleanv(GL_COLOR_WRITEMASK, color_mask); | 5498 glGetBooleanv(GL_COLOR_WRITEMASK, color_mask); |
| 5498 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 5499 glColorMask(true, true, true, true); |
| 5499 | 5500 |
| 5500 GLfloat clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | 5501 GLfloat clear_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; |
| 5501 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); | 5502 glGetFloatv(GL_COLOR_CLEAR_VALUE, clear_color); |
| 5502 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); | 5503 glClearColor(1.0f, 0.0f, 1.0f, 1.0f); |
| 5503 | 5504 |
| 5504 // Clear the buffer to the desired key color. | 5505 // Clear the buffer to the desired key color. |
| 5505 glClear(GL_COLOR_BUFFER_BIT); | 5506 glClear(GL_COLOR_BUFFER_BIT); |
| 5506 | 5507 |
| 5507 // Blit from the multisample buffer to a standard texture. | 5508 // Blit from the multisample buffer to a standard texture. |
| 5508 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); | 5509 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); |
| 5509 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); | 5510 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); |
| 5510 | 5511 |
| 5511 BlitFramebufferHelper( | 5512 BlitFramebufferHelper( |
| 5512 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); | 5513 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 5513 | 5514 |
| 5514 // Read a pixel from the buffer. | 5515 // Read a pixel from the buffer. |
| 5515 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); | 5516 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); |
| 5516 | 5517 |
| 5517 unsigned char pixel[3] = {0, 0, 0}; | 5518 unsigned char pixel[3] = {0, 0, 0}; |
| 5518 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); | 5519 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); |
| 5519 | 5520 |
| 5520 // Detach the renderbuffer. | 5521 // Detach the renderbuffer. |
| 5521 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); | 5522 glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_multisample_); |
| 5522 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 5523 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 5523 GL_RENDERBUFFER, 0); | 5524 GL_RENDERBUFFER, 0); |
| 5524 | 5525 |
| 5525 // Restore cached state. | 5526 // Restore cached state. |
| 5526 if (scissor_enabled) | 5527 if (scissor_enabled) |
| 5527 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 5528 glEnable(GL_SCISSOR_TEST); |
| 5528 | 5529 |
| 5529 state_.SetDeviceColorMask( | 5530 glColorMask(color_mask[0], color_mask[1], color_mask[2], color_mask[3]); |
| 5530 color_mask[0], color_mask[1], color_mask[2], color_mask[3]); | |
| 5531 glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); | 5531 glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); |
| 5532 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer); | 5532 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, draw_framebuffer); |
| 5533 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer); | 5533 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_framebuffer); |
| 5534 | 5534 |
| 5535 // Return true if the pixel matched the desired key color. | 5535 // Return true if the pixel matched the desired key color. |
| 5536 return (pixel[0] == 0xFF && | 5536 return (pixel[0] == 0xFF && |
| 5537 pixel[1] == 0x00 && | 5537 pixel[1] == 0x00 && |
| 5538 pixel[2] == 0xFF); | 5538 pixel[2] == 0xFF); |
| 5539 } | 5539 } |
| 5540 | 5540 |
| (...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7836 glFramebufferTexture2DEXT( | 7836 glFramebufferTexture2DEXT( |
| 7837 GL_DRAW_FRAMEBUFFER_EXT, attachment, target, service_id, level); | 7837 GL_DRAW_FRAMEBUFFER_EXT, attachment, target, service_id, level); |
| 7838 // ANGLE promises a depth only attachment ok. | 7838 // ANGLE promises a depth only attachment ok. |
| 7839 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != | 7839 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != |
| 7840 GL_FRAMEBUFFER_COMPLETE) { | 7840 GL_FRAMEBUFFER_COMPLETE) { |
| 7841 return false; | 7841 return false; |
| 7842 } | 7842 } |
| 7843 glClearStencil(0); | 7843 glClearStencil(0); |
| 7844 glStencilMask(-1); | 7844 glStencilMask(-1); |
| 7845 glClearDepth(1.0f); | 7845 glClearDepth(1.0f); |
| 7846 state_.SetDeviceDepthMask(GL_TRUE); | 7846 glDepthMask(true); |
| 7847 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 7847 glDisable(GL_SCISSOR_TEST); |
| 7848 glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0)); | 7848 glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0)); |
| 7849 | 7849 |
| 7850 RestoreClearState(); | 7850 RestoreClearState(); |
| 7851 | 7851 |
| 7852 glDeleteFramebuffersEXT(1, &fb); | 7852 glDeleteFramebuffersEXT(1, &fb); |
| 7853 Framebuffer* framebuffer = | 7853 Framebuffer* framebuffer = |
| 7854 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 7854 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
| 7855 GLuint fb_service_id = | 7855 GLuint fb_service_id = |
| 7856 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); | 7856 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); |
| 7857 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); | 7857 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); |
| (...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9163 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 9163 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); |
| 9164 return; | 9164 return; |
| 9165 } | 9165 } |
| 9166 | 9166 |
| 9167 // Clear the offscreen color texture. | 9167 // Clear the offscreen color texture. |
| 9168 // TODO(piman): Is this still necessary? | 9168 // TODO(piman): Is this still necessary? |
| 9169 { | 9169 { |
| 9170 ScopedFrameBufferBinder binder(this, | 9170 ScopedFrameBufferBinder binder(this, |
| 9171 offscreen_saved_frame_buffer_->id()); | 9171 offscreen_saved_frame_buffer_->id()); |
| 9172 glClearColor(0, 0, 0, 0); | 9172 glClearColor(0, 0, 0, 0); |
| 9173 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 9173 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 9174 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 9174 glDisable(GL_SCISSOR_TEST); |
| 9175 glClear(GL_COLOR_BUFFER_BIT); | 9175 glClear(GL_COLOR_BUFFER_BIT); |
| 9176 RestoreClearState(); | 9176 RestoreClearState(); |
| 9177 } | 9177 } |
| 9178 } | 9178 } |
| 9179 | 9179 |
| 9180 UpdateParentTextureInfo(); | 9180 UpdateParentTextureInfo(); |
| 9181 } | 9181 } |
| 9182 | 9182 |
| 9183 if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) | 9183 if (offscreen_size_.width() == 0 || offscreen_size_.height() == 0) |
| 9184 return; | 9184 return; |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10796 } | 10796 } |
| 10797 } | 10797 } |
| 10798 | 10798 |
| 10799 // Include the auto-generated part of this file. We split this because it means | 10799 // Include the auto-generated part of this file. We split this because it means |
| 10800 // we can easily edit the non-auto generated parts right here in this file | 10800 // we can easily edit the non-auto generated parts right here in this file |
| 10801 // instead of having to edit some template or the code generator. | 10801 // instead of having to edit some template or the code generator. |
| 10802 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10802 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10803 | 10803 |
| 10804 } // namespace gles2 | 10804 } // namespace gles2 |
| 10805 } // namespace gpu | 10805 } // namespace gpu |
| OLD | NEW |