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

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

Issue 2496633005: Fix unsized internalformat color-renderable detection (Closed)
Patch Set: add gpu_unittests Created 4 years, 1 month 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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 return false; 778 return false;
779 } 779 }
780 780
781 // Can't generate mips for depth or stencil textures. 781 // Can't generate mips for depth or stencil textures.
782 const Texture::LevelInfo& base = face_infos_[0].level_infos[base_level_]; 782 const Texture::LevelInfo& base = face_infos_[0].level_infos[base_level_];
783 uint32_t channels = GLES2Util::GetChannelsForFormat(base.format); 783 uint32_t channels = GLES2Util::GetChannelsForFormat(base.format);
784 if (channels & (GLES2Util::kDepth | GLES2Util::kStencil)) { 784 if (channels & (GLES2Util::kDepth | GLES2Util::kStencil)) {
785 return false; 785 return false;
786 } 786 }
787 787
788 if (!Texture::ColorRenderable(feature_info, base.internal_format, 788 if (!feature_info->validators()->texture_unsized_internal_format.IsValid(
789 immutable_) || 789 base.internal_format)) {
790 !Texture::TextureFilterable(feature_info, base.internal_format, base.type, 790 if (!Texture::ColorRenderable(feature_info, base.internal_format,
791 immutable_)) { 791 immutable_) ||
792 return false; 792 !Texture::TextureFilterable(feature_info, base.internal_format,
793 base.type,
794 immutable_)) {
795 return false;
796 }
793 } 797 }
794 798
795 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { 799 for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
796 const LevelInfo& info = face_infos_[ii].level_infos[base_level_]; 800 const LevelInfo& info = face_infos_[ii].level_infos[base_level_];
797 if ((info.target == 0) || 801 if ((info.target == 0) ||
798 feature_info->validators()->compressed_texture_format.IsValid( 802 feature_info->validators()->compressed_texture_format.IsValid(
799 info.internal_format) || 803 info.internal_format) ||
800 info.image.get()) { 804 info.image.get()) {
801 return false; 805 return false;
802 } 806 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 866 }
863 return complete; 867 return complete;
864 } 868 }
865 869
866 // static 870 // static
867 bool Texture::ColorRenderable(const FeatureInfo* feature_info, 871 bool Texture::ColorRenderable(const FeatureInfo* feature_info,
868 GLenum internal_format, 872 GLenum internal_format,
869 bool immutable) { 873 bool immutable) {
870 if (feature_info->validators()->texture_unsized_internal_format.IsValid( 874 if (feature_info->validators()->texture_unsized_internal_format.IsValid(
871 internal_format)) { 875 internal_format)) {
872 return true; 876 return internal_format == GL_RGBA || internal_format == GL_RGB ||
Zhenyao Mo 2016/11/14 19:49:44 Actually let's stick to the != ALPHA != LUMINANCE
qiankun 2016/11/18 03:20:38 Done.
877 internal_format == GL_BGRA_EXT ||
878 internal_format == GL_SRGB_ALPHA_EXT;
873 } 879 }
874 880
875 return SizedFormatAvailable(feature_info, immutable, internal_format) && 881 return SizedFormatAvailable(feature_info, immutable, internal_format) &&
876 feature_info->validators() 882 feature_info->validators()
877 ->texture_sized_color_renderable_internal_format.IsValid( 883 ->texture_sized_color_renderable_internal_format.IsValid(
878 internal_format); 884 internal_format);
879 } 885 }
880 886
881 // static 887 // static
882 bool Texture::TextureFilterable(const FeatureInfo* feature_info, 888 bool Texture::TextureFilterable(const FeatureInfo* feature_info,
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 // In GLES2, cube completeness is not required for framebuffer completeness. 1771 // In GLES2, cube completeness is not required for framebuffer completeness.
1766 // However, it is required if command buffer is implemented on top of 1772 // However, it is required if command buffer is implemented on top of
1767 // recent OpenGL core versions or OpenGL ES 3.0+. Therefore, for consistency, 1773 // recent OpenGL core versions or OpenGL ES 3.0+. Therefore, for consistency,
1768 // it is better to deviate from ES2 spec and require cube completeness all 1774 // it is better to deviate from ES2 spec and require cube completeness all
1769 // the time. 1775 // the time.
1770 if (face_infos_.size() == 6 && !cube_complete_) 1776 if (face_infos_.size() == 6 && !cube_complete_)
1771 return false; 1777 return false;
1772 DCHECK(level >= 0 && 1778 DCHECK(level >= 0 &&
1773 level < static_cast<GLint>(face_infos_[0].level_infos.size())); 1779 level < static_cast<GLint>(face_infos_[0].level_infos.size()));
1774 GLenum internal_format = face_infos_[0].level_infos[level].internal_format; 1780 GLenum internal_format = face_infos_[0].level_infos[level].internal_format;
1775 bool color_renderable = 1781 bool color_renderable = ColorRenderable(feature_info, internal_format,
1776 ((feature_info->validators()->texture_unsized_internal_format.IsValid( 1782 immutable_);
1777 internal_format) &&
1778 internal_format != GL_ALPHA && internal_format != GL_LUMINANCE &&
1779 internal_format != GL_LUMINANCE_ALPHA &&
1780 internal_format != GL_SRGB_EXT) ||
1781 (SizedFormatAvailable(feature_info, immutable_, internal_format) &&
1782 feature_info->validators()
1783 ->texture_sized_color_renderable_internal_format.IsValid(
1784 internal_format)));
1785 bool depth_renderable = feature_info->validators()-> 1783 bool depth_renderable = feature_info->validators()->
1786 texture_depth_renderable_internal_format.IsValid(internal_format); 1784 texture_depth_renderable_internal_format.IsValid(internal_format);
1787 bool stencil_renderable = feature_info->validators()-> 1785 bool stencil_renderable = feature_info->validators()->
1788 texture_stencil_renderable_internal_format.IsValid(internal_format); 1786 texture_stencil_renderable_internal_format.IsValid(internal_format);
1789 return (color_renderable || depth_renderable || stencil_renderable); 1787 return (color_renderable || depth_renderable || stencil_renderable);
1790 } 1788 }
1791 1789
1792 GLenum Texture::GetCompatibilitySwizzleForChannel(GLenum channel) { 1790 GLenum Texture::GetCompatibilitySwizzleForChannel(GLenum channel) {
1793 return GetSwizzleForChannel(channel, compatibility_swizzle_); 1791 return GetSwizzleForChannel(channel, compatibility_swizzle_);
1794 } 1792 }
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
3648 uint32_t TextureManager::GetServiceIdGeneration() const { 3646 uint32_t TextureManager::GetServiceIdGeneration() const {
3649 return current_service_id_generation_; 3647 return current_service_id_generation_;
3650 } 3648 }
3651 3649
3652 void TextureManager::IncrementServiceIdGeneration() { 3650 void TextureManager::IncrementServiceIdGeneration() {
3653 current_service_id_generation_++; 3651 current_service_id_generation_++;
3654 } 3652 }
3655 3653
3656 } // namespace gles2 3654 } // namespace gles2
3657 } // namespace gpu 3655 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698