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

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

Issue 1950233002: Fix a bug in texture validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 texture_->RemoveTextureRef(this, manager_->have_context_); 1698 texture_->RemoveTextureRef(this, manager_->have_context_);
1699 manager_ = NULL; 1699 manager_ = NULL;
1700 } 1700 }
1701 1701
1702 TextureManager::TextureManager(MemoryTracker* memory_tracker, 1702 TextureManager::TextureManager(MemoryTracker* memory_tracker,
1703 FeatureInfo* feature_info, 1703 FeatureInfo* feature_info,
1704 GLint max_texture_size, 1704 GLint max_texture_size,
1705 GLint max_cube_map_texture_size, 1705 GLint max_cube_map_texture_size,
1706 GLint max_rectangle_texture_size, 1706 GLint max_rectangle_texture_size,
1707 GLint max_3d_texture_size, 1707 GLint max_3d_texture_size,
1708 GLint max_array_texture_layers,
1708 bool use_default_textures) 1709 bool use_default_textures)
1709 : memory_type_tracker_(new MemoryTypeTracker(memory_tracker)), 1710 : memory_type_tracker_(new MemoryTypeTracker(memory_tracker)),
1710 memory_tracker_(memory_tracker), 1711 memory_tracker_(memory_tracker),
1711 feature_info_(feature_info), 1712 feature_info_(feature_info),
1712 framebuffer_manager_(NULL), 1713 framebuffer_manager_(NULL),
1713 max_texture_size_(max_texture_size), 1714 max_texture_size_(max_texture_size),
1714 max_cube_map_texture_size_(max_cube_map_texture_size), 1715 max_cube_map_texture_size_(max_cube_map_texture_size),
1715 max_rectangle_texture_size_(max_rectangle_texture_size), 1716 max_rectangle_texture_size_(max_rectangle_texture_size),
1716 max_3d_texture_size_(max_3d_texture_size), 1717 max_3d_texture_size_(max_3d_texture_size),
1718 max_array_texture_layers_(max_array_texture_layers),
1717 max_levels_(ComputeMipMapCount(GL_TEXTURE_2D, 1719 max_levels_(ComputeMipMapCount(GL_TEXTURE_2D,
1718 max_texture_size, 1720 max_texture_size,
1719 max_texture_size, 1721 max_texture_size,
1720 max_texture_size)), 1722 0)),
1721 max_cube_map_levels_(ComputeMipMapCount(GL_TEXTURE_CUBE_MAP, 1723 max_cube_map_levels_(ComputeMipMapCount(GL_TEXTURE_CUBE_MAP,
1722 max_cube_map_texture_size, 1724 max_cube_map_texture_size,
1723 max_cube_map_texture_size, 1725 max_cube_map_texture_size,
1724 max_cube_map_texture_size)), 1726 0)),
1725 max_3d_levels_(ComputeMipMapCount(GL_TEXTURE_3D, 1727 max_3d_levels_(ComputeMipMapCount(GL_TEXTURE_3D,
1726 max_3d_texture_size, 1728 max_3d_texture_size,
1727 max_3d_texture_size, 1729 max_3d_texture_size,
1728 max_3d_texture_size)), 1730 max_3d_texture_size)),
1729 use_default_textures_(use_default_textures), 1731 use_default_textures_(use_default_textures),
1730 num_unsafe_textures_(0), 1732 num_unsafe_textures_(0),
1731 num_uncleared_mips_(0), 1733 num_uncleared_mips_(0),
1732 num_images_(0), 1734 num_images_(0),
1733 texture_count_(0), 1735 texture_count_(0),
1734 have_context_(true), 1736 have_context_(true),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 } 1835 }
1834 } 1836 }
1835 } 1837 }
1836 1838
1837 *black_texture = ids[0]; 1839 *black_texture = ids[0];
1838 return default_texture; 1840 return default_texture;
1839 } 1841 }
1840 1842
1841 bool TextureManager::ValidForTarget( 1843 bool TextureManager::ValidForTarget(
1842 GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth) { 1844 GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth) {
1845 if (level < 0 || level >= MaxLevelsForTarget(target))
1846 return false;
1843 GLsizei max_size = MaxSizeForTarget(target) >> level; 1847 GLsizei max_size = MaxSizeForTarget(target) >> level;
1844 return level >= 0 && 1848 GLsizei max_depth =
1845 width >= 0 && 1849 (target == GL_TEXTURE_2D_ARRAY ? max_array_texture_layers() : max_size);
1850 return width >= 0 &&
1846 height >= 0 && 1851 height >= 0 &&
1847 depth >= 0 && 1852 depth >= 0 &&
1848 level < MaxLevelsForTarget(target) &&
1849 width <= max_size && 1853 width <= max_size &&
1850 height <= max_size && 1854 height <= max_size &&
1851 depth <= max_size && 1855 depth <= max_depth &&
1852 (level == 0 || feature_info_->feature_flags().npot_ok || 1856 (level == 0 || feature_info_->feature_flags().npot_ok ||
1853 (!GLES2Util::IsNPOT(width) && 1857 (!GLES2Util::IsNPOT(width) &&
1854 !GLES2Util::IsNPOT(height) && 1858 !GLES2Util::IsNPOT(height) &&
1855 !GLES2Util::IsNPOT(depth))) && 1859 !GLES2Util::IsNPOT(depth))) &&
1856 (target != GL_TEXTURE_CUBE_MAP || (width == height && depth == 1)) && 1860 (target != GL_TEXTURE_CUBE_MAP || (width == height && depth == 1)) &&
1857 (target != GL_TEXTURE_2D || (depth == 1)); 1861 (target != GL_TEXTURE_2D || (depth == 1));
1858 } 1862 }
1859 1863
1860 void TextureManager::SetTarget(TextureRef* ref, GLenum target) { 1864 void TextureManager::SetTarget(TextureRef* ref, GLenum target) {
1861 DCHECK(ref); 1865 DCHECK(ref);
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 uint32_t TextureManager::GetServiceIdGeneration() const { 3191 uint32_t TextureManager::GetServiceIdGeneration() const {
3188 return current_service_id_generation_; 3192 return current_service_id_generation_;
3189 } 3193 }
3190 3194
3191 void TextureManager::IncrementServiceIdGeneration() { 3195 void TextureManager::IncrementServiceIdGeneration() {
3192 current_service_id_generation_++; 3196 current_service_id_generation_++;
3193 } 3197 }
3194 3198
3195 } // namespace gles2 3199 } // namespace gles2
3196 } // namespace gpu 3200 } // 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