Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1551)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2588653002: [Command buffer] Fix a bug for early return in blitFramebuffer (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7894 matching lines...) Expand 10 before | Expand all | Expand 10 after
7905 } 7905 }
7906 7906
7907 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); 7907 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER);
7908 if (read_buffer_samples > 0 && 7908 if (read_buffer_samples > 0 &&
7909 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { 7909 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) {
7910 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7910 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7911 "src framebuffer is multisampled, but src/dst regions are different"); 7911 "src framebuffer is multisampled, but src/dst regions are different");
7912 return; 7912 return;
7913 } 7913 }
7914 7914
7915 // If color/depth/stencil buffer have no image, we can remove corresponding
7916 // bitfield from mask and return early if mask equals to 0.
7917 // But validations should be done against the original mask.
7918 GLbitfield mask_blit = mask;
7919
7915 // Detect that designated read/depth/stencil buffer in read framebuffer miss 7920 // Detect that designated read/depth/stencil buffer in read framebuffer miss
7916 // image, and the corresponding buffers in draw framebuffer have image. 7921 // image, and the corresponding buffers in draw framebuffer have image.
7917 bool read_framebuffer_miss_image = false; 7922 bool read_framebuffer_miss_image = false;
7918 7923
7919 // Check whether read framebuffer and draw framebuffer have identical image 7924 // Check whether read framebuffer and draw framebuffer have identical image
7920 // TODO(yunchao): consider doing something like CheckFramebufferStatus(). 7925 // TODO(yunchao): consider doing something like CheckFramebufferStatus().
7921 // We cache the validation results, and if read_framebuffer doesn't change, 7926 // We cache the validation results, and if read_framebuffer doesn't change,
7922 // draw_framebuffer doesn't change, then use the cached status. 7927 // draw_framebuffer doesn't change, then use the cached status.
7923 enum FeedbackLoopState { 7928 enum FeedbackLoopState {
7924 FeedbackLoopTrue, 7929 FeedbackLoopTrue,
(...skipping 27 matching lines...) Expand all
7952 } 7957 }
7953 } 7958 }
7954 } else { 7959 } else {
7955 DCHECK(read_framebuffer && draw_framebuffer); 7960 DCHECK(read_framebuffer && draw_framebuffer);
7956 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) { 7961 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) {
7957 const Framebuffer::Attachment* depth_buffer_read = 7962 const Framebuffer::Attachment* depth_buffer_read =
7958 read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); 7963 read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
7959 const Framebuffer::Attachment* depth_buffer_draw = 7964 const Framebuffer::Attachment* depth_buffer_draw =
7960 draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT); 7965 draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
7961 if (!depth_buffer_draw || !depth_buffer_read) { 7966 if (!depth_buffer_draw || !depth_buffer_read) {
7962 mask &= ~GL_DEPTH_BUFFER_BIT; 7967 mask_blit &= ~GL_DEPTH_BUFFER_BIT;
7963 if (depth_buffer_draw) { 7968 if (depth_buffer_draw) {
7964 read_framebuffer_miss_image = true; 7969 read_framebuffer_miss_image = true;
7965 } 7970 }
7966 } else if (depth_buffer_draw->IsSameAttachment(depth_buffer_read)) { 7971 } else if (depth_buffer_draw->IsSameAttachment(depth_buffer_read)) {
7967 is_feedback_loop = FeedbackLoopTrue; 7972 is_feedback_loop = FeedbackLoopTrue;
7968 } 7973 }
7969 } 7974 }
7970 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) { 7975 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) {
7971 const Framebuffer::Attachment* stencil_buffer_read = 7976 const Framebuffer::Attachment* stencil_buffer_read =
7972 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); 7977 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
7973 const Framebuffer::Attachment* stencil_buffer_draw = 7978 const Framebuffer::Attachment* stencil_buffer_draw =
7974 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); 7979 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
7975 if (!stencil_buffer_draw || !stencil_buffer_read) { 7980 if (!stencil_buffer_draw || !stencil_buffer_read) {
7976 mask &= ~GL_STENCIL_BUFFER_BIT; 7981 mask_blit &= ~GL_STENCIL_BUFFER_BIT;
7977 if (stencil_buffer_draw) { 7982 if (stencil_buffer_draw) {
7978 read_framebuffer_miss_image = true; 7983 read_framebuffer_miss_image = true;
7979 } 7984 }
7980 } else if (stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { 7985 } else if (stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) {
7981 is_feedback_loop = FeedbackLoopTrue; 7986 is_feedback_loop = FeedbackLoopTrue;
7982 } 7987 }
7983 } 7988 }
7984 if (!mask && !read_framebuffer_miss_image)
7985 return;
7986 } 7989 }
7987 7990
7988 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat(); 7991 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat();
7989 GLenum src_type = GetBoundReadFramebufferTextureType(); 7992 GLenum src_type = GetBoundReadFramebufferTextureType();
7990 7993
7991 bool read_buffer_has_srgb = 7994 bool read_buffer_has_srgb =
7992 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB; 7995 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB;
7993 bool draw_buffers_has_srgb = false; 7996 bool draw_buffers_has_srgb = false;
7994 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { 7997 if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
7995 bool is_src_signed_int = 7998 bool is_src_signed_int =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
8063 "The designated attachment point(s) in read framebuffer miss image"); 8066 "The designated attachment point(s) in read framebuffer miss image");
8064 return; 8067 return;
8065 } 8068 }
8066 8069
8067 if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) { 8070 if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) {
8068 if (filter != GL_NEAREST) { 8071 if (filter != GL_NEAREST) {
8069 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 8072 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
8070 "invalid filter for depth/stencil"); 8073 "invalid filter for depth/stencil");
8071 return; 8074 return;
8072 } 8075 }
8073
8074 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) !=
8075 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) ||
8076 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) !=
8077 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) {
8078 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
8079 "src and dst formats differ for depth/stencil");
8080 return;
8081 }
8082 } 8076 }
8083 8077
8078 mask = mask_blit;
8079 if (!mask)
8080 return;
8081
8082 if (((mask & GL_DEPTH_BUFFER_BIT) != 0 &&
8083 (GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) !=
8084 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER))) ||
8085 ((mask & GL_STENCIL_BUFFER_BIT) != 0 &&
8086 ((GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) !=
8087 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))))) {
8088 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
8089 "src and dst formats differ for depth/stencil");
8090 return;
8091 }
8092
8093
8084 if (workarounds().adjust_src_dst_region_for_blitframebuffer) { 8094 if (workarounds().adjust_src_dst_region_for_blitframebuffer) {
8085 gfx::Size read_size = GetBoundReadFramebufferSize(); 8095 gfx::Size read_size = GetBoundReadFramebufferSize();
8086 gfx::Rect src_bounds(0, 0, read_size.width(), read_size.height()); 8096 gfx::Rect src_bounds(0, 0, read_size.width(), read_size.height());
8087 GLint src_x = srcX1 > srcX0 ? srcX0 : srcX1; 8097 GLint src_x = srcX1 > srcX0 ? srcX0 : srcX1;
8088 GLint src_y = srcY1 > srcY0 ? srcY0 : srcY1; 8098 GLint src_y = srcY1 > srcY0 ? srcY0 : srcY1;
8089 base::CheckedNumeric<GLint> src_width_temp = srcX1; 8099 base::CheckedNumeric<GLint> src_width_temp = srcX1;
8090 src_width_temp -= srcX0; 8100 src_width_temp -= srcX0;
8091 base::CheckedNumeric<GLint> src_height_temp = srcY1; 8101 base::CheckedNumeric<GLint> src_height_temp = srcY1;
8092 src_height_temp -= srcY0; 8102 src_height_temp -= srcY0;
8093 GLuint src_width = 0, src_height = 0; 8103 GLuint src_width = 0, src_height = 0;
(...skipping 10909 matching lines...) Expand 10 before | Expand all | Expand 10 after
19003 } 19013 }
19004 19014
19005 // Include the auto-generated part of this file. We split this because it means 19015 // Include the auto-generated part of this file. We split this because it means
19006 // we can easily edit the non-auto generated parts right here in this file 19016 // we can easily edit the non-auto generated parts right here in this file
19007 // instead of having to edit some template or the code generator. 19017 // instead of having to edit some template or the code generator.
19008 #include "base/macros.h" 19018 #include "base/macros.h"
19009 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19019 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19010 19020
19011 } // namespace gles2 19021 } // namespace gles2
19012 } // namespace gpu 19022 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698