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

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

Issue 1505343003: Updating texture validation to account for sampler objects in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed DCHECK that was causing bots to fail Created 5 years 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
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/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 bool can_render_; 58 bool can_render_;
59 bool can_render_to_; 59 bool can_render_to_;
60 bool npot_; 60 bool npot_;
61 61
62 // Since we will be hashing this signature structure, the padding must be 62 // Since we will be hashing this signature structure, the padding must be
63 // zero initialized. Although the C++11 specifications specify that this is 63 // zero initialized. Although the C++11 specifications specify that this is
64 // true, we will use a constructor with a memset to further enforce it instead 64 // true, we will use a constructor with a memset to further enforce it instead
65 // of relying on compilers adhering to this deep dark corner specification. 65 // of relying on compilers adhering to this deep dark corner specification.
66 TextureSignature(GLenum target, 66 TextureSignature(GLenum target,
67 GLint level, 67 GLint level,
68 GLenum min_filter, 68 SamplerState sampler_state,
69 GLenum mag_filter,
70 GLenum wrap_r,
71 GLenum wrap_s,
72 GLenum wrap_t,
73 GLenum usage, 69 GLenum usage,
74 GLenum internal_format, 70 GLenum internal_format,
75 GLenum compare_func,
76 GLenum compare_mode,
77 GLsizei width, 71 GLsizei width,
78 GLsizei height, 72 GLsizei height,
79 GLsizei depth, 73 GLsizei depth,
80 GLfloat max_lod,
81 GLfloat min_lod,
82 GLint base_level, 74 GLint base_level,
83 GLint border, 75 GLint border,
84 GLint max_level, 76 GLint max_level,
85 GLenum format, 77 GLenum format,
86 GLenum type, 78 GLenum type,
87 bool has_image, 79 bool has_image,
88 bool can_render, 80 bool can_render,
89 bool can_render_to, 81 bool can_render_to,
90 bool npot) { 82 bool npot) {
91 memset(this, 0, sizeof(TextureSignature)); 83 memset(this, 0, sizeof(TextureSignature));
92 target_ = target; 84 target_ = target;
93 level_ = level; 85 level_ = level;
94 min_filter_ = min_filter; 86 min_filter_ = sampler_state.min_filter;
95 mag_filter_ = mag_filter; 87 mag_filter_ = sampler_state.mag_filter;
96 wrap_r_ = wrap_r; 88 wrap_r_ = sampler_state.wrap_r;
97 wrap_s_ = wrap_s; 89 wrap_s_ = sampler_state.wrap_s;
98 wrap_t_ = wrap_t; 90 wrap_t_ = sampler_state.wrap_t;
99 usage_ = usage; 91 usage_ = usage;
100 internal_format_ = internal_format; 92 internal_format_ = internal_format;
101 compare_func_ = compare_func; 93 compare_func_ = sampler_state.compare_func;
102 compare_mode_ = compare_mode; 94 compare_mode_ = sampler_state.compare_mode;
103 width_ = width; 95 width_ = width;
104 height_ = height; 96 height_ = height;
105 depth_ = depth; 97 depth_ = depth;
106 max_lod_ = max_lod; 98 max_lod_ = sampler_state.max_lod;
107 min_lod_ = min_lod; 99 min_lod_ = sampler_state.min_lod;
108 base_level_ = base_level; 100 base_level_ = base_level;
109 border_ = border; 101 border_ = border;
110 max_level_ = max_level; 102 max_level_ = max_level;
111 format_ = format; 103 format_ = format;
112 type_ = type; 104 type_ = type;
113 has_image_ = has_image; 105 has_image_ = has_image;
114 can_render_ = can_render; 106 can_render_ = can_render;
115 can_render_to_ = can_render_to; 107 can_render_to_ = can_render_to;
116 npot_ = npot; 108 npot_ = npot;
117 } 109 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 default_textures_[ii] = NULL; 291 default_textures_[ii] = NULL;
300 } 292 }
301 293
302 if (have_context) { 294 if (have_context) {
303 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); 295 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_);
304 } 296 }
305 297
306 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); 298 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented());
307 } 299 }
308 300
309 Texture::Texture(GLuint service_id) 301 Texture::Texture(GLuint service_id, bool is_es3_enabled)
Zhenyao Mo 2015/12/11 20:18:54 Per our offline discussion, I suggest we don't add
310 : mailbox_manager_(NULL), 302 : mailbox_manager_(NULL),
311 memory_tracking_ref_(NULL), 303 memory_tracking_ref_(NULL),
312 service_id_(service_id), 304 service_id_(service_id),
313 cleared_(true), 305 cleared_(true),
314 num_uncleared_mips_(0), 306 num_uncleared_mips_(0),
315 num_npot_faces_(0), 307 num_npot_faces_(0),
316 target_(0), 308 target_(0),
317 min_filter_(GL_NEAREST_MIPMAP_LINEAR),
318 mag_filter_(GL_LINEAR),
319 wrap_r_(GL_REPEAT),
320 wrap_s_(GL_REPEAT),
321 wrap_t_(GL_REPEAT),
322 usage_(GL_NONE), 309 usage_(GL_NONE),
323 compare_func_(GL_LEQUAL),
324 compare_mode_(GL_NONE),
325 max_lod_(1000.0f),
326 min_lod_(-1000.0f),
327 base_level_(0), 310 base_level_(0),
328 max_level_(1000), 311 max_level_(1000),
329 max_level_set_(-1), 312 max_level_set_(-1),
330 texture_complete_(false), 313 texture_complete_(false),
331 texture_mips_dirty_(false), 314 texture_mips_dirty_(false),
332 cube_complete_(false), 315 cube_complete_(false),
333 texture_level0_dirty_(false), 316 texture_level0_dirty_(false),
334 npot_(false), 317 npot_(false),
335 has_been_bound_(false), 318 has_been_bound_(false),
336 framebuffer_attachment_count_(0), 319 framebuffer_attachment_count_(0),
337 immutable_(false), 320 immutable_(false),
338 has_images_(false), 321 has_images_(false),
339 estimated_size_(0), 322 estimated_size_(0),
340 can_render_condition_(CAN_RENDER_ALWAYS), 323 can_render_condition_(CAN_RENDER_ALWAYS),
341 texture_max_anisotropy_initialized_(false) { 324 texture_max_anisotropy_initialized_(false),
325 is_es3_enabled_(is_es3_enabled) {
342 } 326 }
343 327
344 Texture::~Texture() { 328 Texture::~Texture() {
345 if (mailbox_manager_) 329 if (mailbox_manager_)
346 mailbox_manager_->TextureDeleted(this); 330 mailbox_manager_->TextureDeleted(this);
347 } 331 }
348 332
349 void Texture::AddTextureRef(TextureRef* ref) { 333 void Texture::AddTextureRef(TextureRef* ref) {
350 DCHECK(refs_.find(ref) == refs_.end()); 334 DCHECK(refs_.find(ref) == refs_.end());
351 refs_.insert(ref); 335 refs_.insert(ref);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 414 }
431 const Texture::LevelInfo& first_face = 415 const Texture::LevelInfo& first_face =
432 face_infos_[0].level_infos[base_level_]; 416 face_infos_[0].level_infos[base_level_];
433 if (first_face.width == 0 || 417 if (first_face.width == 0 ||
434 first_face.height == 0 || 418 first_face.height == 0 ||
435 first_face.depth == 0) { 419 first_face.depth == 0) {
436 return CAN_RENDER_NEVER; 420 return CAN_RENDER_NEVER;
437 } 421 }
438 } 422 }
439 423
424 if (target_ == GL_TEXTURE_CUBE_MAP && !cube_complete())
425 return CAN_RENDER_NEVER;
426
427 if (is_es3_enabled_)
428 return CAN_RENDER_WITH_VALID_SAMPLER;
429
430 // NeedsMips checkes the built-in sampler state, and so shouldn't be used to
431 // determine renderability with ES3 contexts.
440 bool needs_mips = NeedsMips(); 432 bool needs_mips = NeedsMips();
441 if (needs_mips) { 433 if (needs_mips) {
442 if (!texture_complete()) 434 if (!texture_complete())
443 return CAN_RENDER_NEVER; 435 return CAN_RENDER_NEVER;
444 } 436 }
445 437
446 if (target_ == GL_TEXTURE_CUBE_MAP && !cube_complete())
447 return CAN_RENDER_NEVER;
448
449 bool is_npot_compatible = !needs_mips && 438 bool is_npot_compatible = !needs_mips &&
450 wrap_s_ == GL_CLAMP_TO_EDGE && 439 sampler_state_.wrap_s == GL_CLAMP_TO_EDGE &&
451 wrap_t_ == GL_CLAMP_TO_EDGE; 440 sampler_state_.wrap_t == GL_CLAMP_TO_EDGE;
452 441
453 if (!is_npot_compatible) { 442 if (!is_npot_compatible) {
454 if (target_ == GL_TEXTURE_RECTANGLE_ARB) 443 if (target_ == GL_TEXTURE_RECTANGLE_ARB)
455 return CAN_RENDER_NEVER; 444 return CAN_RENDER_NEVER;
456 else if (npot()) 445 else if (npot())
457 return CAN_RENDER_ONLY_IF_NPOT; 446 return CAN_RENDER_ONLY_IF_NPOT;
458 } 447 }
459 448
460 return CAN_RENDER_ALWAYS; 449 return CAN_RENDER_ALWAYS;
461 } 450 }
462 451
463 bool Texture::CanRender(const FeatureInfo* feature_info) const { 452 bool Texture::CanRender(const FeatureInfo* feature_info) const {
453 return CanRenderWithSampler(feature_info, sampler_state());
454 }
455
456 bool Texture::CanRenderWithSampler(const FeatureInfo* feature_info,
457 const SamplerState* sampler_state) const {
458 DCHECK(sampler_state);
459
464 switch (can_render_condition_) { 460 switch (can_render_condition_) {
465 case CAN_RENDER_ALWAYS: 461 case CAN_RENDER_ALWAYS:
466 return true; 462 return true;
467 case CAN_RENDER_NEVER: 463 case CAN_RENDER_NEVER:
468 return false; 464 return false;
469 case CAN_RENDER_ONLY_IF_NPOT: 465 case CAN_RENDER_ONLY_IF_NPOT:
466 return feature_info->feature_flags().npot_ok;
467 case CAN_RENDER_WITH_VALID_SAMPLER:
470 break; 468 break;
471 } 469 }
472 return feature_info->feature_flags().npot_ok; 470
471 bool needs_mips = sampler_state->min_filter != GL_NEAREST &&
472 sampler_state->min_filter != GL_LINEAR;
473 if (needs_mips && !texture_complete())
474 return false;
475
476 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) {
477 return false;
478 }
479
480 const Texture::LevelInfo& first_level =
481 face_infos_[0].level_infos[base_level_];
482
483 if (first_level.type == GL_FLOAT &&
484 !feature_info->feature_flags().enable_texture_float_linear &&
485 (sampler_state->min_filter != GL_NEAREST_MIPMAP_NEAREST ||
486 sampler_state->mag_filter != GL_NEAREST)) {
487 return false;
488 } else if (first_level.type == GL_HALF_FLOAT_OES &&
489 !feature_info->feature_flags().enable_texture_half_float_linear &&
490 (sampler_state->min_filter != GL_NEAREST_MIPMAP_NEAREST ||
491 sampler_state->mag_filter != GL_NEAREST)) {
492 return false;
493 }
494
495 return true;
473 } 496 }
474 497
475 void Texture::AddToSignature( 498 void Texture::AddToSignature(
476 const FeatureInfo* feature_info, 499 const FeatureInfo* feature_info,
477 GLenum target, 500 GLenum target,
478 GLint level, 501 GLint level,
479 std::string* signature) const { 502 std::string* signature) const {
480 DCHECK(feature_info); 503 DCHECK(feature_info);
481 DCHECK(signature); 504 DCHECK(signature);
482 DCHECK_GE(level, 0); 505 DCHECK_GE(level, 0);
483 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); 506 size_t face_index = GLES2Util::GLTargetToFaceIndex(target);
484 DCHECK_LT(static_cast<size_t>(face_index), 507 DCHECK_LT(static_cast<size_t>(face_index),
485 face_infos_.size()); 508 face_infos_.size());
486 DCHECK_LT(static_cast<size_t>(level), 509 DCHECK_LT(static_cast<size_t>(level),
487 face_infos_[face_index].level_infos.size()); 510 face_infos_[face_index].level_infos.size());
488 511
489 const Texture::LevelInfo& info = 512 const Texture::LevelInfo& info =
490 face_infos_[face_index].level_infos[level]; 513 face_infos_[face_index].level_infos[level];
491 514
492 TextureSignature signature_data(target, 515 TextureSignature signature_data(target,
493 level, 516 level,
494 min_filter_, 517 sampler_state_,
495 mag_filter_,
496 wrap_r_,
497 wrap_s_,
498 wrap_t_,
499 usage_, 518 usage_,
500 info.internal_format, 519 info.internal_format,
501 compare_func_,
502 compare_mode_,
503 info.width, 520 info.width,
504 info.height, 521 info.height,
505 info.depth, 522 info.depth,
506 max_lod_,
507 min_lod_,
508 base_level_, 523 base_level_,
509 info.border, 524 info.border,
510 max_level_, 525 max_level_,
511 info.format, 526 info.format,
512 info.type, 527 info.type,
513 info.image.get() != NULL, 528 info.image.get() != NULL,
514 CanRender(feature_info), 529 CanRender(feature_info),
515 CanRenderTo(), 530 CanRenderTo(),
516 npot_); 531 npot_);
517 532
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 const FeatureInfo* feature_info, GLenum target, GLint max_levels) { 573 const FeatureInfo* feature_info, GLenum target, GLint max_levels) {
559 DCHECK_EQ(0u, target_); // you can only set this once. 574 DCHECK_EQ(0u, target_); // you can only set this once.
560 target_ = target; 575 target_ = target;
561 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; 576 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
562 face_infos_.resize(num_faces); 577 face_infos_.resize(num_faces);
563 for (size_t ii = 0; ii < num_faces; ++ii) { 578 for (size_t ii = 0; ii < num_faces; ++ii) {
564 face_infos_[ii].level_infos.resize(max_levels); 579 face_infos_[ii].level_infos.resize(max_levels);
565 } 580 }
566 581
567 if (target == GL_TEXTURE_EXTERNAL_OES || target == GL_TEXTURE_RECTANGLE_ARB) { 582 if (target == GL_TEXTURE_EXTERNAL_OES || target == GL_TEXTURE_RECTANGLE_ARB) {
568 min_filter_ = GL_LINEAR; 583 sampler_state_.min_filter = GL_LINEAR;
569 wrap_s_ = wrap_t_ = GL_CLAMP_TO_EDGE; 584 sampler_state_.wrap_s = sampler_state_.wrap_t = GL_CLAMP_TO_EDGE;
570 } 585 }
571 586
572 if (target == GL_TEXTURE_EXTERNAL_OES) { 587 if (target == GL_TEXTURE_EXTERNAL_OES) {
573 immutable_ = true; 588 immutable_ = true;
574 } 589 }
575 Update(feature_info); 590 Update(feature_info);
576 UpdateCanRenderCondition(); 591 UpdateCanRenderCondition();
577 } 592 }
578 593
579 bool Texture::CanGenerateMipmaps( 594 bool Texture::CanGenerateMipmaps(
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 case GL_TEXTURE_MIN_LOD: 990 case GL_TEXTURE_MIN_LOD:
976 case GL_TEXTURE_MAX_LOD: 991 case GL_TEXTURE_MAX_LOD:
977 { 992 {
978 GLfloat fparam = static_cast<GLfloat>(param); 993 GLfloat fparam = static_cast<GLfloat>(param);
979 return SetParameterf(feature_info, pname, fparam); 994 return SetParameterf(feature_info, pname, fparam);
980 } 995 }
981 case GL_TEXTURE_MIN_FILTER: 996 case GL_TEXTURE_MIN_FILTER:
982 if (!feature_info->validators()->texture_min_filter_mode.IsValid(param)) { 997 if (!feature_info->validators()->texture_min_filter_mode.IsValid(param)) {
983 return GL_INVALID_ENUM; 998 return GL_INVALID_ENUM;
984 } 999 }
985 min_filter_ = param; 1000 sampler_state_.min_filter = param;
986 break; 1001 break;
987 case GL_TEXTURE_MAG_FILTER: 1002 case GL_TEXTURE_MAG_FILTER:
988 if (!feature_info->validators()->texture_mag_filter_mode.IsValid(param)) { 1003 if (!feature_info->validators()->texture_mag_filter_mode.IsValid(param)) {
989 return GL_INVALID_ENUM; 1004 return GL_INVALID_ENUM;
990 } 1005 }
991 mag_filter_ = param; 1006 sampler_state_.mag_filter = param;
992 break; 1007 break;
993 case GL_TEXTURE_WRAP_R: 1008 case GL_TEXTURE_WRAP_R:
994 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { 1009 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) {
995 return GL_INVALID_ENUM; 1010 return GL_INVALID_ENUM;
996 } 1011 }
997 wrap_r_ = param; 1012 sampler_state_.wrap_r = param;
998 break; 1013 break;
999 case GL_TEXTURE_WRAP_S: 1014 case GL_TEXTURE_WRAP_S:
1000 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { 1015 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) {
1001 return GL_INVALID_ENUM; 1016 return GL_INVALID_ENUM;
1002 } 1017 }
1003 wrap_s_ = param; 1018 sampler_state_.wrap_s = param;
1004 break; 1019 break;
1005 case GL_TEXTURE_WRAP_T: 1020 case GL_TEXTURE_WRAP_T:
1006 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { 1021 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) {
1007 return GL_INVALID_ENUM; 1022 return GL_INVALID_ENUM;
1008 } 1023 }
1009 wrap_t_ = param; 1024 sampler_state_.wrap_t = param;
1010 break; 1025 break;
1011 case GL_TEXTURE_COMPARE_FUNC: 1026 case GL_TEXTURE_COMPARE_FUNC:
1012 if (!feature_info->validators()->texture_compare_func.IsValid(param)) { 1027 if (!feature_info->validators()->texture_compare_func.IsValid(param)) {
1013 return GL_INVALID_ENUM; 1028 return GL_INVALID_ENUM;
1014 } 1029 }
1015 compare_func_ = param; 1030 sampler_state_.compare_func = param;
1016 break; 1031 break;
1017 case GL_TEXTURE_COMPARE_MODE: 1032 case GL_TEXTURE_COMPARE_MODE:
1018 if (!feature_info->validators()->texture_compare_mode.IsValid(param)) { 1033 if (!feature_info->validators()->texture_compare_mode.IsValid(param)) {
1019 return GL_INVALID_ENUM; 1034 return GL_INVALID_ENUM;
1020 } 1035 }
1021 compare_mode_ = param; 1036 sampler_state_.compare_mode = param;
1022 break; 1037 break;
1023 case GL_TEXTURE_BASE_LEVEL: 1038 case GL_TEXTURE_BASE_LEVEL:
1024 if (param < 0) { 1039 if (param < 0) {
1025 return GL_INVALID_VALUE; 1040 return GL_INVALID_VALUE;
1026 } 1041 }
1027 UpdateBaseLevel(param); 1042 UpdateBaseLevel(param);
1028 break; 1043 break;
1029 case GL_TEXTURE_MAX_LEVEL: 1044 case GL_TEXTURE_MAX_LEVEL:
1030 if (param < 0) { 1045 if (param < 0) {
1031 return GL_INVALID_VALUE; 1046 return GL_INVALID_VALUE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 case GL_TEXTURE_COMPARE_FUNC: 1079 case GL_TEXTURE_COMPARE_FUNC:
1065 case GL_TEXTURE_COMPARE_MODE: 1080 case GL_TEXTURE_COMPARE_MODE:
1066 case GL_TEXTURE_BASE_LEVEL: 1081 case GL_TEXTURE_BASE_LEVEL:
1067 case GL_TEXTURE_MAX_LEVEL: 1082 case GL_TEXTURE_MAX_LEVEL:
1068 case GL_TEXTURE_USAGE_ANGLE: 1083 case GL_TEXTURE_USAGE_ANGLE:
1069 { 1084 {
1070 GLint iparam = static_cast<GLint>(param); 1085 GLint iparam = static_cast<GLint>(param);
1071 return SetParameteri(feature_info, pname, iparam); 1086 return SetParameteri(feature_info, pname, iparam);
1072 } 1087 }
1073 case GL_TEXTURE_MIN_LOD: 1088 case GL_TEXTURE_MIN_LOD:
1074 min_lod_ = param; 1089 sampler_state_.min_lod = param;
1075 break; 1090 break;
1076 case GL_TEXTURE_MAX_LOD: 1091 case GL_TEXTURE_MAX_LOD:
1077 max_lod_ = param; 1092 sampler_state_.max_lod = param;
1078 break; 1093 break;
1079 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 1094 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
1080 if (param < 1.f) { 1095 if (param < 1.f) {
1081 return GL_INVALID_VALUE; 1096 return GL_INVALID_VALUE;
1082 } 1097 }
1083 break; 1098 break;
1084 default: 1099 default:
1085 NOTREACHED(); 1100 NOTREACHED();
1086 return GL_INVALID_ENUM; 1101 return GL_INVALID_ENUM;
1087 } 1102 }
(...skipping 17 matching lines...) Expand all
1105 const Texture::LevelInfo& first_level = first_face.level_infos[base_level_]; 1120 const Texture::LevelInfo& first_level = first_face.level_infos[base_level_];
1106 const GLsizei levels_needed = first_face.num_mip_levels; 1121 const GLsizei levels_needed = first_face.num_mip_levels;
1107 1122
1108 texture_complete_ = 1123 texture_complete_ =
1109 max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0; 1124 max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0;
1110 cube_complete_ = (face_infos_.size() == 6) && 1125 cube_complete_ = (face_infos_.size() == 6) &&
1111 (first_level.width == first_level.height); 1126 (first_level.width == first_level.height);
1112 1127
1113 if (first_level.width == 0 || first_level.height == 0) { 1128 if (first_level.width == 0 || first_level.height == 0) {
1114 texture_complete_ = false; 1129 texture_complete_ = false;
1115 } else if (first_level.type == GL_FLOAT && 1130 } else if (!is_es3_enabled_) {
Zhenyao Mo 2015/12/11 20:18:54 Shouldn't we still check the following in ES3?
1116 !feature_info->feature_flags().enable_texture_float_linear && 1131 if (first_level.type == GL_FLOAT &&
1117 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || 1132 !feature_info->feature_flags().enable_texture_float_linear &&
1118 mag_filter_ != GL_NEAREST)) { 1133 (sampler_state_.min_filter != GL_NEAREST_MIPMAP_NEAREST ||
1119 texture_complete_ = false; 1134 sampler_state_.mag_filter != GL_NEAREST)) {
1120 } else if (first_level.type == GL_HALF_FLOAT_OES && 1135 texture_complete_ = false;
1121 !feature_info->feature_flags().enable_texture_half_float_linear && 1136 } else if (first_level.type == GL_HALF_FLOAT_OES &&
1122 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || 1137 !feature_info->feature_flags().enable_texture_half_float_linear &&
1123 mag_filter_ != GL_NEAREST)) { 1138 (sampler_state_.min_filter != GL_NEAREST_MIPMAP_NEAREST ||
1124 texture_complete_ = false; 1139 sampler_state_.mag_filter != GL_NEAREST)) {
1140 texture_complete_ = false;
1141 }
1125 } 1142 }
1126 1143
1127 bool texture_level0_complete = true; 1144 bool texture_level0_complete = true;
1128 if (cube_complete_ && texture_level0_dirty_) { 1145 if (cube_complete_ && texture_level0_dirty_) {
1129 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { 1146 for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
1130 const Texture::LevelInfo& face_base_level = 1147 const Texture::LevelInfo& face_base_level =
1131 face_infos_[ii].level_infos[base_level_]; 1148 face_infos_[ii].level_infos[base_level_];
1132 if (!TextureFaceComplete(first_level, 1149 if (!TextureFaceComplete(first_level,
1133 ii, 1150 ii,
1134 face_base_level.target, 1151 face_base_level.target,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 num_observers_(0) { 1389 num_observers_(0) {
1373 DCHECK(manager_); 1390 DCHECK(manager_);
1374 DCHECK(texture_); 1391 DCHECK(texture_);
1375 texture_->AddTextureRef(this); 1392 texture_->AddTextureRef(this);
1376 manager_->StartTracking(this); 1393 manager_->StartTracking(this);
1377 } 1394 }
1378 1395
1379 scoped_refptr<TextureRef> TextureRef::Create(TextureManager* manager, 1396 scoped_refptr<TextureRef> TextureRef::Create(TextureManager* manager,
1380 GLuint client_id, 1397 GLuint client_id,
1381 GLuint service_id) { 1398 GLuint service_id) {
1382 return new TextureRef(manager, client_id, new Texture(service_id)); 1399 return new TextureRef(manager, client_id, new Texture(service_id,
1400 manager->feature_info_->IsES3Enabled()));
1383 } 1401 }
1384 1402
1385 TextureRef::~TextureRef() { 1403 TextureRef::~TextureRef() {
1386 manager_->StopTracking(this); 1404 manager_->StopTracking(this);
1387 texture_->RemoveTextureRef(this, manager_->have_context_); 1405 texture_->RemoveTextureRef(this, manager_->have_context_);
1388 manager_ = NULL; 1406 manager_ = NULL;
1389 } 1407 }
1390 1408
1391 TextureManager::TextureManager(MemoryTracker* memory_tracker, 1409 TextureManager::TextureManager(MemoryTracker* memory_tracker,
1392 FeatureInfo* feature_info, 1410 FeatureInfo* feature_info,
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 textures_.erase(it); 1716 textures_.erase(it);
1699 } 1717 }
1700 } 1718 }
1701 1719
1702 void TextureManager::StartTracking(TextureRef* ref) { 1720 void TextureManager::StartTracking(TextureRef* ref) {
1703 Texture* texture = ref->texture(); 1721 Texture* texture = ref->texture();
1704 ++texture_count_; 1722 ++texture_count_;
1705 num_uncleared_mips_ += texture->num_uncleared_mips(); 1723 num_uncleared_mips_ += texture->num_uncleared_mips();
1706 if (!texture->SafeToRenderFrom()) 1724 if (!texture->SafeToRenderFrom())
1707 ++num_unsafe_textures_; 1725 ++num_unsafe_textures_;
1708 if (!texture->CanRender(feature_info_.get())) 1726 if (!feature_info_->IsES3Enabled() &&
1727 !texture->CanRender(feature_info_.get()))
1709 ++num_unrenderable_textures_; 1728 ++num_unrenderable_textures_;
1710 if (texture->HasImages()) 1729 if (texture->HasImages())
1711 ++num_images_; 1730 ++num_images_;
1712 } 1731 }
1713 1732
1714 void TextureManager::StopTracking(TextureRef* ref) { 1733 void TextureManager::StopTracking(TextureRef* ref) {
1715 if (ref->num_observers()) { 1734 if (ref->num_observers()) {
1716 for (unsigned int i = 0; i < destruction_observers_.size(); i++) { 1735 for (unsigned int i = 0; i < destruction_observers_.size(); i++) {
1717 destruction_observers_[i]->OnTextureRefDestroying(ref); 1736 destruction_observers_[i]->OnTextureRefDestroying(ref);
1718 } 1737 }
1719 DCHECK_EQ(ref->num_observers(), 0); 1738 DCHECK_EQ(ref->num_observers(), 0);
1720 } 1739 }
1721 1740
1722 Texture* texture = ref->texture(); 1741 Texture* texture = ref->texture();
1723 1742
1724 --texture_count_; 1743 --texture_count_;
1725 if (texture->HasImages()) { 1744 if (texture->HasImages()) {
1726 DCHECK_NE(0, num_images_); 1745 DCHECK_NE(0, num_images_);
1727 --num_images_; 1746 --num_images_;
1728 } 1747 }
1729 if (!texture->CanRender(feature_info_.get())) { 1748 if (!feature_info_->IsES3Enabled() &&
1749 !texture->CanRender(feature_info_.get())) {
1730 DCHECK_NE(0, num_unrenderable_textures_); 1750 DCHECK_NE(0, num_unrenderable_textures_);
1731 --num_unrenderable_textures_; 1751 --num_unrenderable_textures_;
1732 } 1752 }
1733 if (!texture->SafeToRenderFrom()) { 1753 if (!texture->SafeToRenderFrom()) {
1734 DCHECK_NE(0, num_unsafe_textures_); 1754 DCHECK_NE(0, num_unsafe_textures_);
1735 --num_unsafe_textures_; 1755 --num_unsafe_textures_;
1736 } 1756 }
1737 num_uncleared_mips_ -= texture->num_uncleared_mips(); 1757 num_uncleared_mips_ -= texture->num_uncleared_mips();
1738 DCHECK_GE(num_uncleared_mips_, 0); 1758 DCHECK_GE(num_uncleared_mips_, 0);
1739 } 1759 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 } 1813 }
1794 1814
1795 void TextureManager::UpdateUnclearedMips(int delta) { 1815 void TextureManager::UpdateUnclearedMips(int delta) {
1796 num_uncleared_mips_ += delta; 1816 num_uncleared_mips_ += delta;
1797 DCHECK_GE(num_uncleared_mips_, 0); 1817 DCHECK_GE(num_uncleared_mips_, 0);
1798 } 1818 }
1799 1819
1800 void TextureManager::UpdateCanRenderCondition( 1820 void TextureManager::UpdateCanRenderCondition(
1801 Texture::CanRenderCondition old_condition, 1821 Texture::CanRenderCondition old_condition,
1802 Texture::CanRenderCondition new_condition) { 1822 Texture::CanRenderCondition new_condition) {
1823 if (feature_info_->IsES3Enabled())
1824 return;
1803 if (old_condition == Texture::CAN_RENDER_NEVER || 1825 if (old_condition == Texture::CAN_RENDER_NEVER ||
1804 (old_condition == Texture::CAN_RENDER_ONLY_IF_NPOT && 1826 (old_condition == Texture::CAN_RENDER_ONLY_IF_NPOT &&
1805 !feature_info_->feature_flags().npot_ok)) { 1827 !feature_info_->feature_flags().npot_ok)) {
1806 DCHECK_GT(num_unrenderable_textures_, 0); 1828 DCHECK_GT(num_unrenderable_textures_, 0);
1807 --num_unrenderable_textures_; 1829 --num_unrenderable_textures_;
1808 } 1830 }
1809 if (new_condition == Texture::CAN_RENDER_NEVER || 1831 if (new_condition == Texture::CAN_RENDER_NEVER ||
1810 (new_condition == Texture::CAN_RENDER_ONLY_IF_NPOT && 1832 (new_condition == Texture::CAN_RENDER_ONLY_IF_NPOT &&
1811 !feature_info_->feature_flags().npot_ok)) 1833 !feature_info_->feature_flags().npot_ok))
1812 ++num_unrenderable_textures_; 1834 ++num_unrenderable_textures_;
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 return GL_HALF_FLOAT_OES; 2633 return GL_HALF_FLOAT_OES;
2612 case GL_BGRA8_EXT: 2634 case GL_BGRA8_EXT:
2613 return GL_UNSIGNED_BYTE; 2635 return GL_UNSIGNED_BYTE;
2614 default: 2636 default:
2615 return GL_NONE; 2637 return GL_NONE;
2616 } 2638 }
2617 } 2639 }
2618 2640
2619 } // namespace gles2 2641 } // namespace gles2
2620 } // namespace gpu 2642 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698