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

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

Issue 954053002: gpu: Avoid detaching images with glTexSubImage2D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 8472 matching lines...) Expand 10 before | Expand all | Expand 10 after
8483 } 8483 }
8484 } else { 8484 } else {
8485 tile_height = height; 8485 tile_height = height;
8486 } 8486 }
8487 8487
8488 // Assumes the size has already been checked. 8488 // Assumes the size has already been checked.
8489 scoped_ptr<char[]> zero(new char[size]); 8489 scoped_ptr<char[]> zero(new char[size]);
8490 memset(zero.get(), 0, size); 8490 memset(zero.get(), 0, size);
8491 glBindTexture(bind_target, service_id); 8491 glBindTexture(bind_target, service_id);
8492 8492
8493 Texture* clear_texture =
8494 texture_manager()->GetTextureForServiceId(service_id);
no sievers 2015/02/25 01:23:27 Can you change it instead to pass in texture? And
8495 bool has_images = clear_texture && clear_texture->HasImages();
8493 GLint y = 0; 8496 GLint y = 0;
8494 while (y < height) { 8497 while (y < height) {
8495 GLint h = y + tile_height > height ? height - y : tile_height; 8498 GLint h = y + tile_height > height ? height - y : tile_height;
8496 if (is_texture_immutable || h != height) { 8499 if (is_texture_immutable || h != height || has_images) {
8497 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get()); 8500 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get());
8498 } else { 8501 } else {
8499 glTexImage2D( 8502 glTexImage2D(
8500 target, level, internal_format, width, h, 0, format, type, 8503 target, level, internal_format, width, h, 0, format, type,
8501 zero.get()); 8504 zero.get());
8502 } 8505 }
8503 y += tile_height; 8506 y += tile_height;
8504 } 8507 }
8505 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( 8508 TextureRef* texture = texture_manager()->GetTextureInfoForTarget(
8506 &state_, bind_target); 8509 &state_, bind_target);
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
9434 GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big"); 9437 GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big");
9435 return error::kNoError; 9438 return error::kNoError;
9436 } 9439 }
9437 ScopedTextureUploadTimer timer(&texture_state_); 9440 ScopedTextureUploadTimer timer(&texture_state_);
9438 glTexSubImage2D( 9441 glTexSubImage2D(
9439 target, level, xoffset, yoffset, width, height, format, type, data); 9442 target, level, xoffset, yoffset, width, height, format, type, data);
9440 return error::kNoError; 9443 return error::kNoError;
9441 } 9444 }
9442 9445
9443 if (!texture_state_.texsubimage2d_faster_than_teximage2d && 9446 if (!texture_state_.texsubimage2d_faster_than_teximage2d &&
9444 !texture->IsImmutable()) { 9447 !texture->IsImmutable() &&
9448 !texture->HasImages()) {
9445 ScopedTextureUploadTimer timer(&texture_state_); 9449 ScopedTextureUploadTimer timer(&texture_state_);
9446 GLenum internal_format; 9450 GLenum internal_format;
9447 GLenum tex_type; 9451 GLenum tex_type;
9448 texture->GetLevelType(target, level, &tex_type, &internal_format); 9452 texture->GetLevelType(target, level, &tex_type, &internal_format);
9449 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need 9453 // NOTE: In OpenGL ES 2.0 border is always zero. If that changes we'll need
9450 // to look it up. 9454 // to look it up.
9451 glTexImage2D( 9455 glTexImage2D(
9452 target, level, internal_format, width, height, 0, format, type, data); 9456 target, level, internal_format, width, height, 0, format, type, data);
9453 } else { 9457 } else {
9454 ScopedTextureUploadTimer timer(&texture_state_); 9458 ScopedTextureUploadTimer timer(&texture_state_);
(...skipping 2666 matching lines...) Expand 10 before | Expand all | Expand 10 after
12121 } 12125 }
12122 } 12126 }
12123 12127
12124 // Include the auto-generated part of this file. We split this because it means 12128 // Include the auto-generated part of this file. We split this because it means
12125 // we can easily edit the non-auto generated parts right here in this file 12129 // we can easily edit the non-auto generated parts right here in this file
12126 // instead of having to edit some template or the code generator. 12130 // instead of having to edit some template or the code generator.
12127 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 12131 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
12128 12132
12129 } // namespace gles2 12133 } // namespace gles2
12130 } // namespace gpu 12134 } // 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