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

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

Issue 1133033002: Update GetTexParameter* and TexParameter* for ES3 in GPU command buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use previous macro Created 5 years, 7 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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bits.h" 10 #include "base/bits.h"
(...skipping 11 matching lines...) Expand all
22 namespace gpu { 22 namespace gpu {
23 namespace gles2 { 23 namespace gles2 {
24 24
25 // This should contain everything to uniquely identify a Texture. 25 // This should contain everything to uniquely identify a Texture.
26 static const char TextureTag[] = "|Texture|"; 26 static const char TextureTag[] = "|Texture|";
27 struct TextureSignature { 27 struct TextureSignature {
28 GLenum target_; 28 GLenum target_;
29 GLint level_; 29 GLint level_;
30 GLenum min_filter_; 30 GLenum min_filter_;
31 GLenum mag_filter_; 31 GLenum mag_filter_;
32 GLenum wrap_r_;
32 GLenum wrap_s_; 33 GLenum wrap_s_;
33 GLenum wrap_t_; 34 GLenum wrap_t_;
34 GLenum usage_; 35 GLenum usage_;
35 GLenum internal_format_; 36 GLenum internal_format_;
37 GLenum compare_func_;
38 GLenum compare_mode_;
36 GLsizei width_; 39 GLsizei width_;
37 GLsizei height_; 40 GLsizei height_;
38 GLsizei depth_; 41 GLsizei depth_;
42 GLfloat max_lod_;
43 GLfloat min_lod_;
44 GLint base_level_;
39 GLint border_; 45 GLint border_;
46 GLint max_level_;
40 GLenum format_; 47 GLenum format_;
41 GLenum type_; 48 GLenum type_;
42 bool has_image_; 49 bool has_image_;
43 bool can_render_; 50 bool can_render_;
44 bool can_render_to_; 51 bool can_render_to_;
45 bool npot_; 52 bool npot_;
46 53
47 // Since we will be hashing this signature structure, the padding must be 54 // Since we will be hashing this signature structure, the padding must be
48 // zero initialized. Although the C++11 specifications specify that this is 55 // zero initialized. Although the C++11 specifications specify that this is
49 // true, we will use a constructor with a memset to further enforce it instead 56 // true, we will use a constructor with a memset to further enforce it instead
50 // of relying on compilers adhering to this deep dark corner specification. 57 // of relying on compilers adhering to this deep dark corner specification.
51 TextureSignature(GLenum target, 58 TextureSignature(GLenum target,
52 GLint level, 59 GLint level,
53 GLenum min_filter, 60 GLenum min_filter,
54 GLenum mag_filter, 61 GLenum mag_filter,
62 GLenum wrap_r,
55 GLenum wrap_s, 63 GLenum wrap_s,
56 GLenum wrap_t, 64 GLenum wrap_t,
57 GLenum usage, 65 GLenum usage,
58 GLenum internal_format, 66 GLenum internal_format,
67 GLenum compare_func,
68 GLenum compare_mode,
59 GLsizei width, 69 GLsizei width,
60 GLsizei height, 70 GLsizei height,
61 GLsizei depth, 71 GLsizei depth,
72 GLfloat max_lod,
73 GLfloat min_lod,
74 GLint base_level,
62 GLint border, 75 GLint border,
76 GLint max_level,
63 GLenum format, 77 GLenum format,
64 GLenum type, 78 GLenum type,
65 bool has_image, 79 bool has_image,
66 bool can_render, 80 bool can_render,
67 bool can_render_to, 81 bool can_render_to,
68 bool npot) { 82 bool npot) {
69 memset(this, 0, sizeof(TextureSignature)); 83 memset(this, 0, sizeof(TextureSignature));
70 target_ = target; 84 target_ = target;
71 level_ = level; 85 level_ = level;
72 min_filter_ = min_filter; 86 min_filter_ = min_filter;
73 mag_filter_ = mag_filter; 87 mag_filter_ = mag_filter;
88 wrap_r_ = wrap_r;
74 wrap_s_ = wrap_s; 89 wrap_s_ = wrap_s;
75 wrap_t_ = wrap_t; 90 wrap_t_ = wrap_t;
76 usage_ = usage; 91 usage_ = usage;
77 internal_format_ = internal_format; 92 internal_format_ = internal_format;
93 compare_func_ = compare_func;
94 compare_mode_ = compare_mode;
78 width_ = width; 95 width_ = width;
79 height_ = height; 96 height_ = height;
80 depth_ = depth; 97 depth_ = depth;
98 max_lod_ = max_lod;
99 min_lod_ = min_lod;
100 base_level_ = base_level;
81 border_ = border; 101 border_ = border;
102 max_level_ = max_level;
82 format_ = format; 103 format_ = format;
83 type_ = type; 104 type_ = type;
84 has_image_ = has_image; 105 has_image_ = has_image;
85 can_render_ = can_render; 106 can_render_ = can_render;
86 can_render_to_ = can_render_to; 107 can_render_to_ = can_render_to;
87 npot_ = npot; 108 npot_ = npot;
88 } 109 }
89 }; 110 };
90 111
91 TextureManager::DestructionObserver::DestructionObserver() {} 112 TextureManager::DestructionObserver::DestructionObserver() {}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 Texture::Texture(GLuint service_id) 147 Texture::Texture(GLuint service_id)
127 : mailbox_manager_(NULL), 148 : mailbox_manager_(NULL),
128 memory_tracking_ref_(NULL), 149 memory_tracking_ref_(NULL),
129 service_id_(service_id), 150 service_id_(service_id),
130 cleared_(true), 151 cleared_(true),
131 num_uncleared_mips_(0), 152 num_uncleared_mips_(0),
132 num_npot_faces_(0), 153 num_npot_faces_(0),
133 target_(0), 154 target_(0),
134 min_filter_(GL_NEAREST_MIPMAP_LINEAR), 155 min_filter_(GL_NEAREST_MIPMAP_LINEAR),
135 mag_filter_(GL_LINEAR), 156 mag_filter_(GL_LINEAR),
157 wrap_r_(GL_REPEAT),
136 wrap_s_(GL_REPEAT), 158 wrap_s_(GL_REPEAT),
137 wrap_t_(GL_REPEAT), 159 wrap_t_(GL_REPEAT),
138 usage_(GL_NONE), 160 usage_(GL_NONE),
139 pool_(GL_TEXTURE_POOL_UNMANAGED_CHROMIUM), 161 pool_(GL_TEXTURE_POOL_UNMANAGED_CHROMIUM),
162 compare_func_(GL_LEQUAL),
163 compare_mode_(GL_NONE),
164 max_lod_(1000.0f),
165 min_lod_(-1000.0f),
166 base_level_(0),
167 max_level_(1000),
140 max_level_set_(-1), 168 max_level_set_(-1),
141 texture_complete_(false), 169 texture_complete_(false),
142 texture_mips_dirty_(false), 170 texture_mips_dirty_(false),
143 texture_mips_complete_(false), 171 texture_mips_complete_(false),
144 cube_complete_(false), 172 cube_complete_(false),
145 texture_level0_dirty_(false), 173 texture_level0_dirty_(false),
146 texture_level0_complete_(false), 174 texture_level0_complete_(false),
147 npot_(false), 175 npot_(false),
148 has_been_bound_(false), 176 has_been_bound_(false),
149 framebuffer_attachment_count_(0), 177 framebuffer_attachment_count_(0),
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 DCHECK_LT(static_cast<size_t>(level), 326 DCHECK_LT(static_cast<size_t>(level),
299 face_infos_[face_index].level_infos.size()); 327 face_infos_[face_index].level_infos.size());
300 328
301 const Texture::LevelInfo& info = 329 const Texture::LevelInfo& info =
302 face_infos_[face_index].level_infos[level]; 330 face_infos_[face_index].level_infos[level];
303 331
304 TextureSignature signature_data(target, 332 TextureSignature signature_data(target,
305 level, 333 level,
306 min_filter_, 334 min_filter_,
307 mag_filter_, 335 mag_filter_,
336 wrap_r_,
308 wrap_s_, 337 wrap_s_,
309 wrap_t_, 338 wrap_t_,
310 usage_, 339 usage_,
311 info.internal_format, 340 info.internal_format,
341 compare_func_,
342 compare_mode_,
312 info.width, 343 info.width,
313 info.height, 344 info.height,
314 info.depth, 345 info.depth,
346 max_lod_,
347 min_lod_,
348 base_level_,
315 info.border, 349 info.border,
350 max_level_,
316 info.format, 351 info.format,
317 info.type, 352 info.type,
318 info.image.get() != NULL, 353 info.image.get() != NULL,
319 CanRender(feature_info), 354 CanRender(feature_info),
320 CanRenderTo(), 355 CanRenderTo(),
321 npot_); 356 npot_);
322 357
323 signature->append(TextureTag, sizeof(TextureTag)); 358 signature->append(TextureTag, sizeof(TextureTag));
324 signature->append(reinterpret_cast<const char*>(&signature_data), 359 signature->append(reinterpret_cast<const char*>(&signature_data),
325 sizeof(signature_data)); 360 sizeof(signature_data));
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 mag_filter_ = param; 773 mag_filter_ = param;
739 break; 774 break;
740 case GL_TEXTURE_POOL_CHROMIUM: 775 case GL_TEXTURE_POOL_CHROMIUM:
741 if (!feature_info->validators()->texture_pool.IsValid(param)) { 776 if (!feature_info->validators()->texture_pool.IsValid(param)) {
742 return GL_INVALID_ENUM; 777 return GL_INVALID_ENUM;
743 } 778 }
744 GetMemTracker()->TrackMemFree(estimated_size()); 779 GetMemTracker()->TrackMemFree(estimated_size());
745 pool_ = param; 780 pool_ = param;
746 GetMemTracker()->TrackMemAlloc(estimated_size()); 781 GetMemTracker()->TrackMemAlloc(estimated_size());
747 break; 782 break;
783 case GL_TEXTURE_WRAP_R:
784 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) {
785 return GL_INVALID_ENUM;
786 }
787 wrap_r_ = param;
788 break;
748 case GL_TEXTURE_WRAP_S: 789 case GL_TEXTURE_WRAP_S:
749 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { 790 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) {
750 return GL_INVALID_ENUM; 791 return GL_INVALID_ENUM;
751 } 792 }
752 wrap_s_ = param; 793 wrap_s_ = param;
753 break; 794 break;
754 case GL_TEXTURE_WRAP_T: 795 case GL_TEXTURE_WRAP_T:
755 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { 796 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) {
756 return GL_INVALID_ENUM; 797 return GL_INVALID_ENUM;
757 } 798 }
758 wrap_t_ = param; 799 wrap_t_ = param;
759 break; 800 break;
801 case GL_TEXTURE_COMPARE_FUNC:
802 if (!feature_info->validators()->texture_compare_func.IsValid(param)) {
803 return GL_INVALID_ENUM;
804 }
805 compare_func_ = param;
806 break;
807 case GL_TEXTURE_COMPARE_MODE:
808 if (!feature_info->validators()->texture_compare_mode.IsValid(param)) {
809 return GL_INVALID_ENUM;
810 }
811 compare_mode_ = param;
812 break;
813 case GL_TEXTURE_BASE_LEVEL:
814 if (param < 0) {
815 return GL_INVALID_VALUE;
816 }
817 base_level_ = param;
818 break;
819 case GL_TEXTURE_MAX_LEVEL:
820 if (param < 0) {
821 return GL_INVALID_VALUE;
822 }
823 max_level_ = param;
824 break;
760 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 825 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
761 if (param < 1) { 826 if (param < 1) {
762 return GL_INVALID_VALUE; 827 return GL_INVALID_VALUE;
763 } 828 }
764 break; 829 break;
765 case GL_TEXTURE_USAGE_ANGLE: 830 case GL_TEXTURE_USAGE_ANGLE:
766 if (!feature_info->validators()->texture_usage.IsValid(param)) { 831 if (!feature_info->validators()->texture_usage.IsValid(param)) {
767 return GL_INVALID_ENUM; 832 return GL_INVALID_ENUM;
768 } 833 }
769 usage_ = param; 834 usage_ = param;
(...skipping 14 matching lines...) Expand all
784 case GL_TEXTURE_MIN_FILTER: 849 case GL_TEXTURE_MIN_FILTER:
785 case GL_TEXTURE_MAG_FILTER: 850 case GL_TEXTURE_MAG_FILTER:
786 case GL_TEXTURE_POOL_CHROMIUM: 851 case GL_TEXTURE_POOL_CHROMIUM:
787 case GL_TEXTURE_WRAP_S: 852 case GL_TEXTURE_WRAP_S:
788 case GL_TEXTURE_WRAP_T: 853 case GL_TEXTURE_WRAP_T:
789 case GL_TEXTURE_USAGE_ANGLE: 854 case GL_TEXTURE_USAGE_ANGLE:
790 { 855 {
791 GLint iparam = static_cast<GLint>(param); 856 GLint iparam = static_cast<GLint>(param);
792 return SetParameteri(feature_info, pname, iparam); 857 return SetParameteri(feature_info, pname, iparam);
793 } 858 }
859 case GL_TEXTURE_MIN_LOD:
860 min_lod_ = param;
861 break;
862 case GL_TEXTURE_MAX_LOD:
863 max_lod_ = param;
864 break;
794 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 865 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
795 if (param < 1.f) { 866 if (param < 1.f) {
796 return GL_INVALID_VALUE; 867 return GL_INVALID_VALUE;
797 } 868 }
798 break; 869 break;
799 default: 870 default:
800 NOTREACHED(); 871 NOTREACHED();
801 return GL_INVALID_ENUM; 872 return GL_INVALID_ENUM;
802 } 873 }
803 return GL_NO_ERROR; 874 return GL_NO_ERROR;
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 } 1816 }
1746 1817
1747 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { 1818 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() {
1748 texture_state_->texture_upload_count++; 1819 texture_state_->texture_upload_count++;
1749 texture_state_->total_texture_upload_time += 1820 texture_state_->total_texture_upload_time +=
1750 base::TimeTicks::Now() - begin_time_; 1821 base::TimeTicks::Now() - begin_time_;
1751 } 1822 }
1752 1823
1753 } // namespace gles2 1824 } // namespace gles2
1754 } // namespace gpu 1825 } // namespace gpu
OLDNEW
« gpu/blink/webgraphicscontext3d_impl.cc ('K') | « gpu/command_buffer/service/texture_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698