Chromium Code Reviews| 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 13246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // For 3D textures, we always clear the entire texture to 0 if it is not |
| 13268 // TextureManager::ValidateAndDoTexSubImage for TexSubImage3D. | 13268 // cleared. See the code in TextureManager::ValidateAndDoTexSubImage |
| 13269 // for TexSubImage3D. | |
| 13269 if (!texture->IsLevelCleared(target, level)) { | 13270 if (!texture->IsLevelCleared(target, level)) { |
| 13270 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); | 13271 texture_manager()->ClearTextureLevel(this, texture_ref, target, level); |
| 13271 DCHECK(texture->IsLevelCleared(target, level)); | 13272 DCHECK(texture->IsLevelCleared(target, level)); |
| 13273 } else { | |
| 13274 // For any pixel lying outside the framebuffer, all channels of the | |
| 13275 // associated texel are initialized to 0. | |
| 13276 ScopedResolvedFrameBufferBinder binder(this, false, true); | |
| 13277 gfx::Size size = GetBoundReadFrameBufferSize(); | |
| 13278 GLint copyX = 0; | |
| 13279 GLint copyY = 0; | |
| 13280 GLint copyWidth = 0; | |
| 13281 GLint copyHeight = 0; | |
| 13282 Clip(x, width, size.width(), ©X, ©Width); | |
| 13283 Clip(y, height, size.height(), ©Y, ©Height); | |
| 13284 if (x != copyX || y != copyY || | |
| 13285 width != copyWidth || height != copyHeight) { | |
| 13286 uint32_t pixels_size = 0; | |
| 13287 // TODO(piman): OpenGL ES 3.0.4 Section 3.8.5 specifies how to pick an | |
| 13288 // effective internal format if internal_format is unsized, which is a | |
| 13289 // fairly involved logic. For now, just make sure we pick something valid. | |
| 13290 GLenum format = | |
| 13291 TextureManager::ExtractFormatFromStorageFormat(internal_format); | |
| 13292 GLenum type = | |
| 13293 TextureManager::ExtractTypeFromStorageFormat(internal_format); | |
| 13294 if (!format || !type) { | |
|
piman
2016/08/11 18:16:31
This shouldn't happen, the internal_format was sel
yunchao
2016/08/12 15:42:45
Done.
| |
| 13295 LOCAL_SET_GL_ERROR( | |
| 13296 GL_INVALID_OPERATION, | |
| 13297 func_name, "Invalid unsized internal format."); | |
| 13298 return; | |
| 13299 } | |
| 13300 | |
| 13301 if (!GLES2Util::ComputeImageDataSizes( | |
| 13302 width, height, 1, format, type, | |
| 13303 state_.unpack_alignment, &pixels_size, NULL, NULL)) { | |
| 13304 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too large"); | |
| 13305 return; | |
| 13306 } | |
| 13307 | |
| 13308 if (!EnsureGPUMemoryAvailable(pixels_size)) { | |
|
Ken Russell (switch to Gerrit)
2016/08/11 18:09:44
I don't think this call is necessary. The texture'
piman
2016/08/11 18:16:31
I don't think this is needed - we're not allocatin
yunchao
2016/08/12 15:42:45
Done.
| |
| 13309 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "out of memory"); | |
| 13310 return; | |
| 13311 } | |
| 13312 | |
| 13313 // some part was clipped so clear the rect. | |
| 13314 std::unique_ptr<char[]> zero(new char[pixels_size]); | |
| 13315 memset(zero.get(), 0, pixels_size); | |
| 13316 glTexSubImage3D(target, level, xoffset, yoffset, zoffset, | |
| 13317 width, height, 1, format, type, zero.get()); | |
|
Ken Russell (switch to Gerrit)
2016/08/11 18:09:44
This sort of manual zeroing of the pixels that are
piman
2016/08/11 18:33:16
The 2D clearing code can deal with tracking partia
yunchao
2016/08/12 15:42:45
Yes. The spec is not consistent between CopyTexSub
Ken Russell (switch to Gerrit)
2016/08/12 17:39:15
Thanks for pointing out that inconsistency; it's a
yunchao
2016/08/12 23:59:43
Done.
| |
| 13318 } | |
| 13272 } | 13319 } |
| 13273 | 13320 |
| 13274 // TODO(yunchao): Follow-up CLs are necessary. For instance: | 13321 // TODO(yunchao): Follow-up CLs are necessary. For instance: |
| 13275 // 1. emulation of unsized formats in core profile | 13322 // 1. emulation of unsized formats in core profile |
| 13276 // 2. out-of-bounds reading, etc. | |
| 13277 | 13323 |
| 13278 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, | 13324 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, |
| 13279 height); | 13325 height); |
|
piman
2016/08/11 18:16:31
We want to adjust xoffset/yoffset/width/height to
yunchao
2016/08/12 15:42:45
Done.
| |
| 13280 | 13326 |
| 13281 // This may be a slow command. Exit command processing to allow for | 13327 // This may be a slow command. Exit command processing to allow for |
| 13282 // context preemption and GPU watchdog checks. | 13328 // context preemption and GPU watchdog checks. |
| 13283 ExitCommandProcessingEarly(); | 13329 ExitCommandProcessingEarly(); |
| 13284 } | 13330 } |
| 13285 | 13331 |
| 13286 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, | 13332 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, |
| 13287 const void* cmd_data) { | 13333 const void* cmd_data) { |
| 13288 const gles2::cmds::TexSubImage2D& c = | 13334 const gles2::cmds::TexSubImage2D& c = |
| 13289 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); | 13335 *static_cast<const gles2::cmds::TexSubImage2D*>(cmd_data); |
| (...skipping 4453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17743 } | 17789 } |
| 17744 | 17790 |
| 17745 // Include the auto-generated part of this file. We split this because it means | 17791 // 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 | 17792 // 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. | 17793 // instead of having to edit some template or the code generator. |
| 17748 #include "base/macros.h" | 17794 #include "base/macros.h" |
| 17749 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17795 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17750 | 17796 |
| 17751 } // namespace gles2 | 17797 } // namespace gles2 |
| 17752 } // namespace gpu | 17798 } // namespace gpu |
| OLD | NEW |