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(GL_DEPTH_ATTACHMENT) && | |
5669 framebuffer->HasDepthStencilFormatAttachment(GL_STENCIL_ATTACHMENT); | |
5670 bool invalidate_depth = false; | |
5671 bool invalidate_stencil = false; | |
5672 std::unique_ptr<GLenum[]> validated_attachments(new GLenum[count]); | |
5673 GLsizei validated_count = 0; | |
5674 | |
5665 // Validates the attachments. If one of them fails, the whole command fails. | 5675 // Validates the attachments. If one of them fails, the whole command fails. |
5666 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); | 5676 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); |
5667 GLenum thresh1 = GL_COLOR_ATTACHMENT15; | 5677 GLenum thresh1 = GL_COLOR_ATTACHMENT15; |
5668 for (GLsizei i = 0; i < count; ++i) { | 5678 for (GLsizei i = 0; i < count; ++i) { |
5669 if (framebuffer) { | 5679 if (framebuffer) { |
5670 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { | 5680 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { |
5671 LOCAL_SET_GL_ERROR( | 5681 LOCAL_SET_GL_ERROR( |
5672 GL_INVALID_OPERATION, function_name, "invalid attachment"); | 5682 GL_INVALID_OPERATION, function_name, "invalid attachment"); |
5673 return; | 5683 return; |
5674 } | 5684 } |
5675 if (!validators_->attachment.IsValid(attachments[i])) { | 5685 if (!validators_->attachment.IsValid(attachments[i])) { |
5676 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 5686 LOCAL_SET_GL_ERROR_INVALID_ENUM( |
5677 function_name, attachments[i], "attachments"); | 5687 function_name, attachments[i], "attachments"); |
5678 return; | 5688 return; |
5679 } | 5689 } |
5690 if (has_depth_stencil_format) { | |
5691 switch(attachments[i]) { | |
5692 case GL_DEPTH_ATTACHMENT: | |
5693 invalidate_depth = true; | |
5694 continue; | |
5695 case GL_STENCIL_ATTACHMENT: | |
5696 invalidate_stencil = true; | |
5697 continue; | |
5698 } | |
5699 } | |
5680 } else { | 5700 } else { |
5681 if (!validators_->backbuffer_attachment.IsValid(attachments[i])) { | 5701 if (!validators_->backbuffer_attachment.IsValid(attachments[i])) { |
5682 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 5702 LOCAL_SET_GL_ERROR_INVALID_ENUM( |
5683 function_name, attachments[i], "attachments"); | 5703 function_name, attachments[i], "attachments"); |
5684 return; | 5704 return; |
5685 } | 5705 } |
5686 } | 5706 } |
5707 validated_attachments[validated_count++] = attachments[i]; | |
5687 } | 5708 } |
5709 if (invalidate_depth && invalidate_stencil) { | |
5710 validated_attachments[validated_count++] = GL_DEPTH_STENCIL_ATTACHMENT; | |
5711 } | |
5712 count = validated_count; | |
5688 | 5713 |
5689 // If the default framebuffer is bound but we are still rendering to an | 5714 // If the default framebuffer is bound but we are still rendering to an |
5690 // FBO, translate attachment names that refer to default framebuffer | 5715 // FBO, translate attachment names that refer to default framebuffer |
5691 // channels to corresponding framebuffer attachments. | 5716 // channels to corresponding framebuffer attachments. |
5692 std::unique_ptr<GLenum[]> translated_attachments(new GLenum[count]); | 5717 std::unique_ptr<GLenum[]> translated_attachments(new GLenum[count]); |
5693 for (GLsizei i = 0; i < count; ++i) { | 5718 for (GLsizei i = 0; i < count; ++i) { |
5694 GLenum attachment = attachments[i]; | 5719 GLenum attachment = validated_attachments[i]; |
5695 if (!framebuffer && GetBackbufferServiceId()) { | 5720 if (!framebuffer && GetBackbufferServiceId()) { |
5696 switch (attachment) { | 5721 switch (attachment) { |
5697 case GL_COLOR_EXT: | 5722 case GL_COLOR_EXT: |
5698 attachment = GL_COLOR_ATTACHMENT0; | 5723 attachment = GL_COLOR_ATTACHMENT0; |
5699 break; | 5724 break; |
5700 case GL_DEPTH_EXT: | 5725 case GL_DEPTH_EXT: |
5701 attachment = GL_DEPTH_ATTACHMENT; | 5726 attachment = GL_DEPTH_ATTACHMENT; |
5702 break; | 5727 break; |
5703 case GL_STENCIL_EXT: | 5728 case GL_STENCIL_EXT: |
5704 attachment = GL_STENCIL_ATTACHMENT; | 5729 attachment = GL_STENCIL_ATTACHMENT; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5738 // TODO(zmo): Revisit this. | 5763 // TODO(zmo): Revisit this. |
5739 break; | 5764 break; |
5740 } | 5765 } |
5741 | 5766 |
5742 if (!dirty) | 5767 if (!dirty) |
5743 return; | 5768 return; |
5744 | 5769 |
5745 // Marks each one of them as not cleared. | 5770 // Marks each one of them as not cleared. |
5746 for (GLsizei i = 0; i < count; ++i) { | 5771 for (GLsizei i = 0; i < count; ++i) { |
5747 if (framebuffer) { | 5772 if (framebuffer) { |
5748 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | 5773 if (attachments[i] == GL_DEPTH_STENCIL_ATTACHMENT) { |
Ken Russell (switch to Gerrit)
2016/07/18 18:34:20
This looks wrong. It's referencing the attachments
| |
5749 texture_manager(), | 5774 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), |
5750 attachments[i], | 5775 texture_manager(), |
5751 false); | 5776 GL_DEPTH_ATTACHMENT, |
5777 false); | |
5778 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | |
5779 texture_manager(), | |
5780 GL_STENCIL_ATTACHMENT, | |
5781 false); | |
5782 } else { | |
5783 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | |
5784 texture_manager(), | |
5785 attachments[i], | |
5786 false); | |
5787 } | |
5752 } else { | 5788 } else { |
5753 switch (attachments[i]) { | 5789 switch (attachments[i]) { |
5754 case GL_COLOR_EXT: | 5790 case GL_COLOR_EXT: |
5755 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; | 5791 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; |
5756 break; | 5792 break; |
5757 case GL_DEPTH_EXT: | 5793 case GL_DEPTH_EXT: |
5758 backbuffer_needs_clear_bits_ |= GL_DEPTH_BUFFER_BIT; | 5794 backbuffer_needs_clear_bits_ |= GL_DEPTH_BUFFER_BIT; |
5759 break; | 5795 break; |
5760 case GL_STENCIL_EXT: | 5796 case GL_STENCIL_EXT: |
5761 backbuffer_needs_clear_bits_ |= GL_STENCIL_BUFFER_BIT; | 5797 backbuffer_needs_clear_bits_ |= GL_STENCIL_BUFFER_BIT; |
(...skipping 11344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17106 } | 17142 } |
17107 | 17143 |
17108 // Include the auto-generated part of this file. We split this because it means | 17144 // 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 | 17145 // 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. | 17146 // instead of having to edit some template or the code generator. |
17111 #include "base/macros.h" | 17147 #include "base/macros.h" |
17112 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17148 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17113 | 17149 |
17114 } // namespace gles2 | 17150 } // namespace gles2 |
17115 } // namespace gpu | 17151 } // namespace gpu |
OLD | NEW |