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 5644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5655 "glDisableVertexAttribArray", "index out of range"); | 5655 "glDisableVertexAttribArray", "index out of range"); |
5656 } | 5656 } |
5657 } | 5657 } |
5658 | 5658 |
5659 void GLES2DecoderImpl::InvalidateFramebufferImpl( | 5659 void GLES2DecoderImpl::InvalidateFramebufferImpl( |
5660 GLenum target, GLsizei count, const GLenum* attachments, | 5660 GLenum target, GLsizei count, const GLenum* attachments, |
5661 GLint x, GLint y, GLsizei width, GLsizei height, | 5661 GLint x, GLint y, GLsizei width, GLsizei height, |
5662 const char* function_name, FramebufferOperation op) { | 5662 const char* function_name, FramebufferOperation op) { |
5663 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 5663 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); |
5664 | 5664 |
5665 // Because of performance issues, no-op if the format of the attachment is | |
5666 // DEPTH_STENCIL and only one part is intended to be invalidated. | |
5667 bool has_depth_stencil_format = framebuffer && | |
5668 framebuffer->HasDepthStencilFormatAttachment( | |
qiankun
2016/07/18 04:50:09
4 space indent.
| |
5669 GL_DEPTH_ATTACHMENT) && | |
5670 framebuffer->HasDepthStencilFormatAttachment( | |
5671 GL_STENCIL_ATTACHMENT); | |
5672 bool invalidate_depth = false; | |
5673 bool invalidate_stencil = false; | |
5674 std::unique_ptr<GLenum[]> validated_attachments(new GLenum[count]); | |
5675 GLsizei validated_count = 0; | |
5676 | |
5665 // Validates the attachments. If one of them fails, the whole command fails. | 5677 // Validates the attachments. If one of them fails, the whole command fails. |
5666 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); | 5678 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); |
5667 GLenum thresh1 = GL_COLOR_ATTACHMENT15; | 5679 GLenum thresh1 = GL_COLOR_ATTACHMENT15; |
5668 for (GLsizei i = 0; i < count; ++i) { | 5680 for (GLsizei i = 0; i < count; ++i) { |
5669 if (framebuffer) { | 5681 if (framebuffer) { |
5670 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { | 5682 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { |
5671 LOCAL_SET_GL_ERROR( | 5683 LOCAL_SET_GL_ERROR( |
5672 GL_INVALID_OPERATION, function_name, "invalid attachment"); | 5684 GL_INVALID_OPERATION, function_name, "invalid attachment"); |
5673 return; | 5685 return; |
5674 } | 5686 } |
5675 if (!validators_->attachment.IsValid(attachments[i])) { | 5687 if (!validators_->attachment.IsValid(attachments[i])) { |
5676 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 5688 LOCAL_SET_GL_ERROR_INVALID_ENUM( |
5677 function_name, attachments[i], "attachments"); | 5689 function_name, attachments[i], "attachments"); |
5678 return; | 5690 return; |
5679 } | 5691 } |
5692 if (has_depth_stencil_format) { | |
5693 switch(attachments[i]) { | |
5694 case GL_DEPTH_ATTACHMENT: | |
5695 invalidate_depth = true; | |
5696 continue; | |
5697 case GL_STENCIL_ATTACHMENT: | |
5698 invalidate_stencil = true; | |
5699 continue; | |
5700 } | |
5701 } | |
5680 } else { | 5702 } else { |
5681 if (!validators_->backbuffer_attachment.IsValid(attachments[i])) { | 5703 if (!validators_->backbuffer_attachment.IsValid(attachments[i])) { |
5682 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 5704 LOCAL_SET_GL_ERROR_INVALID_ENUM( |
5683 function_name, attachments[i], "attachments"); | 5705 function_name, attachments[i], "attachments"); |
5684 return; | 5706 return; |
5685 } | 5707 } |
5686 } | 5708 } |
5709 validated_attachments[validated_count++] = attachments[i]; | |
5687 } | 5710 } |
5711 if (invalidate_depth && invalidate_stencil) { | |
5712 validated_attachments[validated_count++] = GL_DEPTH_STENCIL_ATTACHMENT; | |
5713 } | |
5714 count = validated_count; | |
5688 | 5715 |
5689 // If the default framebuffer is bound but we are still rendering to an | 5716 // If the default framebuffer is bound but we are still rendering to an |
5690 // FBO, translate attachment names that refer to default framebuffer | 5717 // FBO, translate attachment names that refer to default framebuffer |
5691 // channels to corresponding framebuffer attachments. | 5718 // channels to corresponding framebuffer attachments. |
5692 std::unique_ptr<GLenum[]> translated_attachments(new GLenum[count]); | 5719 std::unique_ptr<GLenum[]> translated_attachments(new GLenum[count]); |
5693 for (GLsizei i = 0; i < count; ++i) { | 5720 for (GLsizei i = 0; i < count; ++i) { |
5694 GLenum attachment = attachments[i]; | 5721 GLenum attachment = validated_attachments[i]; |
5695 if (!framebuffer && GetBackbufferServiceId()) { | 5722 if (!framebuffer && GetBackbufferServiceId()) { |
5696 switch (attachment) { | 5723 switch (attachment) { |
5697 case GL_COLOR_EXT: | 5724 case GL_COLOR_EXT: |
5698 attachment = GL_COLOR_ATTACHMENT0; | 5725 attachment = GL_COLOR_ATTACHMENT0; |
5699 break; | 5726 break; |
5700 case GL_DEPTH_EXT: | 5727 case GL_DEPTH_EXT: |
5701 attachment = GL_DEPTH_ATTACHMENT; | 5728 attachment = GL_DEPTH_ATTACHMENT; |
5702 break; | 5729 break; |
5703 case GL_STENCIL_EXT: | 5730 case GL_STENCIL_EXT: |
5704 attachment = GL_STENCIL_ATTACHMENT; | 5731 attachment = GL_STENCIL_ATTACHMENT; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5738 // TODO(zmo): Revisit this. | 5765 // TODO(zmo): Revisit this. |
5739 break; | 5766 break; |
5740 } | 5767 } |
5741 | 5768 |
5742 if (!dirty) | 5769 if (!dirty) |
5743 return; | 5770 return; |
5744 | 5771 |
5745 // Marks each one of them as not cleared. | 5772 // Marks each one of them as not cleared. |
5746 for (GLsizei i = 0; i < count; ++i) { | 5773 for (GLsizei i = 0; i < count; ++i) { |
5747 if (framebuffer) { | 5774 if (framebuffer) { |
5748 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | 5775 if (attachments[i] == GL_DEPTH_STENCIL_ATTACHMENT) { |
5749 texture_manager(), | 5776 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), |
5750 attachments[i], | 5777 texture_manager(), |
5751 false); | 5778 GL_DEPTH_ATTACHMENT, |
5779 false); | |
5780 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | |
5781 texture_manager(), | |
5782 GL_STENCIL_ATTACHMENT, | |
5783 false); | |
5784 } else { | |
5785 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | |
5786 texture_manager(), | |
5787 attachments[i], | |
5788 false); | |
5789 } | |
5752 } else { | 5790 } else { |
5753 switch (attachments[i]) { | 5791 switch (attachments[i]) { |
5754 case GL_COLOR_EXT: | 5792 case GL_COLOR_EXT: |
5755 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; | 5793 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; |
5756 break; | 5794 break; |
5757 case GL_DEPTH_EXT: | 5795 case GL_DEPTH_EXT: |
5758 backbuffer_needs_clear_bits_ |= GL_DEPTH_BUFFER_BIT; | 5796 backbuffer_needs_clear_bits_ |= GL_DEPTH_BUFFER_BIT; |
5759 break; | 5797 break; |
5760 case GL_STENCIL_EXT: | 5798 case GL_STENCIL_EXT: |
5761 backbuffer_needs_clear_bits_ |= GL_STENCIL_BUFFER_BIT; | 5799 backbuffer_needs_clear_bits_ |= GL_STENCIL_BUFFER_BIT; |
(...skipping 11344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17106 } | 17144 } |
17107 | 17145 |
17108 // Include the auto-generated part of this file. We split this because it means | 17146 // Include the auto-generated part of this file. We split this because it means |
17109 // we can easily edit the non-auto generated parts right here in this file | 17147 // we can easily edit the non-auto generated parts right here in this file |
17110 // instead of having to edit some template or the code generator. | 17148 // instead of having to edit some template or the code generator. |
17111 #include "base/macros.h" | 17149 #include "base/macros.h" |
17112 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17150 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17113 | 17151 |
17114 } // namespace gles2 | 17152 } // namespace gles2 |
17115 } // namespace gpu | 17153 } // namespace gpu |
OLD | NEW |