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 <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 | 1058 |
| 1059 // Clears any uncleared attachments attached to the given frame buffer. | 1059 // Clears any uncleared attachments attached to the given frame buffer. |
| 1060 // Returns false if there was a generated GL error. | 1060 // Returns false if there was a generated GL error. |
| 1061 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); | 1061 void ClearUnclearedAttachments(GLenum target, Framebuffer* framebuffer); |
| 1062 | 1062 |
| 1063 // overridden from GLES2Decoder | 1063 // overridden from GLES2Decoder |
| 1064 virtual bool ClearLevel(unsigned service_id, | 1064 virtual bool ClearLevel(unsigned service_id, |
| 1065 unsigned bind_target, | 1065 unsigned bind_target, |
| 1066 unsigned target, | 1066 unsigned target, |
| 1067 int level, | 1067 int level, |
| 1068 unsigned internal_format, | |
| 1068 unsigned format, | 1069 unsigned format, |
| 1069 unsigned type, | 1070 unsigned type, |
| 1070 int width, | 1071 int width, |
| 1071 int height, | 1072 int height, |
| 1072 bool is_texture_immutable) OVERRIDE; | 1073 bool is_texture_immutable) OVERRIDE; |
| 1073 | 1074 |
| 1074 // Restore all GL state that affects clearing. | 1075 // Restore all GL state that affects clearing. |
| 1075 void RestoreClearState(); | 1076 void RestoreClearState(); |
| 1076 | 1077 |
| 1077 // Remembers the state of some capabilities. | 1078 // Remembers the state of some capabilities. |
| (...skipping 6587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7665 // Just delegate it. Some validation is actually done before this. | 7666 // Just delegate it. Some validation is actually done before this. |
| 7666 buffer_manager()->ValidateAndDoBufferSubData( | 7667 buffer_manager()->ValidateAndDoBufferSubData( |
| 7667 &state_, target, offset, size, data); | 7668 &state_, target, offset, size, data); |
| 7668 } | 7669 } |
| 7669 | 7670 |
| 7670 bool GLES2DecoderImpl::ClearLevel( | 7671 bool GLES2DecoderImpl::ClearLevel( |
| 7671 unsigned service_id, | 7672 unsigned service_id, |
| 7672 unsigned bind_target, | 7673 unsigned bind_target, |
| 7673 unsigned target, | 7674 unsigned target, |
| 7674 int level, | 7675 int level, |
| 7676 unsigned internal_format, | |
| 7675 unsigned format, | 7677 unsigned format, |
| 7676 unsigned type, | 7678 unsigned type, |
| 7677 int width, | 7679 int width, |
| 7678 int height, | 7680 int height, |
| 7679 bool is_texture_immutable) { | 7681 bool is_texture_immutable) { |
| 7680 uint32 channels = GLES2Util::GetChannelsForFormat(format); | 7682 uint32 channels = GLES2Util::GetChannelsForFormat(format); |
| 7681 if (feature_info_->feature_flags().angle_depth_texture && | 7683 if (feature_info_->feature_flags().angle_depth_texture && |
| 7682 (channels & GLES2Util::kDepth) != 0) { | 7684 (channels & GLES2Util::kDepth) != 0) { |
| 7683 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D | 7685 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D |
| 7684 // on depth formats. | 7686 // on depth formats. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7751 memset(zero.get(), 0, size); | 7753 memset(zero.get(), 0, size); |
| 7752 glBindTexture(bind_target, service_id); | 7754 glBindTexture(bind_target, service_id); |
| 7753 | 7755 |
| 7754 GLint y = 0; | 7756 GLint y = 0; |
| 7755 while (y < height) { | 7757 while (y < height) { |
| 7756 GLint h = y + tile_height > height ? height - y : tile_height; | 7758 GLint h = y + tile_height > height ? height - y : tile_height; |
| 7757 if (is_texture_immutable || h != height) { | 7759 if (is_texture_immutable || h != height) { |
| 7758 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get()); | 7760 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get()); |
| 7759 } else { | 7761 } else { |
| 7760 glTexImage2D( | 7762 glTexImage2D( |
| 7761 target, level, format, width, h, 0, format, type, zero.get()); | 7763 target, level, internal_format, width, h, 0, format, type, |
| 7764 zero.get()); | |
| 7762 } | 7765 } |
| 7763 y += tile_height; | 7766 y += tile_height; |
| 7764 } | 7767 } |
| 7765 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( | 7768 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( |
| 7766 &state_, bind_target); | 7769 &state_, bind_target); |
| 7767 glBindTexture(bind_target, texture ? texture->service_id() : 0); | 7770 glBindTexture(bind_target, texture ? texture->service_id() : 0); |
| 7768 return true; | 7771 return true; |
| 7769 } | 7772 } |
| 7770 | 7773 |
| 7771 namespace { | 7774 namespace { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8286 Clip(x, width, size.width(), ©X, ©Width); | 8289 Clip(x, width, size.width(), ©X, ©Width); |
| 8287 Clip(y, height, size.height(), ©Y, ©Height); | 8290 Clip(y, height, size.height(), ©Y, ©Height); |
| 8288 | 8291 |
| 8289 if (copyX != x || | 8292 if (copyX != x || |
| 8290 copyY != y || | 8293 copyY != y || |
| 8291 copyWidth != width || | 8294 copyWidth != width || |
| 8292 copyHeight != height) { | 8295 copyHeight != height) { |
| 8293 // some part was clipped so clear the texture. | 8296 // some part was clipped so clear the texture. |
| 8294 if (!ClearLevel( | 8297 if (!ClearLevel( |
| 8295 texture->service_id(), texture->target(), | 8298 texture->service_id(), texture->target(), |
| 8296 target, level, internal_format, GL_UNSIGNED_BYTE, width, height, | 8299 target, level, internal_format, internal_format, GL_UNSIGNED_BYTE, |
|
piman
2014/02/18 20:40:10
This is probably wrong for RGBA32F internal format
oetuaho-nv
2014/02/19 09:51:17
CopyTexImage2D is not specified for float textures
piman
2014/02/19 20:26:19
Oh, it will fail ValidateFormatAndTypeCombination
| |
| 8297 texture->IsImmutable())) { | 8300 width, height, texture->IsImmutable())) { |
| 8298 LOCAL_SET_GL_ERROR( | 8301 LOCAL_SET_GL_ERROR( |
| 8299 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too big"); | 8302 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too big"); |
| 8300 return; | 8303 return; |
| 8301 } | 8304 } |
| 8302 if (copyHeight > 0 && copyWidth > 0) { | 8305 if (copyHeight > 0 && copyWidth > 0) { |
| 8303 GLint dx = copyX - x; | 8306 GLint dx = copyX - x; |
| 8304 GLint dy = copyY - y; | 8307 GLint dy = copyY - y; |
| 8305 GLint destX = dx; | 8308 GLint destX = dx; |
| 8306 GLint destY = dy; | 8309 GLint destY = dy; |
| 8307 glCopyTexSubImage2D(target, level, | 8310 glCopyTexSubImage2D(target, level, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8532 } | 8535 } |
| 8533 ScopedTextureUploadTimer timer(&texture_state_); | 8536 ScopedTextureUploadTimer timer(&texture_state_); |
| 8534 glTexSubImage2D( | 8537 glTexSubImage2D( |
| 8535 target, level, xoffset, yoffset, width, height, format, type, data); | 8538 target, level, xoffset, yoffset, width, height, format, type, data); |
| 8536 return error::kNoError; | 8539 return error::kNoError; |
| 8537 } | 8540 } |
| 8538 | 8541 |
| 8539 if (!texture_state_.texsubimage2d_faster_than_teximage2d && | 8542 if (!texture_state_.texsubimage2d_faster_than_teximage2d && |
| 8540 !texture->IsImmutable()) { | 8543 !texture->IsImmutable()) { |
| 8541 ScopedTextureUploadTimer timer(&texture_state_); | 8544 ScopedTextureUploadTimer timer(&texture_state_); |
| 8542 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the | 8545 GLenum internal_format; |
| 8543 // same as internal_foramt. If that changes we'll need to look them up. | 8546 GLenum tex_type; |
| 8547 texture->GetLevelType(target, level, &tex_type, &internal_format); | |
| 8548 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need | |
| 8549 // to look it up. | |
| 8544 glTexImage2D( | 8550 glTexImage2D( |
| 8545 target, level, format, width, height, 0, format, type, data); | 8551 target, level, internal_format, width, height, 0, format, type, data); |
| 8546 } else { | 8552 } else { |
| 8547 ScopedTextureUploadTimer timer(&texture_state_); | 8553 ScopedTextureUploadTimer timer(&texture_state_); |
| 8548 glTexSubImage2D( | 8554 glTexSubImage2D( |
| 8549 target, level, xoffset, yoffset, width, height, format, type, data); | 8555 target, level, xoffset, yoffset, width, height, format, type, data); |
| 8550 } | 8556 } |
| 8551 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 8557 texture_manager()->SetLevelCleared(texture_ref, target, level, true); |
| 8552 return error::kNoError; | 8558 return error::kNoError; |
| 8553 } | 8559 } |
| 8554 | 8560 |
| 8555 error::Error GLES2DecoderImpl::HandleTexSubImage2D( | 8561 error::Error GLES2DecoderImpl::HandleTexSubImage2D( |
| (...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10540 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10546 DoDidUseTexImageIfNeeded(texture, texture->target()); |
| 10541 } | 10547 } |
| 10542 | 10548 |
| 10543 // Include the auto-generated part of this file. We split this because it means | 10549 // Include the auto-generated part of this file. We split this because it means |
| 10544 // we can easily edit the non-auto generated parts right here in this file | 10550 // we can easily edit the non-auto generated parts right here in this file |
| 10545 // instead of having to edit some template or the code generator. | 10551 // instead of having to edit some template or the code generator. |
| 10546 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10552 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10547 | 10553 |
| 10548 } // namespace gles2 | 10554 } // namespace gles2 |
| 10549 } // namespace gpu | 10555 } // namespace gpu |
| OLD | NEW |