Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <algorithm> | 8 #include <algorithm> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 friend class TextureDefinition; | 208 friend class TextureDefinition; |
| 209 friend class TextureManager; | 209 friend class TextureManager; |
| 210 friend class TextureRef; | 210 friend class TextureRef; |
| 211 friend class TextureTestHelper; | 211 friend class TextureTestHelper; |
| 212 | 212 |
| 213 ~Texture(); | 213 ~Texture(); |
| 214 void AddTextureRef(TextureRef* ref); | 214 void AddTextureRef(TextureRef* ref); |
| 215 void RemoveTextureRef(TextureRef* ref, bool have_context); | 215 void RemoveTextureRef(TextureRef* ref, bool have_context); |
| 216 MemoryTypeTracker* GetMemTracker(); | 216 MemoryTypeTracker* GetMemTracker(); |
| 217 | 217 |
| 218 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it | 218 // Condition on which this texture is complete. Can be ONLY_IF_NPOT if it |
| 219 // depends on context support for non-power-of-two textures (i.e. will be | 219 // depends on context support for non-power-of-two textures (i.e. will be |
| 220 // renderable if NPOT support is in the context, otherwise not, e.g. texture | 220 // complete if NPOT support is in the context, otherwise not, e.g. texture |
| 221 // with a NPOT level). ALWAYS means it doesn't depend on context features | 221 // with a NPOT level). ALWAYS means it doesn't depend on context features |
| 222 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g. | 222 // (e.g. complete POT), NEVER means it's not complete regardless (e.g. |
| 223 // incomplete). | 223 // incomplete). |
| 224 enum CanRenderCondition { | 224 // See section 3.7.10 of the GLES2 spec. |
| 225 CAN_RENDER_ALWAYS, | 225 enum TextureCompleteness { |
| 226 CAN_RENDER_NEVER, | 226 TEXTURE_COMPLETE_ALWAYS, |
| 227 CAN_RENDER_ONLY_IF_NPOT | 227 TEXTURE_INCOMPLETE, |
| 228 TEXTURE_COMPLETE_ONLY_IF_NPOT | |
| 228 }; | 229 }; |
| 229 | 230 |
| 230 struct LevelInfo { | 231 struct LevelInfo { |
| 231 LevelInfo(); | 232 LevelInfo(); |
| 232 LevelInfo(const LevelInfo& rhs); | 233 LevelInfo(const LevelInfo& rhs); |
| 233 ~LevelInfo(); | 234 ~LevelInfo(); |
| 234 | 235 |
| 235 gfx::Rect cleared_rect; | 236 gfx::Rect cleared_rect; |
| 236 GLenum target; | 237 GLenum target; |
| 237 GLint level; | 238 GLint level; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 263 GLsizei height, | 264 GLsizei height, |
| 264 GLsizei depth, | 265 GLsizei depth, |
| 265 GLint border, | 266 GLint border, |
| 266 GLenum format, | 267 GLenum format, |
| 267 GLenum type, | 268 GLenum type, |
| 268 const gfx::Rect& cleared_rect); | 269 const gfx::Rect& cleared_rect); |
| 269 | 270 |
| 270 // In GLES2 "texture complete" means it has all required mips for filtering | 271 // In GLES2 "texture complete" means it has all required mips for filtering |
| 271 // down to a 1x1 pixel texture, they are in the correct order, they are all | 272 // down to a 1x1 pixel texture, they are in the correct order, they are all |
| 272 // the same format. | 273 // the same format. |
| 273 bool texture_complete() const { | 274 // See section 3.7.10 of the GLES2 spec. |
| 274 return texture_complete_; | 275 bool texture_2d_complete() const { return texture_2d_complete_; } |
| 275 } | |
| 276 | 276 |
| 277 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the | 277 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the |
| 278 // same format, all the same dimensions and all width = height. | 278 // same format, all the same dimensions and all width = height. |
| 279 // See section 3.7.10 of the GLES2 spec. | |
| 279 bool cube_complete() const { | 280 bool cube_complete() const { |
| 280 return cube_complete_; | 281 return cube_complete_; |
| 281 } | 282 } |
| 282 | 283 |
| 283 // Whether or not this texture is a non-power-of-two texture. | 284 // Whether or not this texture is a non-power-of-two texture. |
| 284 bool npot() const { | 285 bool npot() const { |
| 285 return npot_; | 286 return npot_; |
| 286 } | 287 } |
| 287 | 288 |
| 288 // Marks a |rect| of a particular level as cleared. | 289 // Marks a |rect| of a particular level as cleared. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 313 const FeatureInfo* feature_info, GLenum pname, GLfloat param); | 314 const FeatureInfo* feature_info, GLenum pname, GLfloat param); |
| 314 | 315 |
| 315 // Makes each of the mip levels as though they were generated. | 316 // Makes each of the mip levels as though they were generated. |
| 316 bool MarkMipmapsGenerated(const FeatureInfo* feature_info); | 317 bool MarkMipmapsGenerated(const FeatureInfo* feature_info); |
| 317 | 318 |
| 318 bool NeedsMips() const { | 319 bool NeedsMips() const { |
| 319 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; | 320 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; |
| 320 } | 321 } |
| 321 | 322 |
| 322 // True if this texture meets all the GLES2 criteria for rendering. | 323 // True if this texture meets all the GLES2 criteria for rendering. |
| 323 // See section 3.8.2 of the GLES2 spec. | 324 // See section 3.7.10 of the GLES2 spec. |
|
dshwang
2015/08/17 16:20:41
section 3.8.2 is "Shader Execution", which isn't r
Ken Russell (switch to Gerrit)
2015/08/17 21:32:27
On the contrary: it is related. In GLES2 a texture
dshwang
2015/08/18 07:18:16
I see. Let me not change the name. mentioning sect
| |
| 324 bool CanRender(const FeatureInfo* feature_info) const; | 325 bool IsTextureComplete(const FeatureInfo* feature_info) const; |
| 325 | 326 |
| 326 // Returns true if mipmaps can be generated by GL. | 327 // Returns true if mipmaps can be generated by GL. |
| 327 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const; | 328 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const; |
| 328 | 329 |
| 329 // Returns true if any of the texture dimensions are not a power of two. | 330 // Returns true if any of the texture dimensions are not a power of two. |
| 330 static bool TextureIsNPOT(GLsizei width, GLsizei height, GLsizei depth); | 331 static bool TextureIsNPOT(GLsizei width, GLsizei height, GLsizei depth); |
| 331 | 332 |
| 332 // Returns true if texture face is complete relative to the first face. | 333 // Returns true if texture face is complete relative to the first face. |
| 333 static bool TextureFaceComplete(const Texture::LevelInfo& first_face, | 334 static bool TextureFaceComplete(const Texture::LevelInfo& first_face, |
| 334 size_t face_index, | 335 size_t face_index, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 // texture. | 382 // texture. |
| 382 void UpdateSafeToRenderFrom(bool cleared); | 383 void UpdateSafeToRenderFrom(bool cleared); |
| 383 | 384 |
| 384 // Updates the uncleared mip count in all the managers referencing this | 385 // Updates the uncleared mip count in all the managers referencing this |
| 385 // texture. | 386 // texture. |
| 386 void UpdateMipCleared(LevelInfo* info, | 387 void UpdateMipCleared(LevelInfo* info, |
| 387 GLsizei width, | 388 GLsizei width, |
| 388 GLsizei height, | 389 GLsizei height, |
| 389 const gfx::Rect& cleared_rect); | 390 const gfx::Rect& cleared_rect); |
| 390 | 391 |
| 391 // Computes the CanRenderCondition flag. | 392 // Computes the TextureCompleteness flag. |
| 392 CanRenderCondition GetCanRenderCondition() const; | 393 TextureCompleteness GetTextureCompleteness() const; |
| 393 | 394 |
| 394 // Updates the unrenderable texture count in all the managers referencing this | 395 // Updates the unrenderable texture count in all the managers referencing this |
| 395 // texture. | 396 // texture. |
| 396 void UpdateCanRenderCondition(); | 397 void UpdateTextureCompleteness(); |
| 397 | 398 |
| 398 // Updates the images count in all the managers referencing this | 399 // Updates the images count in all the managers referencing this |
| 399 // texture. | 400 // texture. |
| 400 void UpdateHasImages(); | 401 void UpdateHasImages(); |
| 401 | 402 |
| 402 // Increment the framebuffer state change count in all the managers | 403 // Increment the framebuffer state change count in all the managers |
| 403 // referencing this texture. | 404 // referencing this texture. |
| 404 void IncAllFramebufferStateChangeCount(); | 405 void IncAllFramebufferStateChangeCount(); |
| 405 | 406 |
| 406 MailboxManager* mailbox_manager_; | 407 MailboxManager* mailbox_manager_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 GLenum compare_mode_; | 442 GLenum compare_mode_; |
| 442 GLfloat max_lod_; | 443 GLfloat max_lod_; |
| 443 GLfloat min_lod_; | 444 GLfloat min_lod_; |
| 444 GLint base_level_; | 445 GLint base_level_; |
| 445 GLint max_level_; | 446 GLint max_level_; |
| 446 | 447 |
| 447 // The maximum level that has been set. | 448 // The maximum level that has been set. |
| 448 GLint max_level_set_; | 449 GLint max_level_set_; |
| 449 | 450 |
| 450 // Whether or not this texture is "texture complete" | 451 // Whether or not this texture is "texture complete" |
| 451 bool texture_complete_; | 452 bool texture_2d_complete_; |
| 452 | 453 |
| 453 // Whether mip levels have changed and should be reverified. | 454 // Whether mip levels have changed and should be reverified. |
| 454 bool texture_mips_dirty_; | 455 bool texture_mips_dirty_; |
| 455 bool texture_mips_complete_; | 456 bool texture_mips_complete_; |
| 456 | 457 |
| 457 // Whether or not this texture is "cube complete" | 458 // Whether or not this texture is "cube complete" |
| 458 bool cube_complete_; | 459 bool cube_complete_; |
| 459 | 460 |
| 460 // Whether any level 0 faces have changed and should be reverified. | 461 // Whether any level 0 faces have changed and should be reverified. |
| 461 bool texture_level0_dirty_; | 462 bool texture_level0_dirty_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 473 // Whether the texture is immutable and no further changes to the format | 474 // Whether the texture is immutable and no further changes to the format |
| 474 // or dimensions of the texture object can be made. | 475 // or dimensions of the texture object can be made. |
| 475 bool immutable_; | 476 bool immutable_; |
| 476 | 477 |
| 477 // Whether or not this texture has images. | 478 // Whether or not this texture has images. |
| 478 bool has_images_; | 479 bool has_images_; |
| 479 | 480 |
| 480 // Size in bytes this texture is assumed to take in memory. | 481 // Size in bytes this texture is assumed to take in memory. |
| 481 uint32 estimated_size_; | 482 uint32 estimated_size_; |
| 482 | 483 |
| 483 // Cache of the computed CanRenderCondition flag. | 484 // Cache of the computed TextureCompleteness flag. |
| 484 CanRenderCondition can_render_condition_; | 485 TextureCompleteness texture_completeness; |
| 485 | 486 |
| 486 // Whether we have initialized TEXTURE_MAX_ANISOTROPY to 1. | 487 // Whether we have initialized TEXTURE_MAX_ANISOTROPY to 1. |
| 487 bool texture_max_anisotropy_initialized_; | 488 bool texture_max_anisotropy_initialized_; |
| 488 | 489 |
| 489 DISALLOW_COPY_AND_ASSIGN(Texture); | 490 DISALLOW_COPY_AND_ASSIGN(Texture); |
| 490 }; | 491 }; |
| 491 | 492 |
| 492 // This class represents a texture in a client context group. It's mostly 1:1 | 493 // This class represents a texture in a client context group. It's mostly 1:1 |
| 493 // with a client id, though it can outlive the client id if it's still bound to | 494 // with a client id, though it can outlive the client id if it's still bound to |
| 494 // a FBO or another context when destroyed. | 495 // a FBO or another context when destroyed. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 GLsizei width, | 637 GLsizei width, |
| 637 GLsizei height, | 638 GLsizei height, |
| 638 GLsizei depth); | 639 GLsizei depth); |
| 639 | 640 |
| 640 // Checks if a dimensions are valid for a given target. | 641 // Checks if a dimensions are valid for a given target. |
| 641 bool ValidForTarget( | 642 bool ValidForTarget( |
| 642 GLenum target, GLint level, | 643 GLenum target, GLint level, |
| 643 GLsizei width, GLsizei height, GLsizei depth); | 644 GLsizei width, GLsizei height, GLsizei depth); |
| 644 | 645 |
| 645 // True if this texture meets all the GLES2 criteria for rendering. | 646 // True if this texture meets all the GLES2 criteria for rendering. |
| 646 // See section 3.8.2 of the GLES2 spec. | 647 // See section 3.7.10 of the GLES2 spec. |
| 647 bool CanRender(const TextureRef* ref) const { | 648 bool IsTextureComplete(const TextureRef* ref) const { |
| 648 return ref->texture()->CanRender(feature_info_.get()); | 649 return ref->texture()->IsTextureComplete(feature_info_.get()); |
| 649 } | 650 } |
| 650 | 651 |
| 651 // Returns true if mipmaps can be generated by GL. | 652 // Returns true if mipmaps can be generated by GL. |
| 652 bool CanGenerateMipmaps(const TextureRef* ref) const { | 653 bool CanGenerateMipmaps(const TextureRef* ref) const { |
| 653 return ref->texture()->CanGenerateMipmaps(feature_info_.get()); | 654 return ref->texture()->CanGenerateMipmaps(feature_info_.get()); |
| 654 } | 655 } |
| 655 | 656 |
| 656 // Sets the Texture's target | 657 // Sets the Texture's target |
| 657 // Parameters: | 658 // Parameters: |
| 658 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP | 659 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 DecoderFramebufferState* framebuffer_state, | 887 DecoderFramebufferState* framebuffer_state, |
| 887 const char* function_name, | 888 const char* function_name, |
| 888 TextureRef* texture_ref, | 889 TextureRef* texture_ref, |
| 889 const DoTexImageArguments& args); | 890 const DoTexImageArguments& args); |
| 890 | 891 |
| 891 void StartTracking(TextureRef* texture); | 892 void StartTracking(TextureRef* texture); |
| 892 void StopTracking(TextureRef* texture); | 893 void StopTracking(TextureRef* texture); |
| 893 | 894 |
| 894 void UpdateSafeToRenderFrom(int delta); | 895 void UpdateSafeToRenderFrom(int delta); |
| 895 void UpdateUnclearedMips(int delta); | 896 void UpdateUnclearedMips(int delta); |
| 896 void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition, | 897 void UpdateTextureCompleteness(Texture::TextureCompleteness old_completeness, |
| 897 Texture::CanRenderCondition new_condition); | 898 Texture::TextureCompleteness new_completeness); |
| 898 void UpdateNumImages(int delta); | 899 void UpdateNumImages(int delta); |
| 899 void IncFramebufferStateChangeCount(); | 900 void IncFramebufferStateChangeCount(); |
| 900 | 901 |
| 901 GLenum AdjustTexFormat(GLenum format) const; | 902 GLenum AdjustTexFormat(GLenum format) const; |
| 902 | 903 |
| 903 // Helper function called by OnMemoryDump. | 904 // Helper function called by OnMemoryDump. |
| 904 void DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, | 905 void DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
| 905 TextureRef* ref); | 906 TextureRef* ref); |
| 906 | 907 |
| 907 MemoryTypeTracker* GetMemTracker(GLenum texture_pool); | 908 MemoryTypeTracker* GetMemTracker(GLenum texture_pool); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 private: | 961 private: |
| 961 DecoderTextureState* texture_state_; | 962 DecoderTextureState* texture_state_; |
| 962 base::TimeTicks begin_time_; | 963 base::TimeTicks begin_time_; |
| 963 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 964 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 964 }; | 965 }; |
| 965 | 966 |
| 966 } // namespace gles2 | 967 } // namespace gles2 |
| 967 } // namespace gpu | 968 } // namespace gpu |
| 968 | 969 |
| 969 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 970 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |