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

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

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