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

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

Issue 1870483003: Add command buffer support for GL_RGB CHROMIUM image emulation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing braces. Created 4 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 GLfloat min_lod_; 58 GLfloat min_lod_;
59 GLint base_level_; 59 GLint base_level_;
60 GLint border_; 60 GLint border_;
61 GLint max_level_; 61 GLint max_level_;
62 GLenum format_; 62 GLenum format_;
63 GLenum type_; 63 GLenum type_;
64 bool has_image_; 64 bool has_image_;
65 bool can_render_; 65 bool can_render_;
66 bool can_render_to_; 66 bool can_render_to_;
67 bool npot_; 67 bool npot_;
68 bool emulating_rgb_;
68 69
69 // Since we will be hashing this signature structure, the padding must be 70 // Since we will be hashing this signature structure, the padding must be
70 // zero initialized. Although the C++11 specifications specify that this is 71 // zero initialized. Although the C++11 specifications specify that this is
71 // true, we will use a constructor with a memset to further enforce it instead 72 // true, we will use a constructor with a memset to further enforce it instead
72 // of relying on compilers adhering to this deep dark corner specification. 73 // of relying on compilers adhering to this deep dark corner specification.
73 TextureSignature(GLenum target, 74 TextureSignature(GLenum target,
74 GLint level, 75 GLint level,
75 const SamplerState& sampler_state, 76 const SamplerState& sampler_state,
76 GLenum usage, 77 GLenum usage,
77 GLenum internal_format, 78 GLenum internal_format,
78 GLsizei width, 79 GLsizei width,
79 GLsizei height, 80 GLsizei height,
80 GLsizei depth, 81 GLsizei depth,
81 GLint base_level, 82 GLint base_level,
82 GLint border, 83 GLint border,
83 GLint max_level, 84 GLint max_level,
84 GLenum format, 85 GLenum format,
85 GLenum type, 86 GLenum type,
86 bool has_image, 87 bool has_image,
87 bool can_render, 88 bool can_render,
88 bool can_render_to, 89 bool can_render_to,
89 bool npot) { 90 bool npot,
91 bool emulating_rgb) {
90 memset(this, 0, sizeof(TextureSignature)); 92 memset(this, 0, sizeof(TextureSignature));
91 target_ = target; 93 target_ = target;
92 level_ = level; 94 level_ = level;
93 min_filter_ = sampler_state.min_filter; 95 min_filter_ = sampler_state.min_filter;
94 mag_filter_ = sampler_state.mag_filter; 96 mag_filter_ = sampler_state.mag_filter;
95 wrap_r_ = sampler_state.wrap_r; 97 wrap_r_ = sampler_state.wrap_r;
96 wrap_s_ = sampler_state.wrap_s; 98 wrap_s_ = sampler_state.wrap_s;
97 wrap_t_ = sampler_state.wrap_t; 99 wrap_t_ = sampler_state.wrap_t;
98 usage_ = usage; 100 usage_ = usage;
99 internal_format_ = internal_format; 101 internal_format_ = internal_format;
100 compare_func_ = sampler_state.compare_func; 102 compare_func_ = sampler_state.compare_func;
101 compare_mode_ = sampler_state.compare_mode; 103 compare_mode_ = sampler_state.compare_mode;
102 width_ = width; 104 width_ = width;
103 height_ = height; 105 height_ = height;
104 depth_ = depth; 106 depth_ = depth;
105 max_lod_ = sampler_state.max_lod; 107 max_lod_ = sampler_state.max_lod;
106 min_lod_ = sampler_state.min_lod; 108 min_lod_ = sampler_state.min_lod;
107 base_level_ = base_level; 109 base_level_ = base_level;
108 border_ = border; 110 border_ = border;
109 max_level_ = max_level; 111 max_level_ = max_level;
110 format_ = format; 112 format_ = format;
111 type_ = type; 113 type_ = type;
112 has_image_ = has_image; 114 has_image_ = has_image;
113 can_render_ = can_render; 115 can_render_ = can_render;
114 can_render_to_ = can_render_to; 116 can_render_to_ = can_render_to;
115 npot_ = npot; 117 npot_ = npot;
118 emulating_rgb_ = emulating_rgb;
116 } 119 }
117 }; 120 };
118 121
119 class FormatTypeValidator { 122 class FormatTypeValidator {
120 public: 123 public:
121 FormatTypeValidator() { 124 FormatTypeValidator() {
122 static const FormatType kSupportedFormatTypes[] = { 125 static const FormatType kSupportedFormatTypes[] = {
123 // ES2. 126 // ES2.
124 { GL_RGB, GL_RGB, GL_UNSIGNED_BYTE }, 127 { GL_RGB, GL_RGB, GL_UNSIGNED_BYTE },
125 { GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 }, 128 { GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 },
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 texture_mips_dirty_(false), 372 texture_mips_dirty_(false),
370 cube_complete_(false), 373 cube_complete_(false),
371 npot_(false), 374 npot_(false),
372 has_been_bound_(false), 375 has_been_bound_(false),
373 framebuffer_attachment_count_(0), 376 framebuffer_attachment_count_(0),
374 immutable_(false), 377 immutable_(false),
375 has_images_(false), 378 has_images_(false),
376 estimated_size_(0), 379 estimated_size_(0),
377 can_render_condition_(CAN_RENDER_ALWAYS), 380 can_render_condition_(CAN_RENDER_ALWAYS),
378 texture_max_anisotropy_initialized_(false), 381 texture_max_anisotropy_initialized_(false),
379 compatibility_swizzle_(nullptr) {} 382 compatibility_swizzle_(nullptr),
383 emulating_rgb_(false) {}
380 384
381 Texture::~Texture() { 385 Texture::~Texture() {
382 if (mailbox_manager_) 386 if (mailbox_manager_)
383 mailbox_manager_->TextureDeleted(this); 387 mailbox_manager_->TextureDeleted(this);
384 } 388 }
385 389
386 void Texture::AddTextureRef(TextureRef* ref) { 390 void Texture::AddTextureRef(TextureRef* ref) {
387 DCHECK(refs_.find(ref) == refs_.end()); 391 DCHECK(refs_.find(ref) == refs_.end());
388 refs_.insert(ref); 392 refs_.insert(ref);
389 if (!memory_tracking_ref_) { 393 if (!memory_tracking_ref_) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 info.height, 584 info.height,
581 info.depth, 585 info.depth,
582 base_level_, 586 base_level_,
583 info.border, 587 info.border,
584 max_level_, 588 max_level_,
585 info.format, 589 info.format,
586 info.type, 590 info.type,
587 info.image.get() != NULL, 591 info.image.get() != NULL,
588 CanRender(feature_info), 592 CanRender(feature_info),
589 CanRenderTo(feature_info, level), 593 CanRenderTo(feature_info, level),
590 npot_); 594 npot_,
595 emulating_rgb_);
591 596
592 signature->append(TextureTag, sizeof(TextureTag)); 597 signature->append(TextureTag, sizeof(TextureTag));
593 signature->append(reinterpret_cast<const char*>(&signature_data), 598 signature->append(reinterpret_cast<const char*>(&signature_data),
594 sizeof(signature_data)); 599 sizeof(signature_data));
595 } 600 }
596 601
597 void Texture::SetMailboxManager(MailboxManager* mailbox_manager) { 602 void Texture::SetMailboxManager(MailboxManager* mailbox_manager) {
598 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager); 603 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager);
599 mailbox_manager_ = mailbox_manager; 604 mailbox_manager_ = mailbox_manager;
600 } 605 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 } 864 }
860 865
861 if (has_images_ == has_images) 866 if (has_images_ == has_images)
862 return; 867 return;
863 has_images_ = has_images; 868 has_images_ = has_images;
864 int delta = has_images ? +1 : -1; 869 int delta = has_images ? +1 : -1;
865 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) 870 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it)
866 (*it)->manager()->UpdateNumImages(delta); 871 (*it)->manager()->UpdateNumImages(delta);
867 } 872 }
868 873
874 void Texture::UpdateEmulatingRGB() {
875 for (const FaceInfo& face_info : face_infos_) {
876 for (const LevelInfo& level_info : face_info.level_infos) {
877 if (level_info.image && level_info.image->EmulatingRGB()) {
878 emulating_rgb_ = true;
879 return;
880 }
881 }
882 }
883 emulating_rgb_ = false;
884 }
885
886
869 void Texture::IncAllFramebufferStateChangeCount() { 887 void Texture::IncAllFramebufferStateChangeCount() {
870 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) 888 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it)
871 (*it)->manager()->IncFramebufferStateChangeCount(); 889 (*it)->manager()->IncFramebufferStateChangeCount();
872 } 890 }
873 891
874 void Texture::UpdateBaseLevel(GLint base_level) { 892 void Texture::UpdateBaseLevel(GLint base_level) {
875 if (base_level_ == base_level) 893 if (base_level_ == base_level)
876 return; 894 return;
877 base_level_ = base_level; 895 base_level_ = base_level;
878 896
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 Texture::LevelInfo& info = 1456 Texture::LevelInfo& info =
1439 face_infos_[face_index].level_infos[level]; 1457 face_infos_[face_index].level_infos[level];
1440 DCHECK_EQ(info.target, target); 1458 DCHECK_EQ(info.target, target);
1441 DCHECK_EQ(info.level, level); 1459 DCHECK_EQ(info.level, level);
1442 info.image = image; 1460 info.image = image;
1443 info.stream_texture_image = stream_texture_image; 1461 info.stream_texture_image = stream_texture_image;
1444 info.image_state = state; 1462 info.image_state = state;
1445 1463
1446 UpdateCanRenderCondition(); 1464 UpdateCanRenderCondition();
1447 UpdateHasImages(); 1465 UpdateHasImages();
1466 UpdateEmulatingRGB();
1448 } 1467 }
1449 1468
1450 void Texture::SetLevelImage(GLenum target, 1469 void Texture::SetLevelImage(GLenum target,
1451 GLint level, 1470 GLint level,
1452 gl::GLImage* image, 1471 gl::GLImage* image,
1453 ImageState state) { 1472 ImageState state) {
1454 SetLevelImageInternal(target, level, image, nullptr, state); 1473 SetLevelImageInternal(target, level, image, nullptr, state);
1455 } 1474 }
1456 1475
1457 void Texture::SetLevelStreamTextureImage(GLenum target, 1476 void Texture::SetLevelStreamTextureImage(GLenum target,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 1633
1615 void Texture::ApplyFormatWorkarounds(FeatureInfo* feature_info) { 1634 void Texture::ApplyFormatWorkarounds(FeatureInfo* feature_info) {
1616 if (feature_info->gl_version_info().is_desktop_core_profile) { 1635 if (feature_info->gl_version_info().is_desktop_core_profile) {
1617 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) 1636 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size())
1618 return; 1637 return;
1619 const Texture::LevelInfo& info = face_infos_[0].level_infos[base_level_]; 1638 const Texture::LevelInfo& info = face_infos_[0].level_infos[base_level_];
1620 SetCompatibilitySwizzle(GetCompatibilitySwizzle(info.format)); 1639 SetCompatibilitySwizzle(GetCompatibilitySwizzle(info.format));
1621 } 1640 }
1622 } 1641 }
1623 1642
1643 bool Texture::EmulatingRGB() {
1644 return emulating_rgb_;
1645 }
1646
1624 TextureRef::TextureRef(TextureManager* manager, 1647 TextureRef::TextureRef(TextureManager* manager,
1625 GLuint client_id, 1648 GLuint client_id,
1626 Texture* texture) 1649 Texture* texture)
1627 : manager_(manager), 1650 : manager_(manager),
1628 texture_(texture), 1651 texture_(texture),
1629 client_id_(client_id), 1652 client_id_(client_id),
1630 num_observers_(0) { 1653 num_observers_(0) {
1631 DCHECK(manager_); 1654 DCHECK(manager_);
1632 DCHECK(texture_); 1655 DCHECK(texture_);
1633 texture_->AddTextureRef(this); 1656 texture_->AddTextureRef(this);
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 uint32_t TextureManager::GetServiceIdGeneration() const { 3157 uint32_t TextureManager::GetServiceIdGeneration() const {
3135 return current_service_id_generation_; 3158 return current_service_id_generation_;
3136 } 3159 }
3137 3160
3138 void TextureManager::IncrementServiceIdGeneration() { 3161 void TextureManager::IncrementServiceIdGeneration() {
3139 current_service_id_generation_++; 3162 current_service_id_generation_++;
3140 } 3163 }
3141 3164
3142 } // namespace gles2 3165 } // namespace gles2
3143 } // namespace gpu 3166 } // 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