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 5839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5850 break; | 5850 break; |
5851 } | 5851 } |
5852 | 5852 |
5853 if (!dirty) | 5853 if (!dirty) |
5854 return; | 5854 return; |
5855 | 5855 |
5856 // Marks each one of them as not cleared. | 5856 // Marks each one of them as not cleared. |
5857 for (GLsizei i = 0; i < validated_count; ++i) { | 5857 for (GLsizei i = 0; i < validated_count; ++i) { |
5858 if (framebuffer) { | 5858 if (framebuffer) { |
5859 if (validated_attachments[i] == GL_DEPTH_STENCIL_ATTACHMENT) { | 5859 if (validated_attachments[i] == GL_DEPTH_STENCIL_ATTACHMENT) { |
5860 // TODO(qiankun.miao@intel.com): We should only mark DEPTH and STENCIL | |
5861 // attachments as cleared when command buffer handles DEPTH_STENCIL | |
5862 // well. http://crbug.com/630568 | |
5863 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | 5860 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), |
5864 texture_manager(), | 5861 texture_manager(), |
5865 GL_DEPTH_ATTACHMENT, | 5862 GL_DEPTH_ATTACHMENT, |
5866 false); | 5863 false); |
5867 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | 5864 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), |
5868 texture_manager(), | 5865 texture_manager(), |
5869 GL_STENCIL_ATTACHMENT, | 5866 GL_STENCIL_ATTACHMENT, |
5870 false); | 5867 false); |
5871 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | |
5872 texture_manager(), | |
5873 GL_DEPTH_STENCIL_ATTACHMENT, | |
5874 false); | |
5875 } else { | 5868 } else { |
5876 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), | 5869 framebuffer->MarkAttachmentAsCleared(renderbuffer_manager(), |
5877 texture_manager(), | 5870 texture_manager(), |
5878 validated_attachments[i], | 5871 validated_attachments[i], |
5879 false); | 5872 false); |
5880 } | 5873 } |
5881 } else { | 5874 } else { |
5882 switch (validated_attachments[i]) { | 5875 switch (validated_attachments[i]) { |
5883 case GL_COLOR_EXT: | 5876 case GL_COLOR_EXT: |
5884 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; | 5877 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT; |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7113 if (client_renderbuffer_id) { | 7106 if (client_renderbuffer_id) { |
7114 renderbuffer = GetRenderbuffer(client_renderbuffer_id); | 7107 renderbuffer = GetRenderbuffer(client_renderbuffer_id); |
7115 if (!renderbuffer) { | 7108 if (!renderbuffer) { |
7116 LOCAL_SET_GL_ERROR( | 7109 LOCAL_SET_GL_ERROR( |
7117 GL_INVALID_OPERATION, | 7110 GL_INVALID_OPERATION, |
7118 "glFramebufferRenderbuffer", "unknown renderbuffer"); | 7111 "glFramebufferRenderbuffer", "unknown renderbuffer"); |
7119 return; | 7112 return; |
7120 } | 7113 } |
7121 service_id = renderbuffer->service_id(); | 7114 service_id = renderbuffer->service_id(); |
7122 } | 7115 } |
| 7116 std::vector<GLenum> attachments; |
| 7117 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 7118 attachments.push_back(GL_DEPTH_ATTACHMENT); |
| 7119 attachments.push_back(GL_STENCIL_ATTACHMENT); |
| 7120 } else { |
| 7121 attachments.push_back(attachment); |
| 7122 } |
7123 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); | 7123 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); |
7124 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 7124 for (GLenum attachment_point : attachments) { |
7125 glFramebufferRenderbufferEXT( | 7125 glFramebufferRenderbufferEXT( |
7126 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); | 7126 target, attachment_point, renderbuffertarget, service_id); |
7127 glFramebufferRenderbufferEXT( | 7127 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); |
7128 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); | 7128 if (error == GL_NO_ERROR) { |
7129 } else { | 7129 framebuffer->AttachRenderbuffer(attachment_point, renderbuffer); |
7130 glFramebufferRenderbufferEXT( | 7130 } |
7131 target, attachment, renderbuffertarget, service_id); | |
7132 } | |
7133 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); | |
7134 if (error == GL_NO_ERROR) { | |
7135 framebuffer->AttachRenderbuffer(attachment, renderbuffer); | |
7136 } | 7131 } |
7137 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 7132 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
7138 framebuffer_state_.clear_state_dirty = true; | 7133 framebuffer_state_.clear_state_dirty = true; |
7139 } | 7134 } |
7140 OnFboChanged(); | 7135 OnFboChanged(); |
7141 } | 7136 } |
7142 | 7137 |
7143 void GLES2DecoderImpl::DoDisable(GLenum cap) { | 7138 void GLES2DecoderImpl::DoDisable(GLenum cap) { |
7144 if (SetCapabilityState(cap, false)) { | 7139 if (SetCapabilityState(cap, false)) { |
7145 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && | 7140 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7213 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 7208 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
7214 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 7209 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
7215 clear_bits |= GL_COLOR_BUFFER_BIT; | 7210 clear_bits |= GL_COLOR_BUFFER_BIT; |
7216 | 7211 |
7217 if (SupportsDrawBuffers()) { | 7212 if (SupportsDrawBuffers()) { |
7218 reset_draw_buffers = | 7213 reset_draw_buffers = |
7219 framebuffer->PrepareDrawBuffersForClearingUninitializedAttachments(); | 7214 framebuffer->PrepareDrawBuffersForClearingUninitializedAttachments(); |
7220 } | 7215 } |
7221 } | 7216 } |
7222 | 7217 |
7223 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || | 7218 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)) { |
7224 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | |
7225 glClearStencil(0); | 7219 glClearStencil(0); |
7226 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 7220 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
7227 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 7221 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
7228 clear_bits |= GL_STENCIL_BUFFER_BIT; | 7222 clear_bits |= GL_STENCIL_BUFFER_BIT; |
7229 } | 7223 } |
7230 | 7224 |
7231 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) || | 7225 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)) { |
7232 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | |
7233 glClearDepth(1.0f); | 7226 glClearDepth(1.0f); |
7234 state_.SetDeviceDepthMask(GL_TRUE); | 7227 state_.SetDeviceDepthMask(GL_TRUE); |
7235 clear_bits |= GL_DEPTH_BUFFER_BIT; | 7228 clear_bits |= GL_DEPTH_BUFFER_BIT; |
7236 } | 7229 } |
7237 | 7230 |
7238 if (clear_bits) { | 7231 if (clear_bits) { |
7239 if (!cleared_int_renderbuffers && | 7232 if (!cleared_int_renderbuffers && |
7240 target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { | 7233 target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { |
7241 // TODO(zmo): There is no guarantee that an FBO that is complete on the | 7234 // TODO(zmo): There is no guarantee that an FBO that is complete on the |
7242 // READ attachment will be complete as a DRAW attachment. | 7235 // READ attachment will be complete as a DRAW attachment. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7368 target, attachments[ii], textarget, service_id, level); | 7361 target, attachments[ii], textarget, service_id, level); |
7369 } else { | 7362 } else { |
7370 if (features().use_img_for_multisampled_render_to_texture) { | 7363 if (features().use_img_for_multisampled_render_to_texture) { |
7371 glFramebufferTexture2DMultisampleIMG( | 7364 glFramebufferTexture2DMultisampleIMG( |
7372 target, attachments[ii], textarget, service_id, level, samples); | 7365 target, attachments[ii], textarget, service_id, level, samples); |
7373 } else { | 7366 } else { |
7374 glFramebufferTexture2DMultisampleEXT( | 7367 glFramebufferTexture2DMultisampleEXT( |
7375 target, attachments[ii], textarget, service_id, level, samples); | 7368 target, attachments[ii], textarget, service_id, level, samples); |
7376 } | 7369 } |
7377 } | 7370 } |
7378 } | 7371 GLenum error = LOCAL_PEEK_GL_ERROR(name); |
7379 GLenum error = LOCAL_PEEK_GL_ERROR(name); | 7372 if (error == GL_NO_ERROR) { |
7380 if (error == GL_NO_ERROR) { | 7373 framebuffer->AttachTexture(attachments[ii], texture_ref, textarget, level, |
7381 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, | 7374 samples); |
7382 samples); | 7375 } |
7383 } | 7376 } |
7384 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 7377 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
7385 framebuffer_state_.clear_state_dirty = true; | 7378 framebuffer_state_.clear_state_dirty = true; |
7386 } | 7379 } |
7387 | 7380 |
7388 OnFboChanged(); | 7381 OnFboChanged(); |
7389 } | 7382 } |
7390 | 7383 |
7391 void GLES2DecoderImpl::DoFramebufferTextureLayer( | 7384 void GLES2DecoderImpl::DoFramebufferTextureLayer( |
7392 GLenum target, GLenum attachment, GLuint client_texture_id, | 7385 GLenum target, GLenum attachment, GLuint client_texture_id, |
(...skipping 29 matching lines...) Expand all Loading... |
7422 return; | 7415 return; |
7423 } | 7416 } |
7424 if (!texture_manager()->ValidForTarget(texture_target, level, | 7417 if (!texture_manager()->ValidForTarget(texture_target, level, |
7425 0, 0, layer)) { | 7418 0, 0, layer)) { |
7426 LOCAL_SET_GL_ERROR( | 7419 LOCAL_SET_GL_ERROR( |
7427 GL_INVALID_VALUE, function_name, "invalid level or layer"); | 7420 GL_INVALID_VALUE, function_name, "invalid level or layer"); |
7428 return; | 7421 return; |
7429 } | 7422 } |
7430 } | 7423 } |
7431 glFramebufferTextureLayer(target, attachment, service_id, level, layer); | 7424 glFramebufferTextureLayer(target, attachment, service_id, level, layer); |
7432 framebuffer->AttachTextureLayer( | 7425 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
7433 attachment, texture_ref, texture_target, level, layer); | 7426 framebuffer->AttachTextureLayer( |
| 7427 GL_DEPTH_ATTACHMENT, texture_ref, texture_target, level, layer); |
| 7428 framebuffer->AttachTextureLayer( |
| 7429 GL_STENCIL_ATTACHMENT, texture_ref, texture_target, level, layer); |
| 7430 } else { |
| 7431 framebuffer->AttachTextureLayer( |
| 7432 attachment, texture_ref, texture_target, level, layer); |
| 7433 } |
7434 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 7434 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
7435 framebuffer_state_.clear_state_dirty = true; | 7435 framebuffer_state_.clear_state_dirty = true; |
7436 } | 7436 } |
7437 } | 7437 } |
7438 | 7438 |
7439 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 7439 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
7440 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 7440 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
7441 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; | 7441 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; |
7442 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 7442 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
7443 if (!framebuffer) { | 7443 if (!framebuffer) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7479 attachment = GL_DEPTH_ATTACHMENT; | 7479 attachment = GL_DEPTH_ATTACHMENT; |
7480 break; | 7480 break; |
7481 case GL_STENCIL: | 7481 case GL_STENCIL: |
7482 attachment = GL_STENCIL_ATTACHMENT; | 7482 attachment = GL_STENCIL_ATTACHMENT; |
7483 break; | 7483 break; |
7484 default: | 7484 default: |
7485 NOTREACHED(); | 7485 NOTREACHED(); |
7486 break; | 7486 break; |
7487 } | 7487 } |
7488 } | 7488 } |
| 7489 } else { |
| 7490 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 7491 const Framebuffer::Attachment* depth = |
| 7492 framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); |
| 7493 const Framebuffer::Attachment* stencil = |
| 7494 framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); |
| 7495 if ((!depth && !stencil) || |
| 7496 (depth && stencil && depth->IsSameAttachment(stencil))) { |
| 7497 attachment = GL_DEPTH_ATTACHMENT; |
| 7498 } else { |
| 7499 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 7500 "depth and stencil attachment mismatch"); |
| 7501 return; |
| 7502 } |
| 7503 } |
7489 } | 7504 } |
7490 if (pname == GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT && | 7505 if (pname == GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT && |
7491 features().use_img_for_multisampled_render_to_texture) { | 7506 features().use_img_for_multisampled_render_to_texture) { |
7492 pname = GL_TEXTURE_SAMPLES_IMG; | 7507 pname = GL_TEXTURE_SAMPLES_IMG; |
7493 } | 7508 } |
7494 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { | 7509 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
7495 DCHECK(framebuffer); | 7510 DCHECK(framebuffer); |
7496 // If we query from the driver, it will be service ID; however, we need to | 7511 // If we query from the driver, it will be service ID; however, we need to |
7497 // return the client ID here. | 7512 // return the client ID here. |
7498 const Framebuffer::Attachment* attachment_object = | 7513 const Framebuffer::Attachment* attachment_object = |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7588 // and draw framebuffe is default framebuffer, but the other is fbo, they | 7603 // and draw framebuffe is default framebuffer, but the other is fbo, they |
7589 // always have no identical image. | 7604 // always have no identical image. |
7590 if (!read_framebuffer && !draw_framebuffer) { | 7605 if (!read_framebuffer && !draw_framebuffer) { |
7591 is_feedback_loop = FeedbackLoopTrue; | 7606 is_feedback_loop = FeedbackLoopTrue; |
7592 } else if (!read_framebuffer || !draw_framebuffer) { | 7607 } else if (!read_framebuffer || !draw_framebuffer) { |
7593 is_feedback_loop = FeedbackLoopFalse; | 7608 is_feedback_loop = FeedbackLoopFalse; |
7594 } else { | 7609 } else { |
7595 DCHECK(read_framebuffer && draw_framebuffer); | 7610 DCHECK(read_framebuffer && draw_framebuffer); |
7596 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) { | 7611 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) { |
7597 const Framebuffer::Attachment* depth_buffer_read = | 7612 const Framebuffer::Attachment* depth_buffer_read = |
7598 read_framebuffer->GetDepthAttachment(); | 7613 read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); |
7599 const Framebuffer::Attachment* depth_buffer_draw = | 7614 const Framebuffer::Attachment* depth_buffer_draw = |
7600 draw_framebuffer->GetDepthAttachment(); | 7615 draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); |
7601 if (!depth_buffer_draw || !depth_buffer_read) { | 7616 if (!depth_buffer_draw || !depth_buffer_read) { |
7602 mask &= ~GL_DEPTH_BUFFER_BIT; | 7617 mask &= ~GL_DEPTH_BUFFER_BIT; |
7603 } else if (depth_buffer_draw->IsSameAttachment(depth_buffer_read)) { | 7618 } else if (depth_buffer_draw->IsSameAttachment(depth_buffer_read)) { |
7604 is_feedback_loop = FeedbackLoopTrue; | 7619 is_feedback_loop = FeedbackLoopTrue; |
7605 } | 7620 } |
7606 } | 7621 } |
7607 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) { | 7622 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) { |
7608 const Framebuffer::Attachment* stencil_buffer_read = | 7623 const Framebuffer::Attachment* stencil_buffer_read = |
7609 read_framebuffer->GetStencilAttachment(); | 7624 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); |
7610 const Framebuffer::Attachment* stencil_buffer_draw = | 7625 const Framebuffer::Attachment* stencil_buffer_draw = |
7611 draw_framebuffer->GetStencilAttachment(); | 7626 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); |
7612 if (!stencil_buffer_draw || !stencil_buffer_read) { | 7627 if (!stencil_buffer_draw || !stencil_buffer_read) { |
7613 mask &= ~GL_STENCIL_BUFFER_BIT; | 7628 mask &= ~GL_STENCIL_BUFFER_BIT; |
7614 } else if (stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { | 7629 } else if (stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { |
7615 is_feedback_loop = FeedbackLoopTrue; | 7630 is_feedback_loop = FeedbackLoopTrue; |
7616 } | 7631 } |
7617 } | 7632 } |
7618 if (!mask) | 7633 if (!mask) |
7619 return; | 7634 return; |
7620 } | 7635 } |
7621 | 7636 |
(...skipping 10461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18083 } | 18098 } |
18084 | 18099 |
18085 // Include the auto-generated part of this file. We split this because it means | 18100 // Include the auto-generated part of this file. We split this because it means |
18086 // we can easily edit the non-auto generated parts right here in this file | 18101 // we can easily edit the non-auto generated parts right here in this file |
18087 // instead of having to edit some template or the code generator. | 18102 // instead of having to edit some template or the code generator. |
18088 #include "base/macros.h" | 18103 #include "base/macros.h" |
18089 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18104 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18090 | 18105 |
18091 } // namespace gles2 | 18106 } // namespace gles2 |
18092 } // namespace gpu | 18107 } // namespace gpu |
OLD | NEW |