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

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

Issue 1630263002: Revert of Updating texture validation to account for sampler objects in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <list> 12 #include <list>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "gpu/command_buffer/service/feature_info.h" 19 #include "gpu/command_buffer/service/feature_info.h"
20 #include "gpu/command_buffer/service/gl_utils.h" 20 #include "gpu/command_buffer/service/gl_utils.h"
21 #include "gpu/command_buffer/service/memory_tracking.h" 21 #include "gpu/command_buffer/service/memory_tracking.h"
22 #include "gpu/command_buffer/service/sampler_manager.h"
23 #include "gpu/gpu_export.h" 22 #include "gpu/gpu_export.h"
24 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gl/gl_image.h" 24 #include "ui/gl/gl_image.h"
26 25
27 namespace gpu { 26 namespace gpu {
28 namespace gles2 { 27 namespace gles2 {
29 28
30 class GLES2Decoder; 29 class GLES2Decoder;
31 struct ContextState; 30 struct ContextState;
32 struct DecoderFramebufferState; 31 struct DecoderFramebufferState;
(...skipping 21 matching lines...) Expand all
54 // Image state is set to COPIED if the contents of the image has been 53 // Image state is set to COPIED if the contents of the image has been
55 // copied to the texture. Sampling from the texture will be equivalent 54 // copied to the texture. Sampling from the texture will be equivalent
56 // to sampling out the image (assuming image has not been changed since 55 // to sampling out the image (assuming image has not been changed since
57 // it was copied). Using the texture as a target for drawing will only 56 // it was copied). Using the texture as a target for drawing will only
58 // modify the texture and not the image. 57 // modify the texture and not the image.
59 COPIED 58 COPIED
60 }; 59 };
61 60
62 explicit Texture(GLuint service_id); 61 explicit Texture(GLuint service_id);
63 62
64 const SamplerState& sampler_state() const {
65 return sampler_state_;
66 }
67
68 GLenum min_filter() const { 63 GLenum min_filter() const {
69 return sampler_state_.min_filter; 64 return min_filter_;
70 } 65 }
71 66
72 GLenum mag_filter() const { 67 GLenum mag_filter() const {
73 return sampler_state_.mag_filter; 68 return mag_filter_;
74 } 69 }
75 70
76 GLenum wrap_r() const { 71 GLenum wrap_r() const {
77 return sampler_state_.wrap_r; 72 return wrap_r_;
78 } 73 }
79 74
80 GLenum wrap_s() const { 75 GLenum wrap_s() const {
81 return sampler_state_.wrap_s; 76 return wrap_s_;
82 } 77 }
83 78
84 GLenum wrap_t() const { 79 GLenum wrap_t() const {
85 return sampler_state_.wrap_t; 80 return wrap_t_;
86 } 81 }
87 82
88 GLenum usage() const { 83 GLenum usage() const {
89 return usage_; 84 return usage_;
90 } 85 }
91 86
92 GLenum compare_func() const { 87 GLenum compare_func() const {
93 return sampler_state_.compare_func; 88 return compare_func_;
94 } 89 }
95 90
96 GLenum compare_mode() const { 91 GLenum compare_mode() const {
97 return sampler_state_.compare_mode; 92 return compare_mode_;
98 } 93 }
99 94
100 GLfloat max_lod() const { 95 GLfloat max_lod() const {
101 return sampler_state_.max_lod; 96 return max_lod_;
102 } 97 }
103 98
104 GLfloat min_lod() const { 99 GLfloat min_lod() const {
105 return sampler_state_.min_lod; 100 return min_lod_;
106 } 101 }
107 102
108 GLint base_level() const { 103 GLint base_level() const {
109 return base_level_; 104 return base_level_;
110 } 105 }
111 106
112 GLint max_level() const { 107 GLint max_level() const {
113 return max_level_; 108 return max_level_;
114 } 109 }
115 110
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 245
251 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it 246 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it
252 // depends on context support for non-power-of-two textures (i.e. will be 247 // depends on context support for non-power-of-two textures (i.e. will be
253 // renderable if NPOT support is in the context, otherwise not, e.g. texture 248 // renderable if NPOT support is in the context, otherwise not, e.g. texture
254 // with a NPOT level). ALWAYS means it doesn't depend on context features 249 // with a NPOT level). ALWAYS means it doesn't depend on context features
255 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g. 250 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g.
256 // incomplete). 251 // incomplete).
257 enum CanRenderCondition { 252 enum CanRenderCondition {
258 CAN_RENDER_ALWAYS, 253 CAN_RENDER_ALWAYS,
259 CAN_RENDER_NEVER, 254 CAN_RENDER_NEVER,
260 CAN_RENDER_NEEDS_VALIDATION, 255 CAN_RENDER_ONLY_IF_NPOT
261 }; 256 };
262 257
263 struct LevelInfo { 258 struct LevelInfo {
264 LevelInfo(); 259 LevelInfo();
265 LevelInfo(const LevelInfo& rhs); 260 LevelInfo(const LevelInfo& rhs);
266 ~LevelInfo(); 261 ~LevelInfo();
267 262
268 gfx::Rect cleared_rect; 263 gfx::Rect cleared_rect;
269 GLenum target; 264 GLenum target;
270 GLint level; 265 GLint level;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // Returns GL_NO_ERROR on success. Otherwise the error to generate. 340 // Returns GL_NO_ERROR on success. Otherwise the error to generate.
346 GLenum SetParameteri( 341 GLenum SetParameteri(
347 const FeatureInfo* feature_info, GLenum pname, GLint param); 342 const FeatureInfo* feature_info, GLenum pname, GLint param);
348 GLenum SetParameterf( 343 GLenum SetParameterf(
349 const FeatureInfo* feature_info, GLenum pname, GLfloat param); 344 const FeatureInfo* feature_info, GLenum pname, GLfloat param);
350 345
351 // Makes each of the mip levels as though they were generated. 346 // Makes each of the mip levels as though they were generated.
352 void MarkMipmapsGenerated(const FeatureInfo* feature_info); 347 void MarkMipmapsGenerated(const FeatureInfo* feature_info);
353 348
354 bool NeedsMips() const { 349 bool NeedsMips() const {
355 return sampler_state_.min_filter != GL_NEAREST && 350 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR;
356 sampler_state_.min_filter != GL_LINEAR;
357 } 351 }
358 352
359 // True if this texture meets all the GLES2 criteria for rendering. 353 // True if this texture meets all the GLES2 criteria for rendering.
360 // See section 3.8.2 of the GLES2 spec. 354 // See section 3.8.2 of the GLES2 spec.
361 bool CanRender(const FeatureInfo* feature_info) const; 355 bool CanRender(const FeatureInfo* feature_info) const;
362 bool CanRenderWithSampler(const FeatureInfo* feature_info,
363 const SamplerState& sampler_state) const;
364 356
365 // Returns true if mipmaps can be generated by GL. 357 // Returns true if mipmaps can be generated by GL.
366 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const; 358 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const;
367 359
368 // Returns true if any of the texture dimensions are not a power of two. 360 // Returns true if any of the texture dimensions are not a power of two.
369 static bool TextureIsNPOT(GLsizei width, GLsizei height, GLsizei depth); 361 static bool TextureIsNPOT(GLsizei width, GLsizei height, GLsizei depth);
370 362
371 // Returns true if texture face is complete relative to the first face. 363 // Returns true if texture face is complete relative to the first face.
372 static bool TextureFaceComplete(const Texture::LevelInfo& first_face, 364 static bool TextureFaceComplete(const Texture::LevelInfo& first_face,
373 size_t face_index, 365 size_t face_index,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 bool cleared_; 470 bool cleared_;
479 471
480 int num_uncleared_mips_; 472 int num_uncleared_mips_;
481 int num_npot_faces_; 473 int num_npot_faces_;
482 474
483 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. 475 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
484 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3). 476 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3).
485 GLenum target_; 477 GLenum target_;
486 478
487 // Texture parameters. 479 // Texture parameters.
488 SamplerState sampler_state_; 480 GLenum min_filter_;
481 GLenum mag_filter_;
482 GLenum wrap_r_;
483 GLenum wrap_s_;
484 GLenum wrap_t_;
489 GLenum usage_; 485 GLenum usage_;
486 GLenum compare_func_;
487 GLenum compare_mode_;
488 GLfloat max_lod_;
489 GLfloat min_lod_;
490 GLint base_level_; 490 GLint base_level_;
491 GLint max_level_; 491 GLint max_level_;
492 492
493 // The maximum level that has been set. 493 // The maximum level that has been set.
494 GLint max_level_set_; 494 GLint max_level_set_;
495 495
496 // Whether or not this texture is "texture complete" 496 // Whether or not this texture is "texture complete"
497 bool texture_complete_; 497 bool texture_complete_;
498 498
499 // Whether mip levels have changed and should be reverified. 499 // Whether mip levels have changed and should be reverified.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 bool ValidForTarget( 696 bool ValidForTarget(
697 GLenum target, GLint level, 697 GLenum target, GLint level,
698 GLsizei width, GLsizei height, GLsizei depth); 698 GLsizei width, GLsizei height, GLsizei depth);
699 699
700 // True if this texture meets all the GLES2 criteria for rendering. 700 // True if this texture meets all the GLES2 criteria for rendering.
701 // See section 3.8.2 of the GLES2 spec. 701 // See section 3.8.2 of the GLES2 spec.
702 bool CanRender(const TextureRef* ref) const { 702 bool CanRender(const TextureRef* ref) const {
703 return ref->texture()->CanRender(feature_info_.get()); 703 return ref->texture()->CanRender(feature_info_.get());
704 } 704 }
705 705
706 bool CanRenderWithSampler(
707 const TextureRef* ref, const SamplerState& sampler_state) const {
708 return ref->texture()->CanRenderWithSampler(
709 feature_info_.get(), sampler_state);
710 }
711
712 // Returns true if mipmaps can be generated by GL. 706 // Returns true if mipmaps can be generated by GL.
713 bool CanGenerateMipmaps(const TextureRef* ref) const { 707 bool CanGenerateMipmaps(const TextureRef* ref) const {
714 return ref->texture()->CanGenerateMipmaps(feature_info_.get()); 708 return ref->texture()->CanGenerateMipmaps(feature_info_.get());
715 } 709 }
716 710
717 // Sets the Texture's target 711 // Sets the Texture's target
718 // Parameters: 712 // Parameters:
719 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP 713 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
720 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) 714 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3)
721 // max_levels: The maximum levels this type of target can have. 715 // max_levels: The maximum levels this type of target can have.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 case GL_TEXTURE_EXTERNAL_OES: 791 case GL_TEXTURE_EXTERNAL_OES:
798 return default_textures_[kExternalOES].get(); 792 return default_textures_[kExternalOES].get();
799 case GL_TEXTURE_RECTANGLE_ARB: 793 case GL_TEXTURE_RECTANGLE_ARB:
800 return default_textures_[kRectangleARB].get(); 794 return default_textures_[kRectangleARB].get();
801 default: 795 default:
802 NOTREACHED(); 796 NOTREACHED();
803 return NULL; 797 return NULL;
804 } 798 }
805 } 799 }
806 800
801 bool HaveUnrenderableTextures() const {
802 return num_unrenderable_textures_ > 0;
803 }
804
807 bool HaveUnsafeTextures() const { 805 bool HaveUnsafeTextures() const {
808 return num_unsafe_textures_ > 0; 806 return num_unsafe_textures_ > 0;
809 } 807 }
810 808
811 bool HaveUnclearedMips() const { 809 bool HaveUnclearedMips() const {
812 return num_uncleared_mips_ > 0; 810 return num_uncleared_mips_ > 0;
813 } 811 }
814 812
815 bool HaveImages() const { 813 bool HaveImages() const {
816 return num_images_ > 0; 814 return num_images_ > 0;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 GLsizei max_texture_size_; 1008 GLsizei max_texture_size_;
1011 GLsizei max_cube_map_texture_size_; 1009 GLsizei max_cube_map_texture_size_;
1012 GLsizei max_rectangle_texture_size_; 1010 GLsizei max_rectangle_texture_size_;
1013 GLsizei max_3d_texture_size_; 1011 GLsizei max_3d_texture_size_;
1014 GLint max_levels_; 1012 GLint max_levels_;
1015 GLint max_cube_map_levels_; 1013 GLint max_cube_map_levels_;
1016 GLint max_3d_levels_; 1014 GLint max_3d_levels_;
1017 1015
1018 const bool use_default_textures_; 1016 const bool use_default_textures_;
1019 1017
1018 int num_unrenderable_textures_;
1020 int num_unsafe_textures_; 1019 int num_unsafe_textures_;
1021 int num_uncleared_mips_; 1020 int num_uncleared_mips_;
1022 int num_images_; 1021 int num_images_;
1023 1022
1024 // Counts the number of Textures allocated with 'this' as its manager. 1023 // Counts the number of Textures allocated with 'this' as its manager.
1025 // Allows to check no Texture will outlive this. 1024 // Allows to check no Texture will outlive this.
1026 unsigned int texture_count_; 1025 unsigned int texture_count_;
1027 1026
1028 bool have_context_; 1027 bool have_context_;
1029 1028
(...skipping 21 matching lines...) Expand all
1051 private: 1050 private:
1052 DecoderTextureState* texture_state_; 1051 DecoderTextureState* texture_state_;
1053 base::TimeTicks begin_time_; 1052 base::TimeTicks begin_time_;
1054 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); 1053 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer);
1055 }; 1054 };
1056 1055
1057 } // namespace gles2 1056 } // namespace gles2
1058 } // namespace gpu 1057 } // namespace gpu
1059 1058
1060 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 1059 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_definition.cc ('k') | gpu/command_buffer/service/texture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698