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 3 // found in the LICENSE file. 4 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_ 7 8 #include <set> 9 #include <string> 10 #include "base/containers/hash_tables.h" 11 #include "base/memory/ref_counted.h" 12 #include "base/sys_info.h" 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 14 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 15 #include "gpu/config/gpu_driver_bug_workaround_type.h" 16 #include "gpu/gpu_export.h" 17 18 class CommandLine; 19 20 namespace gpu { 21 namespace gles2 { 22 23 // FeatureInfo records the features that are available for a ContextGroup. 24 class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { 25 public: 26 struct FeatureFlags { 27 FeatureFlags(); 28 29 bool chromium_framebuffer_multisample; 30 // Use glBlitFramebuffer() and glRenderbufferStorageMultisample() with 31 // GL_EXT_framebuffer_multisample-style semantics, since they are exposed 32 // as core GL functions on this implementation. 33 bool use_core_framebuffer_multisample; 34 bool multisampled_render_to_texture; 35 // Use the IMG GLenum values and functions rather than EXT. 36 bool use_img_for_multisampled_render_to_texture; 37 bool oes_standard_derivatives; 38 bool oes_egl_image_external; 39 bool oes_depth24; 40 bool oes_compressed_etc1_rgb8_texture; 41 bool packed_depth24_stencil8; 42 bool npot_ok; 43 bool enable_texture_float_linear; 44 bool enable_texture_half_float_linear; 45 bool chromium_stream_texture; 46 bool angle_translated_shader_source; 47 bool angle_pack_reverse_row_order; 48 bool arb_texture_rectangle; 49 bool angle_instanced_arrays; 50 bool occlusion_query_boolean; 51 bool use_arb_occlusion_query2_for_occlusion_query_boolean; 52 bool use_arb_occlusion_query_for_occlusion_query_boolean; 53 bool native_vertex_array_object; 54 bool ext_texture_format_bgra8888; 55 bool enable_shader_name_hashing; 56 bool enable_samplers; 57 bool ext_draw_buffers; 58 bool ext_frag_depth; 59 bool use_async_readpixels; 60 bool map_buffer_range; 61 bool ext_discard_framebuffer; 62 bool angle_depth_texture; 63 bool is_angle; 64 bool is_swiftshader; 65 bool angle_texture_usage; 66 bool ext_texture_storage; 67 }; 68 69 struct Workarounds { 70 Workarounds(); 71 72 #define GPU_OP(type, name) bool name; 73 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) 74 #undef GPU_OP 75 76 // Note: 0 here means use driver limit. 77 GLint max_texture_size; 78 GLint max_cube_map_texture_size; 79 }; 80 81 // Constructor with workarounds taken from the current process's CommandLine 82 FeatureInfo(); 83 84 // Constructor with workarounds taken from |command_line| 85 FeatureInfo(const CommandLine& command_line); 86 87 // Initializes the feature information. Needs a current GL context. 88 bool Initialize(); 89 bool Initialize(const DisallowedFeatures& disallowed_features); 90 91 const Validators* validators() const { 92 return &validators_; 93 } 94 95 const ValueValidator<GLenum>& GetTextureFormatValidator(GLenum format) { 96 return texture_format_validators_[format]; 97 } 98 99 const std::string& extensions() const { 100 return extensions_; 101 } 102 103 const FeatureFlags& feature_flags() const { 104 return feature_flags_; 105 } 106 107 const Workarounds& workarounds() const { 108 return workarounds_; 109 } 110 111 private: 112 friend class base::RefCounted<FeatureInfo>; 113 friend class BufferManagerClientSideArraysTest; 114 friend class GLES2DecoderTestBase; 115 116 typedef base::hash_map<GLenum, ValueValidator<GLenum> > ValidatorMap; 117 ValidatorMap texture_format_validators_; 118 119 ~FeatureInfo(); 120 121 void AddExtensionString(const std::string& str); 122 void InitializeBasicState(const CommandLine& command_line); 123 void InitializeFeatures(); 124 125 Validators validators_; 126 127 DisallowedFeatures disallowed_features_; 128 129 // The extensions string returned by glGetString(GL_EXTENSIONS); 130 std::string extensions_; 131 132 // Flags for some features 133 FeatureFlags feature_flags_; 134 135 // Flags for Workarounds. 136 Workarounds workarounds_; 137 138 DISALLOW_COPY_AND_ASSIGN(FeatureInfo); 139 }; 140 141 } // namespace gles2 142 } // namespace gpu 143 144 #endif // GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_ 145