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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 591 |
592 // These check the state of the currently bound framebuffer or the | 592 // These check the state of the currently bound framebuffer or the |
593 // backbuffer if no framebuffer is bound. | 593 // backbuffer if no framebuffer is bound. |
594 bool BoundFramebufferHasColorAttachmentWithAlpha(); | 594 bool BoundFramebufferHasColorAttachmentWithAlpha(); |
595 bool BoundFramebufferHasDepthAttachment(); | 595 bool BoundFramebufferHasDepthAttachment(); |
596 bool BoundFramebufferHasStencilAttachment(); | 596 bool BoundFramebufferHasStencilAttachment(); |
597 | 597 |
598 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; | 598 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; |
599 | 599 |
600 private: | 600 private: |
| 601 friend class ScopedFrameBufferBinder; |
601 friend class ScopedGLErrorSuppressor; | 602 friend class ScopedGLErrorSuppressor; |
602 friend class ScopedResolvedFrameBufferBinder; | 603 friend class ScopedResolvedFrameBufferBinder; |
603 friend class ScopedTextureUploadTimer; | 604 friend class ScopedTextureUploadTimer; |
604 friend class Texture; | 605 friend class Texture; |
605 friend class RenderBuffer; | 606 friend class RenderBuffer; |
606 friend class FrameBuffer; | 607 friend class FrameBuffer; |
607 | 608 |
608 // Initialize or re-initialize the shader translator. | 609 // Initialize or re-initialize the shader translator. |
609 bool InitializeShaderTranslator(); | 610 bool InitializeShaderTranslator(); |
610 | 611 |
611 void UpdateCapabilities(); | 612 void UpdateCapabilities(); |
612 | 613 |
613 // Helpers for the glGen and glDelete functions. | 614 // Helpers for the glGen and glDelete functions. |
614 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); | 615 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); |
615 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); | 616 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); |
616 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); | 617 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); |
617 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); | 618 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); |
618 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 619 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
619 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 620 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
620 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 621 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
621 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 622 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
622 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 623 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
623 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 624 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
624 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 625 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
625 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 626 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
626 | 627 |
| 628 // Workarounds |
| 629 void OnFboChanged() const; |
| 630 |
627 // TODO(gman): Cache these pointers? | 631 // TODO(gman): Cache these pointers? |
628 BufferManager* buffer_manager() { | 632 BufferManager* buffer_manager() { |
629 return group_->buffer_manager(); | 633 return group_->buffer_manager(); |
630 } | 634 } |
631 | 635 |
632 RenderbufferManager* renderbuffer_manager() { | 636 RenderbufferManager* renderbuffer_manager() { |
633 return group_->renderbuffer_manager(); | 637 return group_->renderbuffer_manager(); |
634 } | 638 } |
635 | 639 |
636 FramebufferManager* framebuffer_manager() { | 640 FramebufferManager* framebuffer_manager() { |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { | 1740 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { |
1737 ScopedGLErrorSuppressor suppressor(decoder_); | 1741 ScopedGLErrorSuppressor suppressor(decoder_); |
1738 decoder_->RestoreCurrentRenderbufferBindings(); | 1742 decoder_->RestoreCurrentRenderbufferBindings(); |
1739 } | 1743 } |
1740 | 1744 |
1741 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, | 1745 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, |
1742 GLuint id) | 1746 GLuint id) |
1743 : decoder_(decoder) { | 1747 : decoder_(decoder) { |
1744 ScopedGLErrorSuppressor suppressor(decoder_); | 1748 ScopedGLErrorSuppressor suppressor(decoder_); |
1745 glBindFramebufferEXT(GL_FRAMEBUFFER, id); | 1749 glBindFramebufferEXT(GL_FRAMEBUFFER, id); |
| 1750 decoder->OnFboChanged(); |
1746 } | 1751 } |
1747 | 1752 |
1748 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { | 1753 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { |
1749 ScopedGLErrorSuppressor suppressor(decoder_); | 1754 ScopedGLErrorSuppressor suppressor(decoder_); |
1750 decoder_->RestoreCurrentFramebufferBindings(); | 1755 decoder_->RestoreCurrentFramebufferBindings(); |
1751 } | 1756 } |
1752 | 1757 |
1753 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( | 1758 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( |
1754 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) | 1759 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) |
1755 : decoder_(decoder) { | 1760 : decoder_(decoder) { |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 GLenum target = supports_separate_framebuffer_binds ? | 2613 GLenum target = supports_separate_framebuffer_binds ? |
2609 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 2614 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
2610 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2615 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
2611 } | 2616 } |
2612 if (framebuffer == state_.bound_read_framebuffer) { | 2617 if (framebuffer == state_.bound_read_framebuffer) { |
2613 state_.bound_read_framebuffer = NULL; | 2618 state_.bound_read_framebuffer = NULL; |
2614 GLenum target = supports_separate_framebuffer_binds ? | 2619 GLenum target = supports_separate_framebuffer_binds ? |
2615 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 2620 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
2616 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2621 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
2617 } | 2622 } |
| 2623 OnFboChanged(); |
2618 RemoveFramebufferInfo(client_ids[ii]); | 2624 RemoveFramebufferInfo(client_ids[ii]); |
2619 } | 2625 } |
2620 } | 2626 } |
2621 } | 2627 } |
2622 | 2628 |
2623 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 2629 void GLES2DecoderImpl::DeleteRenderbuffersHelper( |
2624 GLsizei n, const GLuint* client_ids) { | 2630 GLsizei n, const GLuint* client_ids) { |
2625 bool supports_separate_framebuffer_binds = | 2631 bool supports_separate_framebuffer_binds = |
2626 features().chromium_framebuffer_multisample; | 2632 features().chromium_framebuffer_multisample; |
2627 for (GLsizei ii = 0; ii < n; ++ii) { | 2633 for (GLsizei ii = 0; ii < n; ++ii) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2764 } else { | 2770 } else { |
2765 RebindCurrentFramebuffer( | 2771 RebindCurrentFramebuffer( |
2766 GL_READ_FRAMEBUFFER_EXT, | 2772 GL_READ_FRAMEBUFFER_EXT, |
2767 state_.bound_read_framebuffer.get(), | 2773 state_.bound_read_framebuffer.get(), |
2768 GetBackbufferServiceId()); | 2774 GetBackbufferServiceId()); |
2769 RebindCurrentFramebuffer( | 2775 RebindCurrentFramebuffer( |
2770 GL_DRAW_FRAMEBUFFER_EXT, | 2776 GL_DRAW_FRAMEBUFFER_EXT, |
2771 state_.bound_draw_framebuffer.get(), | 2777 state_.bound_draw_framebuffer.get(), |
2772 GetBackbufferServiceId()); | 2778 GetBackbufferServiceId()); |
2773 } | 2779 } |
| 2780 OnFboChanged(); |
2774 } | 2781 } |
2775 | 2782 |
2776 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { | 2783 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { |
2777 TextureUnit& info = state_.texture_units[0]; | 2784 TextureUnit& info = state_.texture_units[0]; |
2778 GLuint last_id; | 2785 GLuint last_id; |
2779 if (info.bound_texture_2d) { | 2786 if (info.bound_texture_2d) { |
2780 last_id = info.bound_texture_2d->service_id(); | 2787 last_id = info.bound_texture_2d->service_id(); |
2781 } else { | 2788 } else { |
2782 last_id = 0; | 2789 last_id = 0; |
2783 } | 2790 } |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3581 } | 3588 } |
3582 | 3589 |
3583 void GLES2DecoderImpl::RestoreState() const { | 3590 void GLES2DecoderImpl::RestoreState() const { |
3584 state_.RestoreState(); | 3591 state_.RestoreState(); |
3585 | 3592 |
3586 // TODO: Restore multisample bindings | 3593 // TODO: Restore multisample bindings |
3587 GLuint service_id = state_.bound_draw_framebuffer ? | 3594 GLuint service_id = state_.bound_draw_framebuffer ? |
3588 state_.bound_draw_framebuffer->service_id() : | 3595 state_.bound_draw_framebuffer->service_id() : |
3589 GetBackbufferServiceId(); | 3596 GetBackbufferServiceId(); |
3590 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); | 3597 glBindFramebufferEXT(GL_FRAMEBUFFER, service_id); |
| 3598 OnFboChanged(); |
| 3599 } |
| 3600 |
| 3601 void GLES2DecoderImpl::OnFboChanged() const { |
| 3602 if (workarounds().restore_scissor_on_fbo_change) |
| 3603 glScissor(state_.scissor_x, state_.scissor_y, |
| 3604 state_.scissor_width, state_.scissor_height); |
3591 } | 3605 } |
3592 | 3606 |
3593 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 3607 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
3594 FramebufferManager::FramebufferInfo* info = NULL; | 3608 FramebufferManager::FramebufferInfo* info = NULL; |
3595 GLuint service_id = 0; | 3609 GLuint service_id = 0; |
3596 if (client_id != 0) { | 3610 if (client_id != 0) { |
3597 info = GetFramebufferInfo(client_id); | 3611 info = GetFramebufferInfo(client_id); |
3598 if (!info) { | 3612 if (!info) { |
3599 if (!group_->bind_generates_resource()) { | 3613 if (!group_->bind_generates_resource()) { |
3600 LOG(ERROR) | 3614 LOG(ERROR) |
(...skipping 25 matching lines...) Expand all Loading... |
3626 | 3640 |
3627 clear_state_dirty_ = true; | 3641 clear_state_dirty_ = true; |
3628 | 3642 |
3629 // If we are rendering to the backbuffer get the FBO id for any simulated | 3643 // If we are rendering to the backbuffer get the FBO id for any simulated |
3630 // backbuffer. | 3644 // backbuffer. |
3631 if (info == NULL) { | 3645 if (info == NULL) { |
3632 service_id = GetBackbufferServiceId(); | 3646 service_id = GetBackbufferServiceId(); |
3633 } | 3647 } |
3634 | 3648 |
3635 glBindFramebufferEXT(target, service_id); | 3649 glBindFramebufferEXT(target, service_id); |
| 3650 OnFboChanged(); |
3636 } | 3651 } |
3637 | 3652 |
3638 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { | 3653 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { |
3639 RenderbufferManager::RenderbufferInfo* info = NULL; | 3654 RenderbufferManager::RenderbufferInfo* info = NULL; |
3640 GLuint service_id = 0; | 3655 GLuint service_id = 0; |
3641 if (client_id != 0) { | 3656 if (client_id != 0) { |
3642 info = GetRenderbufferInfo(client_id); | 3657 info = GetRenderbufferInfo(client_id); |
3643 if (!info) { | 3658 if (!info) { |
3644 if (!group_->bind_generates_resource()) { | 3659 if (!group_->bind_generates_resource()) { |
3645 LOG(ERROR) | 3660 LOG(ERROR) |
(...skipping 6360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10006 return error::kNoError; | 10021 return error::kNoError; |
10007 } | 10022 } |
10008 | 10023 |
10009 // Include the auto-generated part of this file. We split this because it means | 10024 // Include the auto-generated part of this file. We split this because it means |
10010 // we can easily edit the non-auto generated parts right here in this file | 10025 // we can easily edit the non-auto generated parts right here in this file |
10011 // instead of having to edit some template or the code generator. | 10026 // instead of having to edit some template or the code generator. |
10012 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10027 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10013 | 10028 |
10014 } // namespace gles2 | 10029 } // namespace gles2 |
10015 } // namespace gpu | 10030 } // namespace gpu |
OLD | NEW |