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

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

Issue 2234923002: [Command buffer] CopyTexSubImage3D: Copying pixels outside of framebuffer should be untouched (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed feedbacks from kbr and piman Created 4 years, 4 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 13246 matching lines...) Expand 10 before | Expand all | Expand 10 after
13257 return; 13257 return;
13258 } 13258 }
13259 13259
13260 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) { 13260 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) {
13261 LOCAL_SET_GL_ERROR( 13261 LOCAL_SET_GL_ERROR(
13262 GL_INVALID_OPERATION, 13262 GL_INVALID_OPERATION,
13263 func_name, "source and destination textures are the same"); 13263 func_name, "source and destination textures are the same");
13264 return; 13264 return;
13265 } 13265 }
13266 13266
13267 // For 3D textures, we always clear the entire texture. See the code in 13267 ScopedResolvedFrameBufferBinder binder(this, false, true);
13268 // TextureManager::ValidateAndDoTexSubImage for TexSubImage3D. 13268 gfx::Size size = GetBoundReadFrameBufferSize();
13269 GLint copyX = 0;
13270 GLint copyY = 0;
13271 GLint copyWidth = 0;
13272 GLint copyHeight = 0;
13273 Clip(x, width, size.width(), &copyX, &copyWidth);
13274 Clip(y, height, size.height(), &copyY, &copyHeight);
13275
13276 GLint dx = copyX - x;
13277 GLint dy = copyY - y;
13278 GLint destX = xoffset + dx;
13279 GLint destY = yoffset + dy;
13280 // For 3D textures, we always clear the entire texture to 0 if it is not
13281 // cleared. See the code in TextureManager::ValidateAndDoTexSubImage
13282 // for TexSubImage3D.
13269 if (!texture->IsLevelCleared(target, level)) { 13283 if (!texture->IsLevelCleared(target, level)) {
13270 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); 13284 texture_manager()->ClearTextureLevel(this, texture_ref, target, level);
13271 DCHECK(texture->IsLevelCleared(target, level)); 13285 DCHECK(texture->IsLevelCleared(target, level));
13286 } else {
13287 // For any pixel lying outside the framebuffer, all channels of the
13288 // associated texel are initialized to 0.
13289 if (x != copyX || y != copyY ||
13290 width != copyWidth || height != copyHeight) {
13291 uint32_t pixels_size = 0;
13292 GLenum format =
13293 TextureManager::ExtractFormatFromStorageFormat(internal_format);
13294 GLenum type =
13295 TextureManager::ExtractTypeFromStorageFormat(internal_format);
13296 // The internal_format was selected and validated previously by either
13297 // a TexImage3D or a TexStorage3D. So the format / type pair is valid.
13298 DCHECK(format && type);
13299
13300 if (!GLES2Util::ComputeImageDataSizes(
13301 width, height, 1, format, type,
13302 state_.unpack_alignment, &pixels_size, NULL, NULL)) {
13303 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too large");
13304 return;
13305 }
13306
13307 // some part was clipped so clear the rect.
13308 std::unique_ptr<char[]> zero(new char[pixels_size]);
13309 memset(zero.get(), 0, pixels_size);
13310 glTexSubImage3D(target, level, xoffset, yoffset, zoffset,
13311 width, height, 1, format, type, zero.get());
Ken Russell (switch to Gerrit) 2016/08/12 17:50:27 Per comments above and on the bug: let's change th
yunchao 2016/08/12 23:59:43 Acknowledged.
13312 }
13272 } 13313 }
13273 13314
13274 // TODO(yunchao): Follow-up CLs are necessary. For instance: 13315 // TODO(yunchao): Follow-up CLs are necessary. For instance:
13275 // 1. emulation of unsized formats in core profile 13316 // 1. emulation of unsized formats in core profile
13276 // 2. out-of-bounds reading, etc.
13277 13317
13278 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, 13318 if (copyHeight > 0 && copyWidth > 0) {
13279 height); 13319 glCopyTexSubImage3D(target, level, destX, destY, zoffset,
13320 copyX, copyY, copyWidth, copyHeight);
13321 }
13280 13322
13281 // This may be a slow command. Exit command processing to allow for 13323 // This may be a slow command. Exit command processing to allow for
13282 // context preemption and GPU watchdog checks. 13324 // context preemption and GPU watchdog checks.
13283 ExitCommandProcessingEarly(); 13325 ExitCommandProcessingEarly();
13284 } 13326 }
13285 13327
13286 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, 13328 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size,
13287 const void* cmd_data) { 13329 const void* cmd_data) {
13288 const gles2::cmds::TexSubImage2D& c = 13330 const gles2::cmds::TexSubImage2D& c =
13289 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); 13331 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data);
(...skipping 4453 matching lines...) Expand 10 before | Expand all | Expand 10 after
17743 } 17785 }
17744 17786
17745 // Include the auto-generated part of this file. We split this because it means 17787 // Include the auto-generated part of this file. We split this because it means
17746 // we can easily edit the non-auto generated parts right here in this file 17788 // we can easily edit the non-auto generated parts right here in this file
17747 // instead of having to edit some template or the code generator. 17789 // instead of having to edit some template or the code generator.
17748 #include "base/macros.h" 17790 #include "base/macros.h"
17749 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17750 17792
17751 } // namespace gles2 17793 } // namespace gles2
17752 } // namespace gpu 17794 } // 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