OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 void RestoreBufferBindings() const override { | 614 void RestoreBufferBindings() const override { |
615 state_.RestoreBufferBindings(); | 615 state_.RestoreBufferBindings(); |
616 } | 616 } |
617 void RestoreGlobalState() const override { state_.RestoreGlobalState(NULL); } | 617 void RestoreGlobalState() const override { state_.RestoreGlobalState(NULL); } |
618 void RestoreProgramBindings() const override { | 618 void RestoreProgramBindings() const override { |
619 state_.RestoreProgramBindings(); | 619 state_.RestoreProgramBindings(); |
620 } | 620 } |
621 void RestoreTextureUnitBindings(unsigned unit) const override { | 621 void RestoreTextureUnitBindings(unsigned unit) const override { |
622 state_.RestoreTextureUnitBindings(unit, NULL); | 622 state_.RestoreTextureUnitBindings(unit, NULL); |
623 } | 623 } |
624 void RestoreFramebufferBindings() const override; | 624 void MarkFramebufferBindingsChanged() override; |
625 void RestoreRenderbufferBindings() override; | 625 void RestoreRenderbufferBindings() override; |
626 void RestoreTextureState(unsigned service_id) const override; | 626 void RestoreTextureState(unsigned service_id) const override; |
627 | 627 |
628 void ClearAllAttributes() const override; | 628 void ClearAllAttributes() const override; |
629 void RestoreAllAttributes() const override; | 629 void RestoreAllAttributes() const override; |
630 | 630 |
631 QueryManager* GetQueryManager() override { return query_manager_.get(); } | 631 QueryManager* GetQueryManager() override { return query_manager_.get(); } |
632 VertexArrayManager* GetVertexArrayManager() override { | 632 VertexArrayManager* GetVertexArrayManager() override { |
633 return vertex_array_manager_.get(); | 633 return vertex_array_manager_.get(); |
634 } | 634 } |
(...skipping 26 matching lines...) Expand all Loading... | |
661 void ProcessFinishedAsyncTransfers(); | 661 void ProcessFinishedAsyncTransfers(); |
662 | 662 |
663 bool GetServiceTextureId(uint32_t client_texture_id, | 663 bool GetServiceTextureId(uint32_t client_texture_id, |
664 uint32_t* service_texture_id) override; | 664 uint32_t* service_texture_id) override; |
665 | 665 |
666 uint32_t GetTextureUploadCount() override; | 666 uint32_t GetTextureUploadCount() override; |
667 base::TimeDelta GetTotalTextureUploadTime() override; | 667 base::TimeDelta GetTotalTextureUploadTime() override; |
668 base::TimeDelta GetTotalProcessingCommandsTime() override; | 668 base::TimeDelta GetTotalProcessingCommandsTime() override; |
669 void AddProcessingCommandsTime(base::TimeDelta) override; | 669 void AddProcessingCommandsTime(base::TimeDelta) override; |
670 | 670 |
671 // Restores the current state to the user's settings. | |
672 void RestoreCurrentFramebufferBindings(); | |
673 | |
674 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. | 671 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
675 void ApplyDirtyState(); | 672 void ApplyDirtyState(); |
676 | 673 |
677 // These check the state of the currently bound framebuffer or the | 674 // These check the state of the currently bound framebuffer or the |
678 // backbuffer if no framebuffer is bound. | 675 // backbuffer if no framebuffer is bound. |
679 // Check with all attached and enabled color attachments. | 676 // Check with all attached and enabled color attachments. |
680 bool BoundFramebufferHasColorAttachmentWithAlpha(); | 677 bool BoundFramebufferHasColorAttachmentWithAlpha(); |
681 bool BoundFramebufferHasDepthAttachment(); | 678 bool BoundFramebufferHasDepthAttachment(); |
682 bool BoundFramebufferHasStencilAttachment(); | 679 bool BoundFramebufferHasStencilAttachment(); |
683 | 680 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
745 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 742 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
746 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 743 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
747 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 744 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
748 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 745 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
749 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 746 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
750 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 747 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
751 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 748 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
752 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); | 749 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); |
753 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); | 750 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); |
754 | 751 |
755 // Workarounds | 752 void ApplyFramebufferBindings(GLenum target); |
756 void OnFboChanged() const; | 753 void OnUseFramebuffer(); |
757 void OnUseFramebuffer() const; | |
758 | 754 |
759 error::ContextLostReason GetContextLostReasonFromResetStatus( | 755 error::ContextLostReason GetContextLostReasonFromResetStatus( |
760 GLenum reset_status) const; | 756 GLenum reset_status) const; |
761 | 757 |
762 // TODO(gman): Cache these pointers? | 758 // TODO(gman): Cache these pointers? |
763 BufferManager* buffer_manager() { | 759 BufferManager* buffer_manager() { |
764 return group_->buffer_manager(); | 760 return group_->buffer_manager(); |
765 } | 761 } |
766 | 762 |
767 RenderbufferManager* renderbuffer_manager() { | 763 RenderbufferManager* renderbuffer_manager() { |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1751 NOTREACHED(); | 1747 NOTREACHED(); |
1752 return 0; | 1748 return 0; |
1753 } | 1749 } |
1754 | 1750 |
1755 // Gets the framebuffer info for a particular target. | 1751 // Gets the framebuffer info for a particular target. |
1756 Framebuffer* GetFramebufferInfoForTarget(GLenum target) { | 1752 Framebuffer* GetFramebufferInfoForTarget(GLenum target) { |
1757 Framebuffer* framebuffer = NULL; | 1753 Framebuffer* framebuffer = NULL; |
1758 switch (target) { | 1754 switch (target) { |
1759 case GL_FRAMEBUFFER: | 1755 case GL_FRAMEBUFFER: |
1760 case GL_DRAW_FRAMEBUFFER_EXT: | 1756 case GL_DRAW_FRAMEBUFFER_EXT: |
1761 framebuffer = framebuffer_state_.bound_draw_framebuffer.get(); | 1757 framebuffer = framebuffer_state_.bound_draw_framebuffer(); |
1762 break; | 1758 break; |
1763 case GL_READ_FRAMEBUFFER_EXT: | 1759 case GL_READ_FRAMEBUFFER_EXT: |
1764 framebuffer = framebuffer_state_.bound_read_framebuffer.get(); | 1760 framebuffer = framebuffer_state_.bound_read_framebuffer(); |
1765 break; | 1761 break; |
1766 default: | 1762 default: |
1767 NOTREACHED(); | 1763 NOTREACHED(); |
1768 break; | 1764 break; |
1769 } | 1765 } |
1770 return framebuffer; | 1766 return framebuffer; |
1771 } | 1767 } |
1772 | 1768 |
1773 Renderbuffer* GetRenderbufferInfoForTarget( | 1769 Renderbuffer* GetRenderbufferInfoForTarget( |
1774 GLenum target) { | 1770 GLenum target) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1841 const FeatureInfo::FeatureFlags& features() const { | 1837 const FeatureInfo::FeatureFlags& features() const { |
1842 return feature_info_->feature_flags(); | 1838 return feature_info_->feature_flags(); |
1843 } | 1839 } |
1844 | 1840 |
1845 const GpuDriverBugWorkarounds& workarounds() const { | 1841 const GpuDriverBugWorkarounds& workarounds() const { |
1846 return feature_info_->workarounds(); | 1842 return feature_info_->workarounds(); |
1847 } | 1843 } |
1848 | 1844 |
1849 bool ShouldDeferDraws() { | 1845 bool ShouldDeferDraws() { |
1850 return !offscreen_target_frame_buffer_.get() && | 1846 return !offscreen_target_frame_buffer_.get() && |
1851 framebuffer_state_.bound_draw_framebuffer.get() == NULL && | 1847 !framebuffer_state_.bound_draw_framebuffer() && |
1852 surface_->DeferDraws(); | 1848 surface_->DeferDraws(); |
1853 } | 1849 } |
1854 | 1850 |
1855 bool ShouldDeferReads() { | 1851 bool ShouldDeferReads() { |
1856 return !offscreen_target_frame_buffer_.get() && | 1852 return !offscreen_target_frame_buffer_.get() && |
1857 framebuffer_state_.bound_read_framebuffer.get() == NULL && | 1853 !framebuffer_state_.bound_read_framebuffer() && |
1858 surface_->DeferDraws(); | 1854 surface_->DeferDraws(); |
1859 } | 1855 } |
1860 | 1856 |
1861 bool IsRobustnessSupported() { | 1857 bool IsRobustnessSupported() { |
1862 return has_robustness_extension_ && | 1858 return has_robustness_extension_ && |
1863 context_->WasAllocatedUsingRobustnessExtension(); | 1859 context_->WasAllocatedUsingRobustnessExtension(); |
1864 } | 1860 } |
1865 | 1861 |
1866 error::Error WillAccessBoundFramebufferForDraw() { | 1862 error::Error WillAccessBoundFramebufferForDraw() { |
1867 if (ShouldDeferDraws()) | 1863 if (ShouldDeferDraws()) |
1868 return error::kDeferCommandUntilLater; | 1864 return error::kDeferCommandUntilLater; |
1869 if (!offscreen_target_frame_buffer_.get() && | 1865 if (!offscreen_target_frame_buffer_.get() && |
1870 !framebuffer_state_.bound_draw_framebuffer.get() && | 1866 !framebuffer_state_.bound_draw_framebuffer() && |
1871 !surface_->SetBackbufferAllocation(true)) | 1867 !surface_->SetBackbufferAllocation(true)) |
1872 return error::kLostContext; | 1868 return error::kLostContext; |
1873 return error::kNoError; | 1869 return error::kNoError; |
1874 } | 1870 } |
1875 | 1871 |
1876 error::Error WillAccessBoundFramebufferForRead() { | 1872 error::Error WillAccessBoundFramebufferForRead() { |
1877 if (ShouldDeferReads()) | 1873 if (ShouldDeferReads()) |
1878 return error::kDeferCommandUntilLater; | 1874 return error::kDeferCommandUntilLater; |
1879 if (!offscreen_target_frame_buffer_.get() && | 1875 if (!offscreen_target_frame_buffer_.get() && |
1880 !framebuffer_state_.bound_read_framebuffer.get() && | 1876 !framebuffer_state_.bound_read_framebuffer() && |
1881 !surface_->SetBackbufferAllocation(true)) | 1877 !surface_->SetBackbufferAllocation(true)) |
1882 return error::kLostContext; | 1878 return error::kLostContext; |
1883 return error::kNoError; | 1879 return error::kNoError; |
1884 } | 1880 } |
1885 | 1881 |
1886 bool BackBufferHasAlpha() const { | 1882 bool BackBufferHasAlpha() const { |
1887 if (back_buffer_draw_buffer_ == GL_NONE) | 1883 if (back_buffer_draw_buffer_ == GL_NONE) |
1888 return false; | 1884 return false; |
1889 if (offscreen_target_frame_buffer_.get()) { | 1885 if (offscreen_target_frame_buffer_.get()) { |
1890 return (offscreen_target_color_format_ == GL_RGBA || | 1886 return (offscreen_target_color_format_ == GL_RGBA || |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2207 "ScopedRenderBufferBinder::dtor", state_->GetErrorState()); | 2203 "ScopedRenderBufferBinder::dtor", state_->GetErrorState()); |
2208 state_->RestoreRenderbufferBindings(); | 2204 state_->RestoreRenderbufferBindings(); |
2209 } | 2205 } |
2210 | 2206 |
2211 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, | 2207 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, |
2212 GLuint id) | 2208 GLuint id) |
2213 : decoder_(decoder) { | 2209 : decoder_(decoder) { |
2214 ScopedGLErrorSuppressor suppressor( | 2210 ScopedGLErrorSuppressor suppressor( |
2215 "ScopedFrameBufferBinder::ctor", decoder_->GetErrorState()); | 2211 "ScopedFrameBufferBinder::ctor", decoder_->GetErrorState()); |
2216 glBindFramebufferEXT(GL_FRAMEBUFFER, id); | 2212 glBindFramebufferEXT(GL_FRAMEBUFFER, id); |
2217 decoder->OnFboChanged(); | 2213 decoder->framebuffer_state_.MarkBindingDirty(GL_FRAMEBUFFER); |
2218 } | 2214 } |
2219 | 2215 |
2220 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { | 2216 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { |
2221 ScopedGLErrorSuppressor suppressor( | |
2222 "ScopedFrameBufferBinder::dtor", decoder_->GetErrorState()); | |
2223 decoder_->RestoreCurrentFramebufferBindings(); | |
2224 } | 2217 } |
2225 | 2218 |
2226 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( | 2219 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( |
2227 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) | 2220 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) |
2228 : decoder_(decoder) { | 2221 : decoder_(decoder) { |
2229 resolve_and_bind_ = ( | 2222 resolve_and_bind_ = |
2230 decoder_->offscreen_target_frame_buffer_.get() && | 2223 (decoder_->offscreen_target_frame_buffer_.get() && |
2231 decoder_->IsOffscreenBufferMultisampled() && | 2224 decoder_->IsOffscreenBufferMultisampled() && |
2232 (!decoder_->framebuffer_state_.bound_read_framebuffer.get() || | 2225 (!decoder_->framebuffer_state_.bound_read_framebuffer() || |
2233 enforce_internal_framebuffer)); | 2226 enforce_internal_framebuffer)); |
2234 if (!resolve_and_bind_) | 2227 if (!resolve_and_bind_) { |
2228 decoder_->ApplyFramebufferBindings(GL_READ_FRAMEBUFFER_EXT); | |
2235 return; | 2229 return; |
2230 } | |
2236 | 2231 |
2237 ScopedGLErrorSuppressor suppressor( | 2232 ScopedGLErrorSuppressor suppressor( |
2238 "ScopedResolvedFrameBufferBinder::ctor", decoder_->GetErrorState()); | 2233 "ScopedResolvedFrameBufferBinder::ctor", decoder_->GetErrorState()); |
2239 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, | 2234 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, |
2240 decoder_->offscreen_target_frame_buffer_->id()); | 2235 decoder_->offscreen_target_frame_buffer_->id()); |
2236 decoder->framebuffer_state_.MarkBindingDirty(GL_READ_FRAMEBUFFER_EXT); | |
2241 GLuint targetid; | 2237 GLuint targetid; |
2242 if (internal) { | 2238 if (internal) { |
2243 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { | 2239 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { |
2244 decoder_->offscreen_resolved_frame_buffer_.reset( | 2240 decoder_->offscreen_resolved_frame_buffer_.reset( |
2245 new BackFramebuffer(decoder_)); | 2241 new BackFramebuffer(decoder_)); |
2246 decoder_->offscreen_resolved_frame_buffer_->Create(); | 2242 decoder_->offscreen_resolved_frame_buffer_->Create(); |
2247 decoder_->offscreen_resolved_color_texture_.reset( | 2243 decoder_->offscreen_resolved_color_texture_.reset( |
2248 new BackTexture(decoder->memory_tracker(), &decoder->state_)); | 2244 new BackTexture(decoder->memory_tracker(), &decoder->state_)); |
2249 decoder_->offscreen_resolved_color_texture_->Create(); | 2245 decoder_->offscreen_resolved_color_texture_->Create(); |
2250 | 2246 |
2251 DCHECK(decoder_->offscreen_saved_color_format_); | 2247 DCHECK(decoder_->offscreen_saved_color_format_); |
2252 decoder_->offscreen_resolved_color_texture_->AllocateStorage( | 2248 decoder_->offscreen_resolved_color_texture_->AllocateStorage( |
2253 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_, | 2249 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_, |
2254 false); | 2250 false); |
2255 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture( | 2251 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture( |
2256 decoder_->offscreen_resolved_color_texture_.get()); | 2252 decoder_->offscreen_resolved_color_texture_.get()); |
2257 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() != | 2253 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() != |
2258 GL_FRAMEBUFFER_COMPLETE) { | 2254 GL_FRAMEBUFFER_COMPLETE) { |
2259 LOG(ERROR) << "ScopedResolvedFrameBufferBinder failed " | 2255 LOG(ERROR) << "ScopedResolvedFrameBufferBinder failed " |
2260 << "because offscreen resolved FBO was incomplete."; | 2256 << "because offscreen resolved FBO was incomplete."; |
2261 return; | 2257 return; |
2262 } | 2258 } |
2263 } | 2259 } |
2264 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); | 2260 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); |
2265 } else { | 2261 } else { |
2266 targetid = decoder_->offscreen_saved_frame_buffer_->id(); | 2262 targetid = decoder_->offscreen_saved_frame_buffer_->id(); |
2267 } | 2263 } |
2268 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); | 2264 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); |
2265 // Binding will be marked dirty below. | |
2269 const int width = decoder_->offscreen_size_.width(); | 2266 const int width = decoder_->offscreen_size_.width(); |
2270 const int height = decoder_->offscreen_size_.height(); | 2267 const int height = decoder_->offscreen_size_.height(); |
2271 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 2268 decoder->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
2272 decoder->BlitFramebufferHelper(0, | 2269 decoder->BlitFramebufferHelper(0, |
2273 0, | 2270 0, |
2274 width, | 2271 width, |
2275 height, | 2272 height, |
2276 0, | 2273 0, |
2277 0, | 2274 0, |
2278 width, | 2275 width, |
2279 height, | 2276 height, |
2280 GL_COLOR_BUFFER_BIT, | 2277 GL_COLOR_BUFFER_BIT, |
2281 GL_NEAREST); | 2278 GL_NEAREST); |
2282 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 2279 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
2280 decoder->framebuffer_state_.MarkBindingDirty(GL_FRAMEBUFFER); | |
2283 } | 2281 } |
2284 | 2282 |
2285 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 2283 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { |
2286 if (!resolve_and_bind_) | 2284 if (!resolve_and_bind_) |
2287 return; | 2285 return; |
2288 | 2286 |
2289 ScopedGLErrorSuppressor suppressor( | 2287 ScopedGLErrorSuppressor suppressor( |
2290 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); | 2288 "ScopedResolvedFrameBufferBinder::dtor", decoder_->GetErrorState()); |
2291 decoder_->RestoreCurrentFramebufferBindings(); | |
2292 if (decoder_->state_.enable_flags.scissor_test) { | 2289 if (decoder_->state_.enable_flags.scissor_test) { |
2293 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 2290 decoder_->state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); |
2294 } | 2291 } |
2295 } | 2292 } |
2296 | 2293 |
2297 ScopedFrameBufferReadPixelHelper::ScopedFrameBufferReadPixelHelper( | 2294 ScopedFrameBufferReadPixelHelper::ScopedFrameBufferReadPixelHelper( |
2298 ContextState* state, | 2295 ContextState* state, |
2299 GLES2DecoderImpl* decoder) { | 2296 GLES2DecoderImpl* decoder) { |
2300 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE), | 2297 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE), |
2301 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER)); | 2298 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER)); |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3522 if (buffer && !buffer->IsDeleted()) { | 3519 if (buffer && !buffer->IsDeleted()) { |
3523 buffer->RemoveMappedRange(); | 3520 buffer->RemoveMappedRange(); |
3524 state_.RemoveBoundBuffer(buffer); | 3521 state_.RemoveBoundBuffer(buffer); |
3525 RemoveBuffer(client_ids[ii]); | 3522 RemoveBuffer(client_ids[ii]); |
3526 } | 3523 } |
3527 } | 3524 } |
3528 } | 3525 } |
3529 | 3526 |
3530 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 3527 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
3531 GLsizei n, const GLuint* client_ids) { | 3528 GLsizei n, const GLuint* client_ids) { |
3532 bool supports_separate_framebuffer_binds = | 3529 GLenum target = features().chromium_framebuffer_multisample |
3533 features().chromium_framebuffer_multisample; | 3530 ? GL_DRAW_FRAMEBUFFER_EXT |
3534 | 3531 : GL_FRAMEBUFFER; |
3535 for (GLsizei ii = 0; ii < n; ++ii) { | 3532 for (GLsizei ii = 0; ii < n; ++ii) { |
3536 Framebuffer* framebuffer = | 3533 Framebuffer* framebuffer = |
3537 GetFramebuffer(client_ids[ii]); | 3534 GetFramebuffer(client_ids[ii]); |
3538 if (framebuffer && !framebuffer->IsDeleted()) { | 3535 if (framebuffer && !framebuffer->IsDeleted()) { |
3539 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 3536 if (framebuffer == framebuffer_state_.bound_draw_framebuffer()) { |
3540 GLenum target = supports_separate_framebuffer_binds ? | |
3541 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | |
3542 | |
3543 // Unbind attachments on FBO before deletion. | 3537 // Unbind attachments on FBO before deletion. |
3544 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) | 3538 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) { |
3545 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); | 3539 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); |
3546 | 3540 } |
3547 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 3541 framebuffer_state_.set_bound_draw_framebuffer(nullptr); |
3548 framebuffer_state_.bound_draw_framebuffer = NULL; | |
3549 framebuffer_state_.clear_state_dirty = true; | |
3550 } | 3542 } |
3551 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { | 3543 if (framebuffer == framebuffer_state_.bound_read_framebuffer()) |
3552 framebuffer_state_.bound_read_framebuffer = NULL; | 3544 framebuffer_state_.set_bound_read_framebuffer(nullptr); |
3553 GLenum target = supports_separate_framebuffer_binds ? | |
3554 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | |
3555 glBindFramebufferEXT(target, GetBackbufferServiceId()); | |
3556 } | |
3557 OnFboChanged(); | |
3558 RemoveFramebuffer(client_ids[ii]); | 3545 RemoveFramebuffer(client_ids[ii]); |
3559 } | 3546 } |
3560 } | 3547 } |
3561 } | 3548 } |
3562 | 3549 |
3563 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 3550 void GLES2DecoderImpl::DeleteRenderbuffersHelper( |
3564 GLsizei n, const GLuint* client_ids) { | 3551 GLsizei n, const GLuint* client_ids) { |
3565 bool supports_separate_framebuffer_binds = | 3552 bool supports_separate_framebuffer_binds = |
3566 features().chromium_framebuffer_multisample; | 3553 features().chromium_framebuffer_multisample; |
3567 for (GLsizei ii = 0; ii < n; ++ii) { | 3554 for (GLsizei ii = 0; ii < n; ++ii) { |
3568 Renderbuffer* renderbuffer = | 3555 Renderbuffer* renderbuffer = |
3569 GetRenderbuffer(client_ids[ii]); | 3556 GetRenderbuffer(client_ids[ii]); |
3570 if (renderbuffer && !renderbuffer->IsDeleted()) { | 3557 if (renderbuffer && !renderbuffer->IsDeleted()) { |
3571 if (state_.bound_renderbuffer.get() == renderbuffer) { | 3558 if (state_.bound_renderbuffer.get() == renderbuffer) { |
3572 state_.bound_renderbuffer = NULL; | 3559 state_.bound_renderbuffer = NULL; |
3573 } | 3560 } |
3574 // Unbind from current framebuffers. | 3561 // Unbind from current framebuffers. |
3575 if (supports_separate_framebuffer_binds) { | 3562 if (supports_separate_framebuffer_binds) { |
3576 if (framebuffer_state_.bound_read_framebuffer.get()) { | 3563 if (framebuffer_state_.bound_read_framebuffer()) { |
3577 framebuffer_state_.bound_read_framebuffer | 3564 framebuffer_state_.bound_read_framebuffer()->UnbindRenderbuffer( |
3578 ->UnbindRenderbuffer(GL_READ_FRAMEBUFFER_EXT, renderbuffer); | 3565 GL_READ_FRAMEBUFFER_EXT, renderbuffer); |
3579 } | 3566 } |
3580 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3567 if (framebuffer_state_.bound_draw_framebuffer()) { |
3581 framebuffer_state_.bound_draw_framebuffer | 3568 framebuffer_state_.bound_draw_framebuffer()->UnbindRenderbuffer( |
3582 ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); | 3569 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); |
3583 } | 3570 } |
3584 } else { | 3571 } else { |
3585 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3572 if (framebuffer_state_.bound_draw_framebuffer()) { |
3586 framebuffer_state_.bound_draw_framebuffer | 3573 framebuffer_state_.bound_draw_framebuffer()->UnbindRenderbuffer( |
3587 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); | 3574 GL_FRAMEBUFFER, renderbuffer); |
3588 } | 3575 } |
3589 } | 3576 } |
3590 framebuffer_state_.clear_state_dirty = true; | 3577 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
3591 RemoveRenderbuffer(client_ids[ii]); | 3578 RemoveRenderbuffer(client_ids[ii]); |
3592 } | 3579 } |
3593 } | 3580 } |
3594 } | 3581 } |
3595 | 3582 |
3596 void GLES2DecoderImpl::DeleteTexturesHelper( | 3583 void GLES2DecoderImpl::DeleteTexturesHelper( |
3597 GLsizei n, const GLuint* client_ids) { | 3584 GLsizei n, const GLuint* client_ids) { |
3598 bool supports_separate_framebuffer_binds = | 3585 bool supports_separate_framebuffer_binds = |
3599 features().chromium_framebuffer_multisample; | 3586 features().chromium_framebuffer_multisample; |
3600 for (GLsizei ii = 0; ii < n; ++ii) { | 3587 for (GLsizei ii = 0; ii < n; ++ii) { |
3601 TextureRef* texture_ref = GetTexture(client_ids[ii]); | 3588 TextureRef* texture_ref = GetTexture(client_ids[ii]); |
3602 if (texture_ref) { | 3589 if (texture_ref) { |
3603 Texture* texture = texture_ref->texture(); | 3590 Texture* texture = texture_ref->texture(); |
3604 if (texture->IsAttachedToFramebuffer()) { | 3591 if (texture->IsAttachedToFramebuffer()) { |
3605 framebuffer_state_.clear_state_dirty = true; | 3592 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
3606 } | 3593 } |
3607 // Unbind texture_ref from texture_ref units. | 3594 // Unbind texture_ref from texture_ref units. |
3608 state_.UnbindTexture(texture_ref); | 3595 state_.UnbindTexture(texture_ref); |
3609 | 3596 |
3610 // Unbind from current framebuffers. | 3597 // Unbind from current framebuffers. |
3611 if (supports_separate_framebuffer_binds) { | 3598 if (supports_separate_framebuffer_binds) { |
3612 if (framebuffer_state_.bound_read_framebuffer.get()) { | 3599 if (framebuffer_state_.bound_read_framebuffer()) { |
3613 framebuffer_state_.bound_read_framebuffer | 3600 framebuffer_state_.bound_read_framebuffer()->UnbindTexture( |
3614 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref); | 3601 GL_READ_FRAMEBUFFER_EXT, texture_ref); |
3615 } | 3602 } |
3616 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3603 if (framebuffer_state_.bound_draw_framebuffer()) { |
3617 framebuffer_state_.bound_draw_framebuffer | 3604 framebuffer_state_.bound_draw_framebuffer()->UnbindTexture( |
3618 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref); | 3605 GL_DRAW_FRAMEBUFFER_EXT, texture_ref); |
3619 } | 3606 } |
3620 } else { | 3607 } else { |
3621 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3608 if (framebuffer_state_.bound_draw_framebuffer()) { |
3622 framebuffer_state_.bound_draw_framebuffer | 3609 framebuffer_state_.bound_draw_framebuffer()->UnbindTexture( |
3623 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref); | 3610 GL_FRAMEBUFFER, texture_ref); |
3624 } | 3611 } |
3625 } | 3612 } |
3626 #if defined(OS_MACOSX) | 3613 #if defined(OS_MACOSX) |
3627 GLuint service_id = texture->service_id(); | 3614 GLuint service_id = texture->service_id(); |
3628 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { | 3615 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { |
3629 ReleaseIOSurfaceForTexture(service_id); | 3616 ReleaseIOSurfaceForTexture(service_id); |
3630 } | 3617 } |
3631 #endif | 3618 #endif |
3632 RemoveTexture(client_ids[ii]); | 3619 RemoveTexture(client_ids[ii]); |
3633 } | 3620 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3669 LOG(ERROR) | 3656 LOG(ERROR) |
3670 << " GLES2DecoderImpl: Context reset detected after MakeCurrent."; | 3657 << " GLES2DecoderImpl: Context reset detected after MakeCurrent."; |
3671 group_->LoseContexts(error::kUnknown); | 3658 group_->LoseContexts(error::kUnknown); |
3672 return false; | 3659 return false; |
3673 } | 3660 } |
3674 | 3661 |
3675 ProcessFinishedAsyncTransfers(); | 3662 ProcessFinishedAsyncTransfers(); |
3676 | 3663 |
3677 // Rebind the FBO if it was unbound by the context. | 3664 // Rebind the FBO if it was unbound by the context. |
3678 if (workarounds().unbind_fbo_on_context_switch) | 3665 if (workarounds().unbind_fbo_on_context_switch) |
3679 RestoreFramebufferBindings(); | 3666 MarkFramebufferBindingsChanged(); |
3680 | 3667 |
3681 framebuffer_state_.clear_state_dirty = true; | 3668 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
3682 | 3669 |
3683 // Rebind textures if the service ids may have changed. | 3670 // Rebind textures if the service ids may have changed. |
3684 RestoreAllExternalTextureBindingsIfNeeded(); | 3671 RestoreAllExternalTextureBindingsIfNeeded(); |
3685 | 3672 |
3686 return true; | 3673 return true; |
3687 } | 3674 } |
3688 | 3675 |
3689 void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() { | 3676 void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() { |
3690 ProcessPendingReadPixels(false); | 3677 ProcessPendingReadPixels(false); |
3691 if (engine() && query_manager_.get()) | 3678 if (engine() && query_manager_.get()) |
3692 query_manager_->ProcessPendingTransferQueries(); | 3679 query_manager_->ProcessPendingTransferQueries(); |
3693 } | 3680 } |
3694 | 3681 |
3695 static void RebindCurrentFramebuffer( | |
3696 GLenum target, | |
3697 Framebuffer* framebuffer, | |
3698 GLuint back_buffer_service_id) { | |
3699 GLuint framebuffer_id = framebuffer ? framebuffer->service_id() : 0; | |
3700 | |
3701 if (framebuffer_id == 0) { | |
3702 framebuffer_id = back_buffer_service_id; | |
3703 } | |
3704 | |
3705 glBindFramebufferEXT(target, framebuffer_id); | |
3706 } | |
3707 | |
3708 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { | |
3709 framebuffer_state_.clear_state_dirty = true; | |
3710 | |
3711 if (!features().chromium_framebuffer_multisample) { | |
3712 RebindCurrentFramebuffer( | |
3713 GL_FRAMEBUFFER, | |
3714 framebuffer_state_.bound_draw_framebuffer.get(), | |
3715 GetBackbufferServiceId()); | |
3716 } else { | |
3717 RebindCurrentFramebuffer( | |
3718 GL_READ_FRAMEBUFFER_EXT, | |
3719 framebuffer_state_.bound_read_framebuffer.get(), | |
3720 GetBackbufferServiceId()); | |
3721 RebindCurrentFramebuffer( | |
3722 GL_DRAW_FRAMEBUFFER_EXT, | |
3723 framebuffer_state_.bound_draw_framebuffer.get(), | |
3724 GetBackbufferServiceId()); | |
3725 } | |
3726 OnFboChanged(); | |
3727 } | |
3728 | |
3729 bool GLES2DecoderImpl::CheckFramebufferValid( | 3682 bool GLES2DecoderImpl::CheckFramebufferValid( |
3730 Framebuffer* framebuffer, | 3683 Framebuffer* framebuffer, |
3731 GLenum target, | 3684 GLenum target, |
3732 bool clear_uncleared_images, | 3685 bool clear_uncleared_images, |
3733 const char* func_name) { | 3686 const char* func_name) { |
3734 if (!framebuffer) { | 3687 if (!framebuffer) { |
3735 if (surfaceless_) | 3688 if (surfaceless_) |
3736 return false; | 3689 return false; |
3737 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) { | 3690 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) { |
3738 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f); | 3691 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3801 } | 3754 } |
3802 framebuffer_manager()->MarkAsComplete(framebuffer); | 3755 framebuffer_manager()->MarkAsComplete(framebuffer); |
3803 } | 3756 } |
3804 return true; | 3757 return true; |
3805 } | 3758 } |
3806 | 3759 |
3807 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid( | 3760 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid( |
3808 bool clear_uncleared_images, const char* func_name) { | 3761 bool clear_uncleared_images, const char* func_name) { |
3809 GLenum target = features().chromium_framebuffer_multisample ? | 3762 GLenum target = features().chromium_framebuffer_multisample ? |
3810 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 3763 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
3764 ApplyFramebufferBindings(target); | |
3811 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 3765 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
3812 bool valid = CheckFramebufferValid( | 3766 bool valid = CheckFramebufferValid( |
3813 framebuffer, target, clear_uncleared_images, func_name); | 3767 framebuffer, target, clear_uncleared_images, func_name); |
3814 if (valid && !features().chromium_framebuffer_multisample) | 3768 if (valid && !features().chromium_framebuffer_multisample) |
3815 OnUseFramebuffer(); | 3769 OnUseFramebuffer(); |
3816 return valid; | 3770 return valid; |
3817 } | 3771 } |
3818 | 3772 |
3819 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(const char* func_name) { | 3773 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(const char* func_name) { |
3820 GLenum target = features().chromium_framebuffer_multisample ? | 3774 GLenum target = features().chromium_framebuffer_multisample ? |
3821 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 3775 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
3776 ApplyFramebufferBindings(target); | |
3822 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 3777 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
3823 bool valid = CheckFramebufferValid(framebuffer, target, true, func_name); | 3778 bool valid = CheckFramebufferValid(framebuffer, target, true, func_name); |
3824 return valid; | 3779 return valid; |
3825 } | 3780 } |
3826 | 3781 |
3827 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( | 3782 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
3828 GLenum internalformat) { | 3783 GLenum internalformat) { |
3829 switch (internalformat) { | 3784 switch (internalformat) { |
3830 case GL_SRGB_EXT: | 3785 case GL_SRGB_EXT: |
3831 case GL_SRGB_ALPHA_EXT: | 3786 case GL_SRGB_ALPHA_EXT: |
3832 case GL_SRGB8: | 3787 case GL_SRGB8: |
3833 case GL_SRGB8_ALPHA8: | 3788 case GL_SRGB8_ALPHA8: |
3834 return GL_SRGB; | 3789 return GL_SRGB; |
3835 default: | 3790 default: |
3836 return GL_LINEAR; | 3791 return GL_LINEAR; |
3837 } | 3792 } |
3838 } | 3793 } |
3839 | 3794 |
3840 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( | 3795 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( |
3841 TextureRef* texture, GLint level) { | 3796 TextureRef* texture, GLint level) { |
3842 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? | 3797 Framebuffer* framebuffer = features().chromium_framebuffer_multisample |
3843 framebuffer_state_.bound_read_framebuffer.get() : | 3798 ? framebuffer_state_.bound_read_framebuffer() |
3844 framebuffer_state_.bound_draw_framebuffer.get(); | 3799 : framebuffer_state_.bound_draw_framebuffer(); |
3845 if (!framebuffer) | 3800 if (!framebuffer) |
3846 return false; | 3801 return false; |
3847 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment( | 3802 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment( |
3848 GL_COLOR_ATTACHMENT0); | 3803 GL_COLOR_ATTACHMENT0); |
3849 if (!attachment) | 3804 if (!attachment) |
3850 return false; | 3805 return false; |
3851 return attachment->FormsFeedbackLoop(texture, level); | 3806 return attachment->FormsFeedbackLoop(texture, level); |
3852 } | 3807 } |
3853 | 3808 |
3854 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { | 3809 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4055 state_.default_vertex_attrib_manager = NULL; | 4010 state_.default_vertex_attrib_manager = NULL; |
4056 state_.texture_units.clear(); | 4011 state_.texture_units.clear(); |
4057 state_.sampler_units.clear(); | 4012 state_.sampler_units.clear(); |
4058 state_.bound_array_buffer = NULL; | 4013 state_.bound_array_buffer = NULL; |
4059 state_.bound_copy_read_buffer = NULL; | 4014 state_.bound_copy_read_buffer = NULL; |
4060 state_.bound_copy_write_buffer = NULL; | 4015 state_.bound_copy_write_buffer = NULL; |
4061 state_.bound_pixel_pack_buffer = NULL; | 4016 state_.bound_pixel_pack_buffer = NULL; |
4062 state_.bound_pixel_unpack_buffer = NULL; | 4017 state_.bound_pixel_unpack_buffer = NULL; |
4063 state_.bound_transform_feedback_buffer = NULL; | 4018 state_.bound_transform_feedback_buffer = NULL; |
4064 state_.bound_uniform_buffer = NULL; | 4019 state_.bound_uniform_buffer = NULL; |
4065 framebuffer_state_.bound_read_framebuffer = NULL; | 4020 framebuffer_state_.set_bound_read_framebuffer(nullptr); |
4066 framebuffer_state_.bound_draw_framebuffer = NULL; | 4021 framebuffer_state_.set_bound_draw_framebuffer(nullptr); |
4067 state_.bound_renderbuffer = NULL; | 4022 state_.bound_renderbuffer = NULL; |
4068 | 4023 |
4069 if (offscreen_saved_color_texture_info_.get()) { | 4024 if (offscreen_saved_color_texture_info_.get()) { |
4070 DCHECK(offscreen_target_color_texture_); | 4025 DCHECK(offscreen_target_color_texture_); |
4071 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 4026 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
4072 offscreen_saved_color_texture_->id()); | 4027 offscreen_saved_color_texture_->id()); |
4073 offscreen_saved_color_texture_->Invalidate(); | 4028 offscreen_saved_color_texture_->Invalidate(); |
4074 offscreen_saved_color_texture_info_ = NULL; | 4029 offscreen_saved_color_texture_info_ = NULL; |
4075 } | 4030 } |
4076 if (have_context) { | 4031 if (have_context) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4201 } | 4156 } |
4202 texture_to_io_surface_map_.clear(); | 4157 texture_to_io_surface_map_.clear(); |
4203 #endif | 4158 #endif |
4204 } | 4159 } |
4205 | 4160 |
4206 void GLES2DecoderImpl::SetSurface( | 4161 void GLES2DecoderImpl::SetSurface( |
4207 const scoped_refptr<gfx::GLSurface>& surface) { | 4162 const scoped_refptr<gfx::GLSurface>& surface) { |
4208 DCHECK(context_->IsCurrent(NULL)); | 4163 DCHECK(context_->IsCurrent(NULL)); |
4209 DCHECK(surface_.get()); | 4164 DCHECK(surface_.get()); |
4210 surface_ = surface; | 4165 surface_ = surface; |
4211 RestoreCurrentFramebufferBindings(); | 4166 MarkFramebufferBindingsChanged(); |
4167 // Applying the framebuffer bindings would be possible to be done lazily. | |
4168 // For ease of testing, commit the bindings now. | |
4169 if (!features().chromium_framebuffer_multisample) { | |
4170 ApplyFramebufferBindings(GL_FRAMEBUFFER); | |
4171 } else { | |
4172 ApplyFramebufferBindings(GL_DRAW_FRAMEBUFFER_EXT); | |
4173 ApplyFramebufferBindings(GL_READ_FRAMEBUFFER_EXT); | |
4174 } | |
4212 } | 4175 } |
4213 | 4176 |
4214 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { | 4177 void GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { |
4215 if (!offscreen_saved_color_texture_.get()) { | 4178 if (!offscreen_saved_color_texture_.get()) { |
4216 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; | 4179 LOG(ERROR) << "Called ProduceFrontBuffer on a non-offscreen context"; |
4217 return; | 4180 return; |
4218 } | 4181 } |
4219 if (!offscreen_saved_color_texture_info_.get()) { | 4182 if (!offscreen_saved_color_texture_info_.get()) { |
4220 GLuint service_id = offscreen_saved_color_texture_->id(); | 4183 GLuint service_id = offscreen_saved_color_texture_->id(); |
4221 offscreen_saved_color_texture_info_ = TextureRef::Create( | 4184 offscreen_saved_color_texture_info_ = TextureRef::Create( |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4726 return framebuffer->HasStencilAttachment(); | 4689 return framebuffer->HasStencilAttachment(); |
4727 } | 4690 } |
4728 if (offscreen_target_frame_buffer_.get()) { | 4691 if (offscreen_target_frame_buffer_.get()) { |
4729 return offscreen_target_stencil_format_ != 0 || | 4692 return offscreen_target_stencil_format_ != 0 || |
4730 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; | 4693 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; |
4731 } | 4694 } |
4732 return back_buffer_has_stencil_; | 4695 return back_buffer_has_stencil_; |
4733 } | 4696 } |
4734 | 4697 |
4735 void GLES2DecoderImpl::ApplyDirtyState() { | 4698 void GLES2DecoderImpl::ApplyDirtyState() { |
4736 if (framebuffer_state_.clear_state_dirty) { | 4699 if (framebuffer_state_.is_draw_framebuffer_clear_state_dirty()) { |
4737 bool have_alpha = BoundFramebufferHasColorAttachmentWithAlpha(); | 4700 bool have_alpha = BoundFramebufferHasColorAttachmentWithAlpha(); |
4738 state_.SetDeviceColorMask(state_.color_mask_red, | 4701 state_.SetDeviceColorMask(state_.color_mask_red, |
4739 state_.color_mask_green, | 4702 state_.color_mask_green, |
4740 state_.color_mask_blue, | 4703 state_.color_mask_blue, |
4741 state_.color_mask_alpha && have_alpha); | 4704 state_.color_mask_alpha && have_alpha); |
4742 | 4705 |
4743 bool have_depth = BoundFramebufferHasDepthAttachment(); | 4706 bool have_depth = BoundFramebufferHasDepthAttachment(); |
4744 state_.SetDeviceDepthMask(state_.depth_mask && have_depth); | 4707 state_.SetDeviceDepthMask(state_.depth_mask && have_depth); |
4745 | 4708 |
4746 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 4709 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
4747 state_.SetDeviceStencilMaskSeparate( | 4710 state_.SetDeviceStencilMaskSeparate( |
4748 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); | 4711 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); |
4749 state_.SetDeviceStencilMaskSeparate( | 4712 state_.SetDeviceStencilMaskSeparate( |
4750 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); | 4713 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); |
4751 | 4714 |
4752 state_.SetDeviceCapabilityState( | 4715 state_.SetDeviceCapabilityState( |
4753 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); | 4716 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); |
4754 state_.SetDeviceCapabilityState( | 4717 state_.SetDeviceCapabilityState( |
4755 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); | 4718 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); |
4756 framebuffer_state_.clear_state_dirty = false; | 4719 framebuffer_state_.set_draw_framebuffer_clear_state_dirty(false); |
4757 } | 4720 } |
4758 } | 4721 } |
4759 | 4722 |
4760 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { | 4723 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { |
4761 return (offscreen_target_frame_buffer_.get()) | 4724 return (offscreen_target_frame_buffer_.get()) |
4762 ? offscreen_target_frame_buffer_->id() | 4725 ? offscreen_target_frame_buffer_->id() |
4763 : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0); | 4726 : (surface_.get() ? surface_->GetBackingFrameBufferObject() : 0); |
4764 } | 4727 } |
4765 | 4728 |
4766 void GLES2DecoderImpl::RestoreState(const ContextState* prev_state) { | 4729 void GLES2DecoderImpl::RestoreState(const ContextState* prev_state) { |
4767 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", | 4730 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", |
4768 "context", logger_.GetLogPrefix()); | 4731 "context", logger_.GetLogPrefix()); |
4769 // Restore the Framebuffer first because of bugs in Intel drivers. | 4732 MarkFramebufferBindingsChanged(); |
vmiura
2016/04/28 22:28:20
Based on the previous comment here, we have to ens
| |
4770 // Intel drivers incorrectly clip the viewport settings to | |
4771 // the size of the current framebuffer object. | |
4772 RestoreFramebufferBindings(); | |
4773 state_.RestoreState(prev_state); | 4733 state_.RestoreState(prev_state); |
4774 } | 4734 } |
4775 | 4735 |
4776 void GLES2DecoderImpl::RestoreFramebufferBindings() const { | 4736 void GLES2DecoderImpl::MarkFramebufferBindingsChanged() { |
4777 GLuint service_id = | 4737 framebuffer_state_.MarkBindingDirty(GL_DRAW_FRAMEBUFFER_EXT); |
4778 framebuffer_state_.bound_draw_framebuffer.get() | 4738 framebuffer_state_.MarkBindingDirty(GL_READ_FRAMEBUFFER_EXT); |
4779 ? framebuffer_state_.bound_draw_framebuffer->service_id() | |
4780 : GetBackbufferServiceId(); | |
4781 if (!features().chromium_framebuffer_multisample) { | |
4782 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); | |
4783 } else { | |
4784 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); | |
4785 service_id = framebuffer_state_.bound_read_framebuffer.get() | |
4786 ? framebuffer_state_.bound_read_framebuffer->service_id() | |
4787 : GetBackbufferServiceId(); | |
4788 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); | |
4789 } | |
4790 OnFboChanged(); | |
4791 } | 4739 } |
4792 | 4740 |
4793 void GLES2DecoderImpl::RestoreRenderbufferBindings() { | 4741 void GLES2DecoderImpl::RestoreRenderbufferBindings() { |
4794 state_.RestoreRenderbufferBindings(); | 4742 state_.RestoreRenderbufferBindings(); |
4795 } | 4743 } |
4796 | 4744 |
4797 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { | 4745 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { |
4798 Texture* texture = texture_manager()->GetTextureForServiceId(service_id); | 4746 Texture* texture = texture_manager()->GetTextureForServiceId(service_id); |
4799 if (texture) { | 4747 if (texture) { |
4800 GLenum target = texture->target(); | 4748 GLenum target = texture->target(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4837 force_shader_name_hashing_for_test = force; | 4785 force_shader_name_hashing_for_test = force; |
4838 } | 4786 } |
4839 | 4787 |
4840 // Added specifically for testing backbuffer_needs_clear_bits unittests. | 4788 // Added specifically for testing backbuffer_needs_clear_bits unittests. |
4841 uint32_t GLES2DecoderImpl::GetAndClearBackbufferClearBitsForTest() { | 4789 uint32_t GLES2DecoderImpl::GetAndClearBackbufferClearBitsForTest() { |
4842 uint32_t clear_bits = backbuffer_needs_clear_bits_; | 4790 uint32_t clear_bits = backbuffer_needs_clear_bits_; |
4843 backbuffer_needs_clear_bits_ = 0; | 4791 backbuffer_needs_clear_bits_ = 0; |
4844 return clear_bits; | 4792 return clear_bits; |
4845 } | 4793 } |
4846 | 4794 |
4847 void GLES2DecoderImpl::OnFboChanged() const { | 4795 void GLES2DecoderImpl::ApplyFramebufferBindings(GLenum target) { |
4796 if (!framebuffer_state_.IsBindingDirty(target)) | |
4797 return; | |
4798 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | |
4799 GLuint service_id = | |
4800 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); | |
4801 | |
4802 glBindFramebufferEXT(target, service_id); | |
4803 | |
4804 framebuffer_state_.MarkBindingClean(target); | |
4805 | |
4848 if (workarounds().restore_scissor_on_fbo_change) | 4806 if (workarounds().restore_scissor_on_fbo_change) |
4849 state_.fbo_binding_for_scissor_workaround_dirty = true; | 4807 state_.fbo_binding_for_scissor_workaround_dirty = true; |
4850 } | 4808 } |
4851 | 4809 |
4852 // Called after the FBO is checked for completeness. | 4810 // Called after the FBO is checked for completeness. |
4853 void GLES2DecoderImpl::OnUseFramebuffer() const { | 4811 void GLES2DecoderImpl::OnUseFramebuffer() { |
4854 if (state_.fbo_binding_for_scissor_workaround_dirty) { | 4812 if (state_.fbo_binding_for_scissor_workaround_dirty) { |
4855 state_.fbo_binding_for_scissor_workaround_dirty = false; | |
4856 // The driver forgets the correct scissor when modifying the FBO binding. | 4813 // The driver forgets the correct scissor when modifying the FBO binding. |
4857 glScissor(state_.scissor_x, | 4814 glScissor(state_.scissor_x, |
4858 state_.scissor_y, | 4815 state_.scissor_y, |
4859 state_.scissor_width, | 4816 state_.scissor_width, |
4860 state_.scissor_height); | 4817 state_.scissor_height); |
4861 | 4818 |
4862 // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, | 4819 // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, |
4863 // it's unclear how this bug works. | 4820 // it's unclear how this bug works. |
4864 glFlush(); | 4821 glFlush(); |
4865 } | 4822 } |
4866 } | 4823 } |
4867 | 4824 |
4868 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 4825 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
4869 Framebuffer* framebuffer = NULL; | 4826 Framebuffer* framebuffer = NULL; |
4870 GLuint service_id = 0; | |
4871 if (client_id != 0) { | 4827 if (client_id != 0) { |
4872 framebuffer = GetFramebuffer(client_id); | 4828 framebuffer = GetFramebuffer(client_id); |
4873 if (!framebuffer) { | 4829 if (!framebuffer) { |
4874 if (!group_->bind_generates_resource()) { | 4830 if (!group_->bind_generates_resource()) { |
4875 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 4831 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
4876 "glBindFramebuffer", | 4832 "glBindFramebuffer", |
4877 "id not generated by glGenFramebuffers"); | 4833 "id not generated by glGenFramebuffers"); |
4878 return; | 4834 return; |
4879 } | 4835 } |
4880 | 4836 |
4881 // It's a new id so make a framebuffer framebuffer for it. | 4837 // It's a new id so make a framebuffer framebuffer for it. |
4838 GLuint service_id = 0; | |
4882 glGenFramebuffersEXT(1, &service_id); | 4839 glGenFramebuffersEXT(1, &service_id); |
4883 CreateFramebuffer(client_id, service_id); | 4840 CreateFramebuffer(client_id, service_id); |
4884 framebuffer = GetFramebuffer(client_id); | 4841 framebuffer = GetFramebuffer(client_id); |
4885 } else { | |
4886 service_id = framebuffer->service_id(); | |
4887 } | 4842 } |
4888 framebuffer->MarkAsValid(); | 4843 framebuffer->MarkAsValid(); |
4889 } | 4844 } |
4890 LogClientServiceForInfo(framebuffer, client_id, "glBindFramebuffer"); | 4845 LogClientServiceForInfo(framebuffer, client_id, "glBindFramebuffer"); |
4891 | 4846 |
4892 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { | 4847 framebuffer_state_.SetBoundFramebuffer(target, framebuffer); |
4893 framebuffer_state_.bound_draw_framebuffer = framebuffer; | 4848 // Currently we apply the framebuffer binding directly. In the future, |
4894 } | 4849 // this may not be neccessary. Current test expectations prevent more |
4895 | 4850 // lazy application. |
4896 // vmiura: This looks like dup code | 4851 ApplyFramebufferBindings(target); |
4897 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { | |
4898 framebuffer_state_.bound_read_framebuffer = framebuffer; | |
4899 } | |
4900 | |
4901 framebuffer_state_.clear_state_dirty = true; | |
4902 | |
4903 // If we are rendering to the backbuffer get the FBO id for any simulated | |
4904 // backbuffer. | |
4905 if (framebuffer == NULL) { | |
4906 service_id = GetBackbufferServiceId(); | |
4907 } | |
4908 | |
4909 glBindFramebufferEXT(target, service_id); | |
4910 OnFboChanged(); | |
4911 } | 4852 } |
4912 | 4853 |
4913 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { | 4854 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { |
4914 Renderbuffer* renderbuffer = NULL; | 4855 Renderbuffer* renderbuffer = NULL; |
4915 GLuint service_id = 0; | 4856 GLuint service_id = 0; |
4916 if (client_id != 0) { | 4857 if (client_id != 0) { |
4917 renderbuffer = GetRenderbuffer(client_id); | 4858 renderbuffer = GetRenderbuffer(client_id); |
4918 if (!renderbuffer) { | 4859 if (!renderbuffer) { |
4919 if (!group_->bind_generates_resource()) { | 4860 if (!group_->bind_generates_resource()) { |
4920 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 4861 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6267 renderbuffer = GetRenderbuffer(client_renderbuffer_id); | 6208 renderbuffer = GetRenderbuffer(client_renderbuffer_id); |
6268 if (!renderbuffer) { | 6209 if (!renderbuffer) { |
6269 LOCAL_SET_GL_ERROR( | 6210 LOCAL_SET_GL_ERROR( |
6270 GL_INVALID_OPERATION, | 6211 GL_INVALID_OPERATION, |
6271 "glFramebufferRenderbuffer", "unknown renderbuffer"); | 6212 "glFramebufferRenderbuffer", "unknown renderbuffer"); |
6272 return; | 6213 return; |
6273 } | 6214 } |
6274 service_id = renderbuffer->service_id(); | 6215 service_id = renderbuffer->service_id(); |
6275 } | 6216 } |
6276 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); | 6217 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); |
6277 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 6218 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
vmiura
2016/04/28 22:28:20
Also needs ApplyFramebufferBindings(target) ?
| |
6278 glFramebufferRenderbufferEXT( | 6219 glFramebufferRenderbufferEXT( |
6279 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); | 6220 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); |
6280 glFramebufferRenderbufferEXT( | 6221 glFramebufferRenderbufferEXT( |
6281 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); | 6222 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); |
6282 } else { | 6223 } else { |
6283 glFramebufferRenderbufferEXT( | 6224 glFramebufferRenderbufferEXT( |
6284 target, attachment, renderbuffertarget, service_id); | 6225 target, attachment, renderbuffertarget, service_id); |
6285 } | 6226 } |
6286 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); | 6227 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); |
6287 if (error == GL_NO_ERROR) { | 6228 if (error == GL_NO_ERROR) { |
6288 framebuffer->AttachRenderbuffer(attachment, renderbuffer); | 6229 framebuffer->AttachRenderbuffer(attachment, renderbuffer); |
6230 framebuffer_state_.NotifyFramebufferChanged(framebuffer); | |
6289 } | 6231 } |
6290 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | |
6291 framebuffer_state_.clear_state_dirty = true; | |
6292 } | |
6293 OnFboChanged(); | |
6294 } | 6232 } |
6295 | 6233 |
6296 void GLES2DecoderImpl::DoDisable(GLenum cap) { | 6234 void GLES2DecoderImpl::DoDisable(GLenum cap) { |
6297 if (SetCapabilityState(cap, false)) { | 6235 if (SetCapabilityState(cap, false)) { |
6298 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && | 6236 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
6299 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { | 6237 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { |
6300 // Enable and Disable PRIMITIVE_RESTART only before and after | 6238 // Enable and Disable PRIMITIVE_RESTART only before and after |
6301 // DrawElements* for old desktop GL. | 6239 // DrawElements* for old desktop GL. |
6302 return; | 6240 return; |
6303 } | 6241 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6407 GetBackbufferServiceId(); | 6345 GetBackbufferServiceId(); |
6408 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); | 6346 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); |
6409 } | 6347 } |
6410 } | 6348 } |
6411 | 6349 |
6412 framebuffer_manager()->MarkAttachmentsAsCleared( | 6350 framebuffer_manager()->MarkAttachmentsAsCleared( |
6413 framebuffer, renderbuffer_manager(), texture_manager()); | 6351 framebuffer, renderbuffer_manager(), texture_manager()); |
6414 } | 6352 } |
6415 | 6353 |
6416 void GLES2DecoderImpl::RestoreClearState() { | 6354 void GLES2DecoderImpl::RestoreClearState() { |
6417 framebuffer_state_.clear_state_dirty = true; | 6355 framebuffer_state_.set_draw_framebuffer_clear_state_dirty(true); |
6418 glClearColor( | 6356 glClearColor( |
6419 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, | 6357 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, |
6420 state_.color_clear_alpha); | 6358 state_.color_clear_alpha); |
6421 glClearStencil(state_.stencil_clear); | 6359 glClearStencil(state_.stencil_clear); |
6422 glClearDepth(state_.depth_clear); | 6360 glClearDepth(state_.depth_clear); |
6423 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 6361 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, |
6424 state_.enable_flags.scissor_test); | 6362 state_.enable_flags.scissor_test); |
6425 glScissor(state_.scissor_x, state_.scissor_y, state_.scissor_width, | 6363 glScissor(state_.scissor_x, state_.scissor_y, state_.scissor_width, |
6426 state_.scissor_height); | 6364 state_.scissor_height); |
6427 } | 6365 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6488 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { | 6426 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { |
6489 LOCAL_SET_GL_ERROR( | 6427 LOCAL_SET_GL_ERROR( |
6490 GL_INVALID_VALUE, | 6428 GL_INVALID_VALUE, |
6491 name, "level out of range"); | 6429 name, "level out of range"); |
6492 return; | 6430 return; |
6493 } | 6431 } |
6494 | 6432 |
6495 if (texture_ref) | 6433 if (texture_ref) |
6496 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); | 6434 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); |
6497 | 6435 |
6436 ApplyFramebufferBindings(target); | |
6498 std::vector<GLenum> attachments; | 6437 std::vector<GLenum> attachments; |
6499 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 6438 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
6500 attachments.push_back(GL_DEPTH_ATTACHMENT); | 6439 attachments.push_back(GL_DEPTH_ATTACHMENT); |
6501 attachments.push_back(GL_STENCIL_ATTACHMENT); | 6440 attachments.push_back(GL_STENCIL_ATTACHMENT); |
6502 } else { | 6441 } else { |
6503 attachments.push_back(attachment); | 6442 attachments.push_back(attachment); |
6504 } | 6443 } |
6505 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); | 6444 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); |
6506 for (size_t ii = 0; ii < attachments.size(); ++ii) { | 6445 for (size_t ii = 0; ii < attachments.size(); ++ii) { |
6507 if (0 == samples) { | 6446 if (0 == samples) { |
6508 glFramebufferTexture2DEXT( | 6447 glFramebufferTexture2DEXT( |
6509 target, attachments[ii], textarget, service_id, level); | 6448 target, attachments[ii], textarget, service_id, level); |
6510 } else { | 6449 } else { |
6511 if (features().use_img_for_multisampled_render_to_texture) { | 6450 if (features().use_img_for_multisampled_render_to_texture) { |
6512 glFramebufferTexture2DMultisampleIMG( | 6451 glFramebufferTexture2DMultisampleIMG( |
6513 target, attachments[ii], textarget, service_id, level, samples); | 6452 target, attachments[ii], textarget, service_id, level, samples); |
6514 } else { | 6453 } else { |
6515 glFramebufferTexture2DMultisampleEXT( | 6454 glFramebufferTexture2DMultisampleEXT( |
6516 target, attachments[ii], textarget, service_id, level, samples); | 6455 target, attachments[ii], textarget, service_id, level, samples); |
6517 } | 6456 } |
6518 } | 6457 } |
6519 } | 6458 } |
6520 GLenum error = LOCAL_PEEK_GL_ERROR(name); | 6459 GLenum error = LOCAL_PEEK_GL_ERROR(name); |
6521 if (error == GL_NO_ERROR) { | 6460 if (error == GL_NO_ERROR) { |
6522 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, | 6461 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, |
6523 samples); | 6462 samples); |
6463 framebuffer_state_.NotifyFramebufferChanged(framebuffer); | |
6524 } | 6464 } |
6525 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | |
6526 framebuffer_state_.clear_state_dirty = true; | |
6527 } | |
6528 | |
6529 OnFboChanged(); | |
6530 } | 6465 } |
6531 | 6466 |
6532 void GLES2DecoderImpl::DoFramebufferTextureLayer( | 6467 void GLES2DecoderImpl::DoFramebufferTextureLayer( |
6533 GLenum target, GLenum attachment, GLuint client_texture_id, | 6468 GLenum target, GLenum attachment, GLuint client_texture_id, |
6534 GLint level, GLint layer) { | 6469 GLint level, GLint layer) { |
6535 // TODO(zmo): Add full validation. | 6470 // TODO(zmo): Add full validation. |
6536 GLuint service_id = 0; | 6471 GLuint service_id = 0; |
6537 TextureRef* texture_ref = NULL; | 6472 TextureRef* texture_ref = NULL; |
6538 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 6473 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
6539 if (!framebuffer) { | 6474 if (!framebuffer) { |
6540 LOCAL_SET_GL_ERROR( | 6475 LOCAL_SET_GL_ERROR( |
6541 GL_INVALID_OPERATION, | 6476 GL_INVALID_OPERATION, |
6542 "glFramebufferTextureLayer", "no framebuffer bound."); | 6477 "glFramebufferTextureLayer", "no framebuffer bound."); |
6543 return; | 6478 return; |
6544 } | 6479 } |
6545 if (client_texture_id) { | 6480 if (client_texture_id) { |
6546 texture_ref = GetTexture(client_texture_id); | 6481 texture_ref = GetTexture(client_texture_id); |
6547 if (!texture_ref) { | 6482 if (!texture_ref) { |
6548 LOCAL_SET_GL_ERROR( | 6483 LOCAL_SET_GL_ERROR( |
6549 GL_INVALID_OPERATION, | 6484 GL_INVALID_OPERATION, |
6550 "glFramebufferTextureLayer", "unknown texture_ref"); | 6485 "glFramebufferTextureLayer", "unknown texture_ref"); |
6551 return; | 6486 return; |
6552 } | 6487 } |
6553 service_id = texture_ref->service_id(); | 6488 service_id = texture_ref->service_id(); |
6554 } | 6489 } |
6490 ApplyFramebufferBindings(target); | |
6555 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferTextureLayer"); | 6491 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferTextureLayer"); |
6556 glFramebufferTextureLayer(target, attachment, service_id, level, layer); | 6492 glFramebufferTextureLayer(target, attachment, service_id, level, layer); |
6557 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferTextureLayer"); | 6493 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferTextureLayer"); |
6558 if (error == GL_NO_ERROR) { | 6494 if (error == GL_NO_ERROR) { |
6559 framebuffer->AttachTextureLayer(attachment, texture_ref, | 6495 framebuffer->AttachTextureLayer(attachment, texture_ref, |
6560 texture_ref ? texture_ref->texture()->target() : 0, | 6496 texture_ref ? texture_ref->texture()->target() : 0, |
6561 level, layer); | 6497 level, layer); |
6562 } | 6498 framebuffer_state_.NotifyFramebufferChanged(framebuffer); |
6563 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | |
6564 framebuffer_state_.clear_state_dirty = true; | |
6565 } | 6499 } |
6566 } | 6500 } |
6567 | 6501 |
6568 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 6502 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
6569 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 6503 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
6570 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; | 6504 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; |
6571 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 6505 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
6572 if (!framebuffer) { | 6506 if (!framebuffer) { |
6573 if (!unsafe_es3_apis_enabled()) { | 6507 if (!unsafe_es3_apis_enabled()) { |
6574 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | 6508 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6622 } | 6556 } |
6623 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { | 6557 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
6624 DCHECK(framebuffer); | 6558 DCHECK(framebuffer); |
6625 // If we query from the driver, it will be service ID; however, we need to | 6559 // If we query from the driver, it will be service ID; however, we need to |
6626 // return the client ID here. | 6560 // return the client ID here. |
6627 const Framebuffer::Attachment* attachment_object = | 6561 const Framebuffer::Attachment* attachment_object = |
6628 framebuffer->GetAttachment(attachment); | 6562 framebuffer->GetAttachment(attachment); |
6629 *params = attachment_object ? attachment_object->object_name() : 0; | 6563 *params = attachment_object ? attachment_object->object_name() : 0; |
6630 return; | 6564 return; |
6631 } | 6565 } |
6632 | 6566 ApplyFramebufferBindings(target); |
6633 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); | 6567 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); |
6634 // We didn't perform a full error check before gl call. | 6568 // We didn't perform a full error check before gl call. |
6635 LOCAL_PEEK_GL_ERROR(kFunctionName); | 6569 LOCAL_PEEK_GL_ERROR(kFunctionName); |
6636 } | 6570 } |
6637 | 6571 |
6638 void GLES2DecoderImpl::DoGetRenderbufferParameteriv( | 6572 void GLES2DecoderImpl::DoGetRenderbufferParameteriv( |
6639 GLenum target, GLenum pname, GLint* params) { | 6573 GLenum target, GLenum pname, GLint* params) { |
6640 Renderbuffer* renderbuffer = | 6574 Renderbuffer* renderbuffer = |
6641 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); | 6575 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); |
6642 if (!renderbuffer) { | 6576 if (!renderbuffer) { |
(...skipping 3674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10317 DCHECK(target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY); | 10251 DCHECK(target != GL_TEXTURE_3D && target != GL_TEXTURE_2D_ARRAY); |
10318 uint32_t channels = GLES2Util::GetChannelsForFormat(format); | 10252 uint32_t channels = GLES2Util::GetChannelsForFormat(format); |
10319 if ((feature_info_->feature_flags().angle_depth_texture || | 10253 if ((feature_info_->feature_flags().angle_depth_texture || |
10320 feature_info_->IsES3Enabled()) | 10254 feature_info_->IsES3Enabled()) |
10321 && (channels & GLES2Util::kDepth) != 0) { | 10255 && (channels & GLES2Util::kDepth) != 0) { |
10322 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D | 10256 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D |
10323 // on depth formats. | 10257 // on depth formats. |
10324 GLuint fb = 0; | 10258 GLuint fb = 0; |
10325 glGenFramebuffersEXT(1, &fb); | 10259 glGenFramebuffersEXT(1, &fb); |
10326 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); | 10260 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); |
10261 framebuffer_state_.MarkBindingDirty(GL_DRAW_FRAMEBUFFER_EXT); | |
10327 | 10262 |
10328 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, | 10263 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, |
10329 target, texture->service_id(), level); | 10264 target, texture->service_id(), level); |
10330 bool have_stencil = (channels & GLES2Util::kStencil) != 0; | 10265 bool have_stencil = (channels & GLES2Util::kStencil) != 0; |
10331 if (have_stencil) { | 10266 if (have_stencil) { |
10332 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT, | 10267 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT, |
10333 target, texture->service_id(), level); | 10268 target, texture->service_id(), level); |
10334 } | 10269 } |
10335 | 10270 |
10336 // ANGLE promises a depth only attachment ok. | 10271 // ANGLE promises a depth only attachment ok. |
10337 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != | 10272 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != |
10338 GL_FRAMEBUFFER_COMPLETE) { | 10273 GL_FRAMEBUFFER_COMPLETE) { |
10274 ApplyFramebufferBindings(GL_DRAW_FRAMEBUFFER_EXT); | |
10339 return false; | 10275 return false; |
10340 } | 10276 } |
10341 glClearStencil(0); | 10277 glClearStencil(0); |
10342 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 10278 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
10343 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 10279 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
10344 glClearDepth(1.0f); | 10280 glClearDepth(1.0f); |
10345 state_.SetDeviceDepthMask(GL_TRUE); | 10281 state_.SetDeviceDepthMask(GL_TRUE); |
10346 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); | 10282 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, true); |
10347 glScissor(xoffset, yoffset, width, height); | 10283 glScissor(xoffset, yoffset, width, height); |
10348 glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0)); | 10284 glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0)); |
10349 | 10285 |
10350 RestoreClearState(); | 10286 RestoreClearState(); |
10351 | 10287 |
10352 glDeleteFramebuffersEXT(1, &fb); | 10288 glDeleteFramebuffersEXT(1, &fb); |
10353 Framebuffer* framebuffer = | 10289 ApplyFramebufferBindings(GL_DRAW_FRAMEBUFFER_EXT); |
10354 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | |
10355 GLuint fb_service_id = | |
10356 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); | |
10357 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); | |
10358 return true; | 10290 return true; |
10359 } | 10291 } |
10360 | 10292 |
10361 const uint32_t kMaxZeroSize = 1024 * 1024 * 4; | 10293 const uint32_t kMaxZeroSize = 1024 * 1024 * 4; |
10362 | 10294 |
10363 uint32_t size; | 10295 uint32_t size; |
10364 uint32_t padded_row_size; | 10296 uint32_t padded_row_size; |
10365 if (!GLES2Util::ComputeImageDataSizes( | 10297 if (!GLES2Util::ComputeImageDataSizes( |
10366 width, height, 1, format, type, state_.unpack_alignment, &size, | 10298 width, height, 1, format, type, state_.unpack_alignment, &size, |
10367 NULL, &padded_row_size)) { | 10299 NULL, &padded_row_size)) { |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11002 return error::kNoError; | 10934 return error::kNoError; |
11003 } | 10935 } |
11004 | 10936 |
11005 if (!EnsureGPUMemoryAvailable(image_size)) { | 10937 if (!EnsureGPUMemoryAvailable(image_size)) { |
11006 LOCAL_SET_GL_ERROR( | 10938 LOCAL_SET_GL_ERROR( |
11007 GL_OUT_OF_MEMORY, "glCompressedTexImage2D", "out of memory"); | 10939 GL_OUT_OF_MEMORY, "glCompressedTexImage2D", "out of memory"); |
11008 return error::kNoError; | 10940 return error::kNoError; |
11009 } | 10941 } |
11010 | 10942 |
11011 if (texture->IsAttachedToFramebuffer()) { | 10943 if (texture->IsAttachedToFramebuffer()) { |
11012 framebuffer_state_.clear_state_dirty = true; | 10944 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
11013 } | 10945 } |
11014 | 10946 |
11015 std::unique_ptr<int8_t[]> zero; | 10947 std::unique_ptr<int8_t[]> zero; |
11016 if (!data) { | 10948 if (!data) { |
11017 zero.reset(new int8_t[image_size]); | 10949 zero.reset(new int8_t[image_size]); |
11018 memset(zero.get(), 0, image_size); | 10950 memset(zero.get(), 0, image_size); |
11019 data = zero.get(); | 10951 data = zero.get(); |
11020 } | 10952 } |
11021 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); | 10953 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage2D"); |
11022 glCompressedTexImage2D( | 10954 glCompressedTexImage2D( |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11197 return error::kNoError; | 11129 return error::kNoError; |
11198 } | 11130 } |
11199 | 11131 |
11200 if (!EnsureGPUMemoryAvailable(image_size)) { | 11132 if (!EnsureGPUMemoryAvailable(image_size)) { |
11201 LOCAL_SET_GL_ERROR( | 11133 LOCAL_SET_GL_ERROR( |
11202 GL_OUT_OF_MEMORY, "glCompressedTexImage3D", "out of memory"); | 11134 GL_OUT_OF_MEMORY, "glCompressedTexImage3D", "out of memory"); |
11203 return error::kNoError; | 11135 return error::kNoError; |
11204 } | 11136 } |
11205 | 11137 |
11206 if (texture->IsAttachedToFramebuffer()) { | 11138 if (texture->IsAttachedToFramebuffer()) { |
11207 framebuffer_state_.clear_state_dirty = true; | 11139 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
11208 } | 11140 } |
11209 | 11141 |
11210 std::unique_ptr<int8_t[]> zero; | 11142 std::unique_ptr<int8_t[]> zero; |
11211 if (!data) { | 11143 if (!data) { |
11212 zero.reset(new int8_t[image_size]); | 11144 zero.reset(new int8_t[image_size]); |
11213 memset(zero.get(), 0, image_size); | 11145 memset(zero.get(), 0, image_size); |
11214 data = zero.get(); | 11146 data = zero.get(); |
11215 } | 11147 } |
11216 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage3D"); | 11148 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCompressedTexImage3D"); |
11217 glCompressedTexImage3D(target, level, internal_format, width, height, depth, | 11149 glCompressedTexImage3D(target, level, internal_format, width, height, depth, |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11750 GL_INVALID_OPERATION, | 11682 GL_INVALID_OPERATION, |
11751 "glCopyTexImage2D", "source and destination textures are the same"); | 11683 "glCopyTexImage2D", "source and destination textures are the same"); |
11752 return; | 11684 return; |
11753 } | 11685 } |
11754 | 11686 |
11755 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); | 11687 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); |
11756 ScopedResolvedFrameBufferBinder binder(this, false, true); | 11688 ScopedResolvedFrameBufferBinder binder(this, false, true); |
11757 gfx::Size size = GetBoundReadFrameBufferSize(); | 11689 gfx::Size size = GetBoundReadFrameBufferSize(); |
11758 | 11690 |
11759 if (texture->IsAttachedToFramebuffer()) { | 11691 if (texture->IsAttachedToFramebuffer()) { |
11760 framebuffer_state_.clear_state_dirty = true; | 11692 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
11761 } | 11693 } |
11762 | 11694 |
11763 // Clip to size to source dimensions | 11695 // Clip to size to source dimensions |
11764 GLint copyX = 0; | 11696 GLint copyX = 0; |
11765 GLint copyY = 0; | 11697 GLint copyY = 0; |
11766 GLint copyWidth = 0; | 11698 GLint copyWidth = 0; |
11767 GLint copyHeight = 0; | 11699 GLint copyHeight = 0; |
11768 Clip(x, width, size.width(), ©X, ©Width); | 11700 Clip(x, width, size.width(), ©X, ©Width); |
11769 Clip(y, height, size.height(), ©Y, ©Height); | 11701 Clip(y, height, size.height(), ©Y, ©Height); |
11770 | 11702 |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14355 } | 14287 } |
14356 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | 14288 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
14357 &state_, target); | 14289 &state_, target); |
14358 if (!texture_ref) { | 14290 if (!texture_ref) { |
14359 LOCAL_SET_GL_ERROR( | 14291 LOCAL_SET_GL_ERROR( |
14360 GL_INVALID_OPERATION, function_name, "unknown texture for target"); | 14292 GL_INVALID_OPERATION, function_name, "unknown texture for target"); |
14361 return; | 14293 return; |
14362 } | 14294 } |
14363 Texture* texture = texture_ref->texture(); | 14295 Texture* texture = texture_ref->texture(); |
14364 if (texture->IsAttachedToFramebuffer()) { | 14296 if (texture->IsAttachedToFramebuffer()) { |
14365 framebuffer_state_.clear_state_dirty = true; | 14297 framebuffer_state_.NotifyBoundFramebuffersChanged(); |
14366 } | 14298 } |
14367 if (texture->IsImmutable()) { | 14299 if (texture->IsImmutable()) { |
14368 LOCAL_SET_GL_ERROR( | 14300 LOCAL_SET_GL_ERROR( |
14369 GL_INVALID_OPERATION, function_name, "texture is immutable"); | 14301 GL_INVALID_OPERATION, function_name, "texture is immutable"); |
14370 return; | 14302 return; |
14371 } | 14303 } |
14372 | 14304 |
14373 GLenum format = TextureManager::ExtractFormatFromStorageFormat( | 14305 GLenum format = TextureManager::ExtractFormatFromStorageFormat( |
14374 internal_format); | 14306 internal_format); |
14375 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); | 14307 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16371 } | 16303 } |
16372 | 16304 |
16373 // Include the auto-generated part of this file. We split this because it means | 16305 // Include the auto-generated part of this file. We split this because it means |
16374 // we can easily edit the non-auto generated parts right here in this file | 16306 // we can easily edit the non-auto generated parts right here in this file |
16375 // instead of having to edit some template or the code generator. | 16307 // instead of having to edit some template or the code generator. |
16376 #include "base/macros.h" | 16308 #include "base/macros.h" |
16377 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16309 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16378 | 16310 |
16379 } // namespace gles2 | 16311 } // namespace gles2 |
16380 } // namespace gpu | 16312 } // namespace gpu |
OLD | NEW |