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

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

Issue 2429005: Adds tracking of number of unrenderable textures so... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 #include "base/bits.h" 6 #include "base/bits.h"
7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
8 #include "gpu/command_buffer/service/context_group.h" 8 #include "gpu/command_buffer/service/context_group.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
10 10
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 TextureManager::TextureManager( 256 TextureManager::TextureManager(
257 GLint max_texture_size, 257 GLint max_texture_size,
258 GLint max_cube_map_texture_size) 258 GLint max_cube_map_texture_size)
259 : max_texture_size_(max_texture_size), 259 : max_texture_size_(max_texture_size),
260 max_cube_map_texture_size_(max_cube_map_texture_size), 260 max_cube_map_texture_size_(max_cube_map_texture_size),
261 max_levels_(ComputeMipMapCount(max_texture_size, 261 max_levels_(ComputeMipMapCount(max_texture_size,
262 max_texture_size, 262 max_texture_size,
263 max_texture_size)), 263 max_texture_size)),
264 max_cube_map_levels_(ComputeMipMapCount(max_cube_map_texture_size, 264 max_cube_map_levels_(ComputeMipMapCount(max_cube_map_texture_size,
265 max_cube_map_texture_size, 265 max_cube_map_texture_size,
266 max_cube_map_texture_size)) { 266 max_cube_map_texture_size)),
267 num_unrenderable_textures_(0) {
267 default_texture_2d_ = TextureInfo::Ref(new TextureInfo(0)); 268 default_texture_2d_ = TextureInfo::Ref(new TextureInfo(0));
268 SetInfoTarget(default_texture_2d_, GL_TEXTURE_2D); 269 SetInfoTarget(default_texture_2d_, GL_TEXTURE_2D);
269 default_texture_2d_->SetLevelInfo( 270 default_texture_2d_->SetLevelInfo(
270 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); 271 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
271 default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(0)); 272 default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(0));
272 SetInfoTarget(default_texture_cube_map_, GL_TEXTURE_CUBE_MAP); 273 SetInfoTarget(default_texture_cube_map_, GL_TEXTURE_CUBE_MAP);
273 for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { 274 for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) {
274 default_texture_cube_map_->SetLevelInfo( 275 default_texture_cube_map_->SetLevelInfo(
275 GLES2Util::IndexToGLFaceTarget(ii), 276 GLES2Util::IndexToGLFaceTarget(ii),
276 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); 277 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
(...skipping 13 matching lines...) Expand all
290 height <= max_size && 291 height <= max_size &&
291 depth <= max_size && 292 depth <= max_size &&
292 (level == 0 || 293 (level == 0 ||
293 (!GLES2Util::IsNPOT(width) && 294 (!GLES2Util::IsNPOT(width) &&
294 !GLES2Util::IsNPOT(height) && 295 !GLES2Util::IsNPOT(height) &&
295 !GLES2Util::IsNPOT(depth))) && 296 !GLES2Util::IsNPOT(depth))) &&
296 (target != GL_TEXTURE_CUBE_MAP || (width == height && depth == 1)) && 297 (target != GL_TEXTURE_CUBE_MAP || (width == height && depth == 1)) &&
297 (target != GL_TEXTURE_2D || (depth == 1)); 298 (target != GL_TEXTURE_2D || (depth == 1));
298 } 299 }
299 300
301 void TextureManager::SetLevelInfo(
302 TextureManager::TextureInfo* info,
303 GLenum target,
304 GLint level,
305 GLint internal_format,
306 GLsizei width,
307 GLsizei height,
308 GLsizei depth,
309 GLint border,
310 GLenum format,
311 GLenum type) {
312 DCHECK(info);
313 DCHECK(!info->IsDeleted());
314 if (!info->CanRender()) {
315 --num_unrenderable_textures_;
316 }
317 info->SetLevelInfo(
318 target, level, internal_format, width, height, depth,
319 border, format, type);
320 if (!info->CanRender()) {
321 ++num_unrenderable_textures_;
322 }
323 }
324
325 void TextureManager::SetParameter(
326 TextureManager::TextureInfo* info, GLenum pname, GLint param) {
327 DCHECK(info);
328 DCHECK(!info->IsDeleted());
329 if (!info->CanRender()) {
330 --num_unrenderable_textures_;
331 }
332 info->SetParameter(pname, param);
333 if (!info->CanRender()) {
334 ++num_unrenderable_textures_;
335 }
336 }
337
338 bool TextureManager::MarkMipmapsGenerated(TextureManager::TextureInfo* info) {
339 DCHECK(info);
340 DCHECK(!info->IsDeleted());
341 if (!info->CanRender()) {
342 --num_unrenderable_textures_;
343 }
344 bool result = info->MarkMipmapsGenerated();
345 if (!info->CanRender()) {
346 ++num_unrenderable_textures_;
347 }
348 return result;
349 }
350
300 TextureManager::TextureInfo* TextureManager::CreateTextureInfo( 351 TextureManager::TextureInfo* TextureManager::CreateTextureInfo(
301 GLuint client_id, GLuint service_id) { 352 GLuint client_id, GLuint service_id) {
302 TextureInfo::Ref info(new TextureInfo(service_id)); 353 TextureInfo::Ref info(new TextureInfo(service_id));
303 std::pair<TextureInfoMap::iterator, bool> result = 354 std::pair<TextureInfoMap::iterator, bool> result =
304 texture_infos_.insert(std::make_pair(client_id, info)); 355 texture_infos_.insert(std::make_pair(client_id, info));
305 DCHECK(result.second); 356 DCHECK(result.second);
357 if (!info->CanRender()) {
358 ++num_unrenderable_textures_;
359 }
306 return info.get(); 360 return info.get();
307 } 361 }
308 362
309 TextureManager::TextureInfo* TextureManager::GetTextureInfo( 363 TextureManager::TextureInfo* TextureManager::GetTextureInfo(
310 GLuint client_id) { 364 GLuint client_id) {
311 TextureInfoMap::iterator it = texture_infos_.find(client_id); 365 TextureInfoMap::iterator it = texture_infos_.find(client_id);
312 return it != texture_infos_.end() ? it->second : NULL; 366 return it != texture_infos_.end() ? it->second : NULL;
313 } 367 }
314 368
315 void TextureManager::RemoveTextureInfo(GLuint client_id) { 369 void TextureManager::RemoveTextureInfo(GLuint client_id) {
316 TextureInfoMap::iterator it = texture_infos_.find(client_id); 370 TextureInfoMap::iterator it = texture_infos_.find(client_id);
317 if (it != texture_infos_.end()) { 371 if (it != texture_infos_.end()) {
318 it->second->MarkAsDeleted(); 372 TextureInfo* info = it->second;
373 if (!info->CanRender()) {
374 --num_unrenderable_textures_;
375 }
376 info->MarkAsDeleted();
319 texture_infos_.erase(it); 377 texture_infos_.erase(it);
320 } 378 }
321 } 379 }
322 380
323 bool TextureManager::GetClientId(GLuint service_id, GLuint* client_id) const { 381 bool TextureManager::GetClientId(GLuint service_id, GLuint* client_id) const {
324 // This doesn't need to be fast. It's only used during slow queries. 382 // This doesn't need to be fast. It's only used during slow queries.
325 for (TextureInfoMap::const_iterator it = texture_infos_.begin(); 383 for (TextureInfoMap::const_iterator it = texture_infos_.begin();
326 it != texture_infos_.end(); ++it) { 384 it != texture_infos_.end(); ++it) {
327 if (it->second->service_id() == service_id) { 385 if (it->second->service_id() == service_id) {
328 *client_id = it->first; 386 *client_id = it->first;
329 return true; 387 return true;
330 } 388 }
331 } 389 }
332 return false; 390 return false;
333 } 391 }
334 392
335 } // namespace gles2 393 } // namespace gles2
336 } // namespace gpu 394 } // namespace gpu
337 395
338 396
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698