| 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 13375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13386 } else { | 13386 } else { |
| 13387 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, | 13387 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, |
| 13388 format, image_size, data); | 13388 format, image_size, data); |
| 13389 } | 13389 } |
| 13390 | 13390 |
| 13391 // This may be a slow command. Exit command processing to allow for | 13391 // This may be a slow command. Exit command processing to allow for |
| 13392 // context preemption and GPU watchdog checks. | 13392 // context preemption and GPU watchdog checks. |
| 13393 ExitCommandProcessingEarly(); | 13393 ExitCommandProcessingEarly(); |
| 13394 } | 13394 } |
| 13395 | 13395 |
| 13396 static void Clip( | |
| 13397 GLint start, GLint range, GLint sourceRange, | |
| 13398 GLint* out_start, GLint* out_range) { | |
| 13399 DCHECK(out_start); | |
| 13400 DCHECK(out_range); | |
| 13401 if (start < 0) { | |
| 13402 range += start; | |
| 13403 start = 0; | |
| 13404 } | |
| 13405 GLint end = start + range; | |
| 13406 if (end > sourceRange) { | |
| 13407 range -= end - sourceRange; | |
| 13408 } | |
| 13409 *out_start = start; | |
| 13410 *out_range = range; | |
| 13411 } | |
| 13412 | |
| 13413 bool GLES2DecoderImpl::ValidateCopyTexFormat( | 13396 bool GLES2DecoderImpl::ValidateCopyTexFormat( |
| 13414 const char* func_name, GLenum internal_format, | 13397 const char* func_name, GLenum internal_format, |
| 13415 GLenum read_format, GLenum read_type) { | 13398 GLenum read_format, GLenum read_type) { |
| 13416 if (read_format == 0) { | 13399 if (read_format == 0) { |
| 13417 LOCAL_SET_GL_ERROR( | 13400 LOCAL_SET_GL_ERROR( |
| 13418 GL_INVALID_OPERATION, func_name, "no valid color image"); | 13401 GL_INVALID_OPERATION, func_name, "no valid color image"); |
| 13419 return false; | 13402 return false; |
| 13420 } | 13403 } |
| 13421 // Check we have compatible formats. | 13404 // Check we have compatible formats. |
| 13422 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 13405 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13560 | 13543 |
| 13561 bool requires_luma_blit = | 13544 bool requires_luma_blit = |
| 13562 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), | 13545 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), |
| 13563 format); | 13546 format); |
| 13564 if (requires_luma_blit && | 13547 if (requires_luma_blit && |
| 13565 !InitializeCopyTexImageBlitter(func_name)) { | 13548 !InitializeCopyTexImageBlitter(func_name)) { |
| 13566 return; | 13549 return; |
| 13567 } | 13550 } |
| 13568 | 13551 |
| 13569 // Clip to size to source dimensions | 13552 // Clip to size to source dimensions |
| 13570 GLint copyX = 0; | 13553 gfx::Rect src(x, y, width, height); |
| 13571 GLint copyY = 0; | 13554 const gfx::Rect dst(0, 0, size.width(), size.height()); |
| 13572 GLint copyWidth = 0; | 13555 src.Intersect(dst); |
| 13573 GLint copyHeight = 0; | |
| 13574 Clip(x, width, size.width(), ©X, ©Width); | |
| 13575 Clip(y, height, size.height(), ©Y, ©Height); | |
| 13576 | 13556 |
| 13577 if (copyX != x || | 13557 if (src.x() != x || src.y() != y || |
| 13578 copyY != y || | 13558 src.width() != width || src.height() != height) { |
| 13579 copyWidth != width || | |
| 13580 copyHeight != height) { | |
| 13581 // some part was clipped so clear the rect. | 13559 // some part was clipped so clear the rect. |
| 13582 std::unique_ptr<char[]> zero(new char[pixels_size]); | 13560 std::unique_ptr<char[]> zero(new char[pixels_size]); |
| 13583 memset(zero.get(), 0, pixels_size); | 13561 memset(zero.get(), 0, pixels_size); |
| 13584 glTexImage2D(target, level, TextureManager::AdjustTexInternalFormat( | 13562 glTexImage2D(target, level, TextureManager::AdjustTexInternalFormat( |
| 13585 feature_info_.get(), internal_format), | 13563 feature_info_.get(), internal_format), |
| 13586 width, height, border, format, type, zero.get()); | 13564 width, height, border, format, type, zero.get()); |
| 13587 if (copyHeight > 0 && copyWidth > 0) { | 13565 if (!src.IsEmpty()) { |
| 13588 GLint dx = copyX - x; | 13566 GLint destX = src.x() - x; |
| 13589 GLint dy = copyY - y; | 13567 GLint destY = src.y() - y; |
| 13590 GLint destX = dx; | |
| 13591 GLint destY = dy; | |
| 13592 if (requires_luma_blit) { | 13568 if (requires_luma_blit) { |
| 13593 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | 13569 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
| 13594 this, texture->service_id(), texture->target(), target, format, | 13570 this, texture->service_id(), texture->target(), target, format, |
| 13595 type, level, destX, destY, 0, copyX, copyY, copyWidth, copyHeight, | 13571 type, level, destX, destY, 0, |
| 13572 src.x(), src.y(), src.width(), src.height(), |
| 13596 GetBoundReadFramebufferServiceId(), | 13573 GetBoundReadFramebufferServiceId(), |
| 13597 GetBoundReadFramebufferInternalFormat()); | 13574 GetBoundReadFramebufferInternalFormat()); |
| 13598 } else { | 13575 } else { |
| 13599 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, | 13576 glCopyTexSubImage2D(target, level, destX, destY, |
| 13600 copyWidth, copyHeight); | 13577 src.x(), src.y(), src.width(), src.height()); |
| 13601 } | 13578 } |
| 13602 } | 13579 } |
| 13603 } else { | 13580 } else { |
| 13604 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( | 13581 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( |
| 13605 feature_info_.get(), internal_format); | 13582 feature_info_.get(), internal_format); |
| 13606 if (workarounds().init_two_cube_map_levels_before_copyteximage && | 13583 if (workarounds().init_two_cube_map_levels_before_copyteximage && |
| 13607 texture->target() == GL_TEXTURE_CUBE_MAP && | 13584 texture->target() == GL_TEXTURE_CUBE_MAP && |
| 13608 target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { | 13585 target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { |
| 13609 for (int i = 0; i < 2; ++i) { | 13586 for (int i = 0; i < 2; ++i) { |
| 13610 TextureManager::DoTexImageArguments args = { | 13587 TextureManager::DoTexImageArguments args = { |
| 13611 target, i, final_internal_format, 1, 1, 1, border, | 13588 target, i, final_internal_format, 1, 1, 1, border, |
| 13612 format, type, nullptr, 1, 0, | 13589 format, type, nullptr, 1, 0, |
| 13613 TextureManager::DoTexImageArguments::kTexImage2D }; | 13590 TextureManager::DoTexImageArguments::kTexImage2D }; |
| 13614 texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, | 13591 texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, |
| 13615 &state_, &framebuffer_state_, texture_ref, func_name, args); | 13592 &state_, &framebuffer_state_, texture_ref, func_name, args); |
| 13616 } | 13593 } |
| 13617 } | 13594 } |
| 13618 | 13595 |
| 13619 // The service id and target of the texture attached to READ_FRAMEBUFFER. | 13596 // The service id and target of the texture attached to READ_FRAMEBUFFER. |
| 13620 GLuint source_texture_service_id = 0; | 13597 GLuint source_texture_service_id = 0; |
| 13621 GLenum source_texture_target = 0; | 13598 GLenum source_texture_target = 0; |
| 13622 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 13599 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 13623 bool use_workaround = NeedsCopyTextureImageWorkaround( | 13600 bool use_workaround = NeedsCopyTextureImageWorkaround( |
| 13624 final_internal_format, channels_exist, &source_texture_service_id, | 13601 final_internal_format, channels_exist, &source_texture_service_id, |
| 13625 &source_texture_target); | 13602 &source_texture_target); |
| 13626 if (requires_luma_blit) { | 13603 if (requires_luma_blit) { |
| 13627 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( | 13604 copy_tex_image_blit_->DoCopyTexImage2DToLUMACompatibilityTexture( |
| 13628 this, texture->service_id(), texture->target(), target, format, | 13605 this, texture->service_id(), texture->target(), target, format, |
| 13629 type, level, internal_format, copyX, copyY, copyWidth, copyHeight, | 13606 type, level, internal_format, x, y, width, height, |
| 13630 GetBoundReadFramebufferServiceId(), | 13607 GetBoundReadFramebufferServiceId(), |
| 13631 GetBoundReadFramebufferInternalFormat()); | 13608 GetBoundReadFramebufferInternalFormat()); |
| 13632 } else if (use_workaround) { | 13609 } else if (use_workaround) { |
| 13633 GLenum dest_texture_target = target; | 13610 GLenum dest_texture_target = target; |
| 13634 GLenum framebuffer_target = features().chromium_framebuffer_multisample | 13611 GLenum framebuffer_target = features().chromium_framebuffer_multisample |
| 13635 ? GL_READ_FRAMEBUFFER_EXT | 13612 ? GL_READ_FRAMEBUFFER_EXT |
| 13636 : GL_FRAMEBUFFER; | 13613 : GL_FRAMEBUFFER; |
| 13637 | 13614 |
| 13638 GLenum temp_internal_format = 0; | 13615 GLenum temp_internal_format = 0; |
| 13639 if (channels_exist == GLES2Util::kRGBA) { | 13616 if (channels_exist == GLES2Util::kRGBA) { |
| 13640 temp_internal_format = GL_RGBA; | 13617 temp_internal_format = GL_RGBA; |
| 13641 } else if (channels_exist == GLES2Util::kRGB) { | 13618 } else if (channels_exist == GLES2Util::kRGB) { |
| 13642 temp_internal_format = GL_RGB; | 13619 temp_internal_format = GL_RGB; |
| 13643 } else { | 13620 } else { |
| 13644 NOTREACHED(); | 13621 NOTREACHED(); |
| 13645 } | 13622 } |
| 13646 | 13623 |
| 13647 GLuint temp_texture; | 13624 GLuint temp_texture; |
| 13648 { | 13625 { |
| 13649 // Copy from the read framebuffer into |temp_texture|. | 13626 // Copy from the read framebuffer into |temp_texture|. |
| 13650 glGenTextures(1, &temp_texture); | 13627 glGenTextures(1, &temp_texture); |
| 13651 ScopedTextureBinder binder(&state_, temp_texture, | 13628 ScopedTextureBinder binder(&state_, temp_texture, |
| 13652 source_texture_target); | 13629 source_texture_target); |
| 13653 glCopyTexImage2D(source_texture_target, 0, temp_internal_format, copyX, | 13630 glCopyTexImage2D(source_texture_target, 0, temp_internal_format, |
| 13654 copyY, copyWidth, copyHeight, border); | 13631 x, y, width, height, border); |
| 13655 | 13632 |
| 13656 // Attach the temp texture to the read framebuffer. | 13633 // Attach the temp texture to the read framebuffer. |
| 13657 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, | 13634 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, |
| 13658 source_texture_target, temp_texture, 0); | 13635 source_texture_target, temp_texture, 0); |
| 13659 } | 13636 } |
| 13660 | 13637 |
| 13661 // Copy to the final texture. | 13638 // Copy to the final texture. |
| 13662 DCHECK_EQ(static_cast<GLuint>(GL_TEXTURE_2D), dest_texture_target); | 13639 DCHECK_EQ(static_cast<GLuint>(GL_TEXTURE_2D), dest_texture_target); |
| 13663 glCopyTexImage2D(dest_texture_target, level, final_internal_format, 0, 0, | 13640 glCopyTexImage2D(dest_texture_target, level, final_internal_format, 0, 0, |
| 13664 copyWidth, copyHeight, 0); | 13641 width, height, 0); |
| 13665 | 13642 |
| 13666 // Rebind source texture. | 13643 // Rebind source texture. |
| 13667 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, | 13644 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, |
| 13668 source_texture_target, | 13645 source_texture_target, |
| 13669 source_texture_service_id, 0); | 13646 source_texture_service_id, 0); |
| 13670 | 13647 |
| 13671 glDeleteTextures(1, &temp_texture); | 13648 glDeleteTextures(1, &temp_texture); |
| 13672 } else { | 13649 } else { |
| 13673 if (workarounds().init_one_cube_map_level_before_copyteximage && | 13650 if (workarounds().init_one_cube_map_level_before_copyteximage && |
| 13674 texture->target() == GL_TEXTURE_CUBE_MAP && | 13651 texture->target() == GL_TEXTURE_CUBE_MAP && |
| 13675 target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { | 13652 target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { |
| 13676 TextureManager::DoTexImageArguments args = { | 13653 TextureManager::DoTexImageArguments args = { |
| 13677 target, level, final_internal_format, width, height, 1, border, | 13654 target, level, final_internal_format, width, height, 1, border, |
| 13678 format, type, nullptr, pixels_size, 0, | 13655 format, type, nullptr, pixels_size, 0, |
| 13679 TextureManager::DoTexImageArguments::kTexImage2D }; | 13656 TextureManager::DoTexImageArguments::kTexImage2D }; |
| 13680 texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, | 13657 texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, |
| 13681 &state_, &framebuffer_state_, texture_ref, func_name, args); | 13658 &state_, &framebuffer_state_, texture_ref, func_name, args); |
| 13682 } | 13659 } |
| 13683 glCopyTexImage2D(target, level, final_internal_format, copyX, copyY, | 13660 glCopyTexImage2D(target, level, final_internal_format, |
| 13684 copyWidth, copyHeight, border); | 13661 x, y, width, height, border); |
| 13685 } | 13662 } |
| 13686 } | 13663 } |
| 13687 GLenum error = LOCAL_PEEK_GL_ERROR(func_name); | 13664 GLenum error = LOCAL_PEEK_GL_ERROR(func_name); |
| 13688 if (error == GL_NO_ERROR) { | 13665 if (error == GL_NO_ERROR) { |
| 13689 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, | 13666 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, |
| 13690 width, height, 1, border, format, | 13667 width, height, 1, border, format, |
| 13691 type, gfx::Rect(width, height)); | 13668 type, gfx::Rect(width, height)); |
| 13692 texture->ApplyFormatWorkarounds(feature_info_.get()); | 13669 texture->ApplyFormatWorkarounds(feature_info_.get()); |
| 13693 } | 13670 } |
| 13694 | 13671 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13739 | 13716 |
| 13740 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { | 13717 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) { |
| 13741 LOCAL_SET_GL_ERROR( | 13718 LOCAL_SET_GL_ERROR( |
| 13742 GL_INVALID_OPERATION, | 13719 GL_INVALID_OPERATION, |
| 13743 func_name, "source and destination textures are the same"); | 13720 func_name, "source and destination textures are the same"); |
| 13744 return; | 13721 return; |
| 13745 } | 13722 } |
| 13746 | 13723 |
| 13747 ScopedResolvedFramebufferBinder binder(this, false, true); | 13724 ScopedResolvedFramebufferBinder binder(this, false, true); |
| 13748 gfx::Size size = GetBoundReadFramebufferSize(); | 13725 gfx::Size size = GetBoundReadFramebufferSize(); |
| 13749 GLint copyX = 0; | |
| 13750 GLint copyY = 0; | |
| 13751 GLint copyWidth = 0; | |
| 13752 GLint copyHeight = 0; | |
| 13753 Clip(x, width, size.width(), ©X, ©Width); | |
| 13754 Clip(y, height, size.height(), ©Y, ©Height); | |
| 13755 | 13726 |
| 13756 GLint dx = copyX - x; | 13727 gfx::Rect src(x, y, width, height); |
| 13757 GLint dy = copyY - y; | 13728 const gfx::Rect dst(0, 0, size.width(), size.height()); |
| 13729 src.Intersect(dst); |
| 13730 |
| 13731 if (src.IsEmpty()) |
| 13732 return; |
| 13733 |
| 13734 GLint dx = src.x() - x; |
| 13735 GLint dy = src.y() - y; |
| 13758 GLint destX = xoffset + dx; | 13736 GLint destX = xoffset + dx; |
| 13759 GLint destY = yoffset + dy; | 13737 GLint destY = yoffset + dy; |
| 13760 // It's only legal to skip clearing the level of the target texture | 13738 // It's only legal to skip clearing the level of the target texture |
| 13761 // if the entire level is being redefined. | 13739 // if the entire level is being redefined. |
| 13762 GLsizei level_width = 0; | 13740 GLsizei level_width = 0; |
| 13763 GLsizei level_height = 0; | 13741 GLsizei level_height = 0; |
| 13764 GLsizei level_depth = 0; | 13742 GLsizei level_depth = 0; |
| 13765 bool have_level = texture->GetLevelSize( | 13743 bool have_level = texture->GetLevelSize( |
| 13766 target, level, &level_width, &level_height, &level_depth); | 13744 target, level, &level_width, &level_height, &level_depth); |
| 13767 // Validated above. | 13745 // Validated above. |
| 13768 DCHECK(have_level); | 13746 DCHECK(have_level); |
| 13769 if (destX == 0 && destY == 0 && | 13747 if (destX == 0 && destY == 0 && |
| 13770 copyWidth == level_width && copyHeight == level_height) { | 13748 src.width() == level_width && src.height() == level_height) { |
| 13771 // Write all pixels in below. | 13749 // Write all pixels in below. |
| 13772 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 13750 texture_manager()->SetLevelCleared(texture_ref, target, level, true); |
| 13773 } else { | 13751 } else { |
| 13774 gfx::Rect cleared_rect; | 13752 gfx::Rect cleared_rect; |
| 13775 if (TextureManager::CombineAdjacentRects( | 13753 if (TextureManager::CombineAdjacentRects( |
| 13776 texture->GetLevelClearedRect(target, level), | 13754 texture->GetLevelClearedRect(target, level), |
| 13777 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) { | 13755 gfx::Rect(destX, destY, src.width(), src.height()), |
| 13756 &cleared_rect)) { |
| 13778 DCHECK_GE(cleared_rect.size().GetArea(), | 13757 DCHECK_GE(cleared_rect.size().GetArea(), |
| 13779 texture->GetLevelClearedRect(target, level).size().GetArea()); | 13758 texture->GetLevelClearedRect(target, level).size().GetArea()); |
| 13780 texture_manager()->SetLevelClearedRect(texture_ref, target, level, | 13759 texture_manager()->SetLevelClearedRect(texture_ref, target, level, |
| 13781 cleared_rect); | 13760 cleared_rect); |
| 13782 } else { | 13761 } else { |
| 13783 // Otherwise clear part of texture level that is not already cleared. | 13762 // Otherwise clear part of texture level that is not already cleared. |
| 13784 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, | 13763 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
| 13785 level)) { | 13764 level)) { |
| 13786 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); | 13765 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); |
| 13787 return; | 13766 return; |
| 13788 } | 13767 } |
| 13789 } | 13768 } |
| 13790 } | 13769 } |
| 13791 | 13770 |
| 13792 if (copyHeight > 0 && copyWidth > 0) { | 13771 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( |
| 13793 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( | 13772 feature_info_.get(), internal_format)) { |
| 13794 feature_info_.get(), internal_format)) { | 13773 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { |
| 13795 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { | 13774 return; |
| 13796 return; | |
| 13797 } | |
| 13798 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | |
| 13799 this, texture->service_id(), texture->target(), target, | |
| 13800 internal_format, type, level, destX, destY, 0, | |
| 13801 copyX, copyY, copyWidth, copyHeight, | |
| 13802 GetBoundReadFramebufferServiceId(), | |
| 13803 GetBoundReadFramebufferInternalFormat()); | |
| 13804 } else { | |
| 13805 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, copyWidth, | |
| 13806 copyHeight); | |
| 13807 } | 13775 } |
| 13776 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
| 13777 this, texture->service_id(), texture->target(), target, |
| 13778 internal_format, type, level, destX, destY, 0, |
| 13779 src.x(), src.y(), src.width(), src.height(), |
| 13780 GetBoundReadFramebufferServiceId(), |
| 13781 GetBoundReadFramebufferInternalFormat()); |
| 13782 } else { |
| 13783 glCopyTexSubImage2D(target, level, destX, destY, |
| 13784 src.x(), src.y(), src.width(), src.height()); |
| 13808 } | 13785 } |
| 13809 | 13786 |
| 13810 // This may be a slow command. Exit command processing to allow for | 13787 // This may be a slow command. Exit command processing to allow for |
| 13811 // context preemption and GPU watchdog checks. | 13788 // context preemption and GPU watchdog checks. |
| 13812 ExitCommandProcessingEarly(); | 13789 ExitCommandProcessingEarly(); |
| 13813 } | 13790 } |
| 13814 | 13791 |
| 13815 void GLES2DecoderImpl::DoCopyTexSubImage3D( | 13792 void GLES2DecoderImpl::DoCopyTexSubImage3D( |
| 13816 GLenum target, | 13793 GLenum target, |
| 13817 GLint level, | 13794 GLint level, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13855 | 13832 |
| 13856 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { | 13833 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { |
| 13857 LOCAL_SET_GL_ERROR( | 13834 LOCAL_SET_GL_ERROR( |
| 13858 GL_INVALID_OPERATION, | 13835 GL_INVALID_OPERATION, |
| 13859 func_name, "source and destination textures are the same"); | 13836 func_name, "source and destination textures are the same"); |
| 13860 return; | 13837 return; |
| 13861 } | 13838 } |
| 13862 | 13839 |
| 13863 ScopedResolvedFramebufferBinder binder(this, false, true); | 13840 ScopedResolvedFramebufferBinder binder(this, false, true); |
| 13864 gfx::Size size = GetBoundReadFramebufferSize(); | 13841 gfx::Size size = GetBoundReadFramebufferSize(); |
| 13865 GLint copyX = 0; | |
| 13866 GLint copyY = 0; | |
| 13867 GLint copyWidth = 0; | |
| 13868 GLint copyHeight = 0; | |
| 13869 Clip(x, width, size.width(), ©X, ©Width); | |
| 13870 Clip(y, height, size.height(), ©Y, ©Height); | |
| 13871 | 13842 |
| 13872 GLint dx = copyX - x; | 13843 gfx::Rect src(x, y, width, height); |
| 13873 GLint dy = copyY - y; | 13844 const gfx::Rect dst(0, 0, size.width(), size.height()); |
| 13845 src.Intersect(dst); |
| 13846 if (src.IsEmpty()) |
| 13847 return; |
| 13848 |
| 13849 GLint dx = src.x() - x; |
| 13850 GLint dy = src.y() - y; |
| 13874 GLint destX = xoffset + dx; | 13851 GLint destX = xoffset + dx; |
| 13875 GLint destY = yoffset + dy; | 13852 GLint destY = yoffset + dy; |
| 13876 // For 3D textures, we always clear the entire texture to 0 if it is not | 13853 // For 3D textures, we always clear the entire texture to 0 if it is not |
| 13877 // cleared. See the code in TextureManager::ValidateAndDoTexSubImage | 13854 // cleared. See the code in TextureManager::ValidateAndDoTexSubImage |
| 13878 // for TexSubImage3D. | 13855 // for TexSubImage3D. |
| 13879 if (!texture->IsLevelCleared(target, level)) { | 13856 if (!texture->IsLevelCleared(target, level)) { |
| 13880 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, | 13857 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
| 13881 level)) { | 13858 level)) { |
| 13882 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); | 13859 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); |
| 13883 return; | 13860 return; |
| 13884 } | 13861 } |
| 13885 DCHECK(texture->IsLevelCleared(target, level)); | 13862 DCHECK(texture->IsLevelCleared(target, level)); |
| 13886 } | 13863 } |
| 13887 | 13864 |
| 13888 if (copyHeight > 0 && copyWidth > 0) { | 13865 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( |
| 13889 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( | 13866 feature_info_.get(), internal_format)) { |
| 13890 feature_info_.get(), internal_format)) { | 13867 if (!InitializeCopyTexImageBlitter(func_name)) { |
| 13891 if (!InitializeCopyTexImageBlitter(func_name)) { | 13868 return; |
| 13892 return; | |
| 13893 } | |
| 13894 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | |
| 13895 this, texture->service_id(), texture->target(), target, | |
| 13896 internal_format, type, level, destX, destY, zoffset, | |
| 13897 copyX, copyY, copyWidth, copyHeight, | |
| 13898 GetBoundReadFramebufferServiceId(), | |
| 13899 GetBoundReadFramebufferInternalFormat()); | |
| 13900 } else { | |
| 13901 glCopyTexSubImage3D(target, level, destX, destY, zoffset, | |
| 13902 copyX, copyY, copyWidth, copyHeight); | |
| 13903 } | 13869 } |
| 13870 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
| 13871 this, texture->service_id(), texture->target(), target, |
| 13872 internal_format, type, level, destX, destY, zoffset, |
| 13873 src.x(), src.y(), src.width(), src.height(), |
| 13874 GetBoundReadFramebufferServiceId(), |
| 13875 GetBoundReadFramebufferInternalFormat()); |
| 13876 } else { |
| 13877 glCopyTexSubImage3D(target, level, destX, destY, zoffset, |
| 13878 src.x(), src.y(), src.width(), src.height()); |
| 13904 } | 13879 } |
| 13905 | 13880 |
| 13906 // This may be a slow command. Exit command processing to allow for | 13881 // This may be a slow command. Exit command processing to allow for |
| 13907 // context preemption and GPU watchdog checks. | 13882 // context preemption and GPU watchdog checks. |
| 13908 ExitCommandProcessingEarly(); | 13883 ExitCommandProcessingEarly(); |
| 13909 } | 13884 } |
| 13910 | 13885 |
| 13911 error::Error GLES2DecoderImpl::HandleTexSubImage2D( | 13886 error::Error GLES2DecoderImpl::HandleTexSubImage2D( |
| 13912 uint32_t immediate_data_size, const volatile void* cmd_data) { | 13887 uint32_t immediate_data_size, const volatile void* cmd_data) { |
| 13913 const char* func_name = "glTexSubImage2D"; | 13888 const char* func_name = "glTexSubImage2D"; |
| (...skipping 4569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18483 } | 18458 } |
| 18484 | 18459 |
| 18485 // Include the auto-generated part of this file. We split this because it means | 18460 // Include the auto-generated part of this file. We split this because it means |
| 18486 // we can easily edit the non-auto generated parts right here in this file | 18461 // we can easily edit the non-auto generated parts right here in this file |
| 18487 // instead of having to edit some template or the code generator. | 18462 // instead of having to edit some template or the code generator. |
| 18488 #include "base/macros.h" | 18463 #include "base/macros.h" |
| 18489 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18464 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18490 | 18465 |
| 18491 } // namespace gles2 | 18466 } // namespace gles2 |
| 18492 } // namespace gpu | 18467 } // namespace gpu |
| OLD | NEW |