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

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

Issue 2329453002: [Command buffer] During blit FB, It is invalid if src source and dst source have identical image (Closed)
Patch Set: Created 4 years, 3 months 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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 // Infer color encoding from internalformat 1342 // Infer color encoding from internalformat
1343 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); 1343 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
1344 1344
1345 // Check that the currently bound read framebuffer's color image 1345 // Check that the currently bound read framebuffer's color image
1346 // isn't the target texture of the glCopyTex{Sub}Image{2D|3D}. 1346 // isn't the target texture of the glCopyTex{Sub}Image{2D|3D}.
1347 bool FormsTextureCopyingFeedbackLoop( 1347 bool FormsTextureCopyingFeedbackLoop(
1348 TextureRef* texture, 1348 TextureRef* texture,
1349 GLint level, 1349 GLint level,
1350 GLint layer); 1350 GLint layer);
1351 1351
1352 // Check that whether the currently bound draw framebuffer has image
Zhenyao Mo 2016/09/09 16:29:57 nit: remove that
yunchao 2016/09/09 16:47:33 Done.
1353 // that is identical to the read framebuffer's image for blitFramebuffer,
1354 // and only check the designated image type by parameter mask.
1355 bool FormsFramebufferBlitingFeedbackLoop(GLbitfield mask);
1356
1352 // Check if a framebuffer meets our requirements. 1357 // Check if a framebuffer meets our requirements.
1353 // Generates |gl_error| if the framebuffer is incomplete. 1358 // Generates |gl_error| if the framebuffer is incomplete.
1354 bool CheckFramebufferValid( 1359 bool CheckFramebufferValid(
1355 Framebuffer* framebuffer, 1360 Framebuffer* framebuffer,
1356 GLenum target, 1361 GLenum target,
1357 GLenum gl_error, 1362 GLenum gl_error,
1358 const char* func_name); 1363 const char* func_name);
1359 1364
1360 bool CheckBoundDrawFramebufferValid(const char* func_name); 1365 bool CheckBoundDrawFramebufferValid(const char* func_name);
1361 // Generates |gl_error| if the bound read fbo is incomplete. 1366 // Generates |gl_error| if the bound read fbo is incomplete.
(...skipping 2963 matching lines...) Expand 10 before | Expand all | Expand 10 after
4325 framebuffer_state_.bound_draw_framebuffer.get(); 4330 framebuffer_state_.bound_draw_framebuffer.get();
4326 if (!framebuffer) 4331 if (!framebuffer)
4327 return false; 4332 return false;
4328 const Framebuffer::Attachment* attachment = 4333 const Framebuffer::Attachment* attachment =
4329 framebuffer->GetReadBufferAttachment(); 4334 framebuffer->GetReadBufferAttachment();
4330 if (!attachment) 4335 if (!attachment)
4331 return false; 4336 return false;
4332 return attachment->FormsFeedbackLoop(texture, level, layer); 4337 return attachment->FormsFeedbackLoop(texture, level, layer);
4333 } 4338 }
4334 4339
4340 bool GLES2DecoderImpl::FormsFramebufferBlitingFeedbackLoop(GLbitfield mask) {
4341 Framebuffer* read_framebuffer =
4342 framebuffer_state_.bound_read_framebuffer.get();
4343 Framebuffer* draw_framebuffer =
4344 framebuffer_state_.bound_draw_framebuffer.get();
4345 // If both read framebuffer and draw framebuffer are default framebuffer,
4346 // They always have the same image.
4347 if (!read_framebuffer && !draw_framebuffer)
4348 return true;
4349 if (!read_framebuffer || !draw_framebuffer)
4350 return false;
4351 if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
4352 const Framebuffer::Attachment* read_buffer =
4353 read_framebuffer->GetReadBufferAttachment();
4354
4355 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {
Zhenyao Mo 2016/09/09 16:29:57 If you go through attachments of the draw_framebuf
yunchao 2016/09/09 16:47:33 That's true. But we still need to iterate to cover
Zhenyao Mo 2016/09/09 17:39:32 We should always optimize against most common use
4356 GLenum drawbuffer = static_cast<GLenum>(GL_DRAW_BUFFER0 + ii);
4357 if (draw_framebuffer->GetDrawBuffer(drawbuffer) == GL_NONE) {
4358 continue;
4359 }
4360 GLenum attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + ii);
4361 const Framebuffer::Attachment* draw_buffer =
4362 draw_framebuffer->GetAttachment(attachment);
4363 if (!draw_buffer) {
4364 continue;
4365 }
4366 if (draw_buffer->IsSameAttachment(read_buffer)) {
4367 return true;
4368 }
4369 }
4370 }
4371 if ((mask & GL_DEPTH_BUFFER_BIT) != 0) {
4372 const Framebuffer::Attachment* depth_buffer_read =
4373 read_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
4374 const Framebuffer::Attachment* depth_buffer_draw =
4375 draw_framebuffer->GetAttachment(GL_DEPTH_ATTACHMENT);
4376 if (depth_buffer_draw &&
Zhenyao Mo 2016/09/09 16:29:57 nit: wrong indent
yunchao 2016/09/09 16:47:33 Done.
4377 depth_buffer_draw->IsSameAttachment(depth_buffer_read)) {
4378 return true;
4379 }
4380 }
4381 if ((mask & GL_STENCIL_BUFFER_BIT) != 0) {
4382 const Framebuffer::Attachment* stencil_buffer_read =
4383 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
4384 const Framebuffer::Attachment* stencil_buffer_draw =
4385 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
4386 if (stencil_buffer_draw &&
4387 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) {
4388 return true;
4389 }
4390 }
4391 return false;
4392 }
4393
4335 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() { 4394 gfx::Size GLES2DecoderImpl::GetBoundReadFramebufferSize() {
4336 Framebuffer* framebuffer = 4395 Framebuffer* framebuffer =
4337 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4396 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4338 if (framebuffer != NULL) { 4397 if (framebuffer != NULL) {
4339 const Framebuffer::Attachment* attachment = 4398 const Framebuffer::Attachment* attachment =
4340 framebuffer->GetReadBufferAttachment(); 4399 framebuffer->GetReadBufferAttachment();
4341 if (attachment) { 4400 if (attachment) {
4342 return gfx::Size(attachment->width(), attachment->height()); 4401 return gfx::Size(attachment->width(), attachment->height());
4343 } 4402 }
4344 return gfx::Size(0, 0); 4403 return gfx::Size(0, 0);
(...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after
7592 } 7651 }
7593 7652
7594 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); 7653 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER);
7595 if (read_buffer_samples > 0 && 7654 if (read_buffer_samples > 0 &&
7596 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { 7655 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) {
7597 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7656 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7598 "src framebuffer is multisampled, but src/dst regions are different"); 7657 "src framebuffer is multisampled, but src/dst regions are different");
7599 return; 7658 return;
7600 } 7659 }
7601 7660
7661 if (FormsFramebufferBlitingFeedbackLoop(mask)) {
7662 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7663 "source buffer and destination buffers are identical");
7664 return;
7665 }
7666
7602 GLenum src_format = GetBoundReadFramebufferInternalFormat(); 7667 GLenum src_format = GetBoundReadFramebufferInternalFormat();
7603 GLenum src_type = GetBoundReadFramebufferTextureType(); 7668 GLenum src_type = GetBoundReadFramebufferTextureType();
7604 7669
7605 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { 7670 if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
7606 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); 7671 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format);
7607 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); 7672 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format);
7608 DCHECK(!is_src_signed_int || !is_src_unsigned_int); 7673 DCHECK(!is_src_signed_int || !is_src_unsigned_int);
7609 7674
7610 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { 7675 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) {
7611 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7676 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
(...skipping 10317 matching lines...) Expand 10 before | Expand all | Expand 10 after
17929 } 17994 }
17930 17995
17931 // Include the auto-generated part of this file. We split this because it means 17996 // Include the auto-generated part of this file. We split this because it means
17932 // we can easily edit the non-auto generated parts right here in this file 17997 // we can easily edit the non-auto generated parts right here in this file
17933 // instead of having to edit some template or the code generator. 17998 // instead of having to edit some template or the code generator.
17934 #include "base/macros.h" 17999 #include "base/macros.h"
17935 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18000 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17936 18001
17937 } // namespace gles2 18002 } // namespace gles2
17938 } // namespace gpu 18003 } // 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