| 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 7549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7560 Framebuffer* draw_framebuffer = | 7560 Framebuffer* draw_framebuffer = |
| 7561 framebuffer_state_.bound_draw_framebuffer.get(); | 7561 framebuffer_state_.bound_draw_framebuffer.get(); |
| 7562 // If both read framebuffer and draw framebuffer are default framebuffer, | 7562 // If both read framebuffer and draw framebuffer are default framebuffer, |
| 7563 // They always have identical image. Otherwise, if one of read framebuffer | 7563 // They always have identical image. Otherwise, if one of read framebuffer |
| 7564 // and draw framebuffe is default framebuffer, but the other is fbo, they | 7564 // and draw framebuffe is default framebuffer, but the other is fbo, they |
| 7565 // always have no identical image. | 7565 // always have no identical image. |
| 7566 if (!read_framebuffer && !draw_framebuffer) { | 7566 if (!read_framebuffer && !draw_framebuffer) { |
| 7567 is_feedback_loop = FeedbackLoopTrue; | 7567 is_feedback_loop = FeedbackLoopTrue; |
| 7568 } else if (!read_framebuffer || !draw_framebuffer) { | 7568 } else if (!read_framebuffer || !draw_framebuffer) { |
| 7569 is_feedback_loop = FeedbackLoopFalse; | 7569 is_feedback_loop = FeedbackLoopFalse; |
| 7570 } | 7570 } else { |
| 7571 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) { | 7571 DCHECK(read_framebuffer && draw_framebuffer); |
| 7572 const Framebuffer::Attachment* depth_buffer_read = | 7572 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) { |
| 7573 read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); | 7573 const Framebuffer::Attachment* depth_buffer_read = |
| 7574 const Framebuffer::Attachment* depth_buffer_draw = | 7574 read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); |
| 7575 draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); | 7575 const Framebuffer::Attachment* depth_buffer_draw = |
| 7576 if (depth_buffer_draw && | 7576 draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); |
| 7577 depth_buffer_draw->IsSameAttachment(depth_buffer_read)) { | 7577 if (depth_buffer_draw && |
| 7578 is_feedback_loop = FeedbackLoopTrue; | 7578 depth_buffer_draw->IsSameAttachment(depth_buffer_read)) { |
| 7579 is_feedback_loop = FeedbackLoopTrue; |
| 7580 } |
| 7579 } | 7581 } |
| 7580 } | 7582 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) { |
| 7581 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) { | 7583 const Framebuffer::Attachment* stencil_buffer_read = |
| 7582 const Framebuffer::Attachment* stencil_buffer_read = | 7584 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); |
| 7583 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); | 7585 const Framebuffer::Attachment* stencil_buffer_draw = |
| 7584 const Framebuffer::Attachment* stencil_buffer_draw = | 7586 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); |
| 7585 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); | 7587 if (stencil_buffer_draw && |
| 7586 if (stencil_buffer_draw && | 7588 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { |
| 7587 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { | 7589 is_feedback_loop = FeedbackLoopTrue; |
| 7588 is_feedback_loop = FeedbackLoopTrue; | 7590 } |
| 7589 } | 7591 } |
| 7590 } | 7592 } |
| 7591 | 7593 |
| 7592 GLenum src_format = GetBoundReadFramebufferInternalFormat(); | 7594 GLenum src_format = GetBoundReadFramebufferInternalFormat(); |
| 7593 GLenum src_type = GetBoundReadFramebufferTextureType(); | 7595 GLenum src_type = GetBoundReadFramebufferTextureType(); |
| 7594 | 7596 |
| 7595 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { | 7597 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { |
| 7596 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); | 7598 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); |
| 7597 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); | 7599 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); |
| 7598 DCHECK(!is_src_signed_int || !is_src_unsigned_int); | 7600 DCHECK(!is_src_signed_int || !is_src_unsigned_int); |
| 7599 | 7601 |
| 7600 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { | 7602 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { |
| 7601 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7603 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7602 "invalid filter for integer format"); | 7604 "invalid filter for integer format"); |
| 7603 return; | 7605 return; |
| 7604 } | 7606 } |
| 7605 | 7607 |
| 7606 GLenum src_sized_format = | 7608 GLenum src_sized_format = |
| 7607 GLES2Util::ConvertToSizedFormat(src_format, src_type); | 7609 GLES2Util::ConvertToSizedFormat(src_format, src_type); |
| 7610 DCHECK(read_framebuffer || (is_feedback_loop != FeedbackLoopUnknown)); |
| 7608 const Framebuffer::Attachment* read_buffer = | 7611 const Framebuffer::Attachment* read_buffer = |
| 7609 is_feedback_loop == FeedbackLoopUnknown ? | 7612 is_feedback_loop == FeedbackLoopUnknown ? |
| 7610 read_framebuffer->GetReadBufferAttachment() : nullptr; | 7613 read_framebuffer->GetReadBufferAttachment() : nullptr; |
| 7611 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { | 7614 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { |
| 7612 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( | 7615 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( |
| 7613 static_cast<GLint>(ii)); | 7616 static_cast<GLint>(ii)); |
| 7614 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); | 7617 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); |
| 7615 if (dst_format == 0) | 7618 if (dst_format == 0) |
| 7616 continue; | 7619 continue; |
| 7617 if (read_buffer_samples > 0 && | 7620 if (read_buffer_samples > 0 && |
| 7618 (src_sized_format != | 7621 (src_sized_format != |
| 7619 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { | 7622 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { |
| 7620 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7623 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7621 "src and dst formats differ for color"); | 7624 "src and dst formats differ for color"); |
| 7622 return; | 7625 return; |
| 7623 } | 7626 } |
| 7624 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); | 7627 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); |
| 7625 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); | 7628 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); |
| 7626 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); | 7629 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); |
| 7627 if (is_src_signed_int != is_dst_signed_int || | 7630 if (is_src_signed_int != is_dst_signed_int || |
| 7628 is_src_unsigned_int != is_dst_unsigned_int) { | 7631 is_src_unsigned_int != is_dst_unsigned_int) { |
| 7629 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7632 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7630 "incompatible src/dst color formats"); | 7633 "incompatible src/dst color formats"); |
| 7631 return; | 7634 return; |
| 7632 } | 7635 } |
| 7633 // Check whether draw buffers have identical color image with read buffer | 7636 // Check whether draw buffers have identical color image with read buffer |
| 7634 if (is_feedback_loop == FeedbackLoopUnknown) { | 7637 if (is_feedback_loop == FeedbackLoopUnknown) { |
| 7635 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + ii); | 7638 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + ii); |
| 7639 DCHECK(draw_framebuffer); |
| 7636 const Framebuffer::Attachment* draw_buffer = | 7640 const Framebuffer::Attachment* draw_buffer = |
| 7637 draw_framebuffer->GetAttachment(attachment); | 7641 draw_framebuffer->GetAttachment(attachment); |
| 7638 if (!draw_buffer) { | 7642 if (!draw_buffer) { |
| 7639 continue; | 7643 continue; |
| 7640 } | 7644 } |
| 7641 if (draw_buffer->IsSameAttachment(read_buffer)) { | 7645 if (draw_buffer->IsSameAttachment(read_buffer)) { |
| 7642 is_feedback_loop = FeedbackLoopTrue; | 7646 is_feedback_loop = FeedbackLoopTrue; |
| 7643 break; | 7647 break; |
| 7644 } | 7648 } |
| 7645 } | 7649 } |
| (...skipping 10324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17970 } | 17974 } |
| 17971 | 17975 |
| 17972 // Include the auto-generated part of this file. We split this because it means | 17976 // Include the auto-generated part of this file. We split this because it means |
| 17973 // we can easily edit the non-auto generated parts right here in this file | 17977 // we can easily edit the non-auto generated parts right here in this file |
| 17974 // instead of having to edit some template or the code generator. | 17978 // instead of having to edit some template or the code generator. |
| 17975 #include "base/macros.h" | 17979 #include "base/macros.h" |
| 17976 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17980 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17977 | 17981 |
| 17978 } // namespace gles2 | 17982 } // namespace gles2 |
| 17979 } // namespace gpu | 17983 } // namespace gpu |
| OLD | NEW |