James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 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" |
James Robinson | d2015d9 | 2014-12-08 13:45:40 -0800 | [diff] [blame] | 17 | #include "ui/gl/gl_version_info.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 18 | |
| 19 | namespace base { |
| 20 | class CommandLine; |
| 21 | } |
| 22 | |
| 23 | namespace gpu { |
| 24 | namespace gles2 { |
| 25 | |
| 26 | // FeatureInfo records the features that are available for a ContextGroup. |
| 27 | class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { |
| 28 | public: |
| 29 | struct FeatureFlags { |
| 30 | FeatureFlags(); |
| 31 | |
| 32 | bool chromium_color_buffer_float_rgba; |
| 33 | bool chromium_color_buffer_float_rgb; |
| 34 | bool chromium_framebuffer_multisample; |
| 35 | bool chromium_sync_query; |
| 36 | // Use glBlitFramebuffer() and glRenderbufferStorageMultisample() with |
| 37 | // GL_EXT_framebuffer_multisample-style semantics, since they are exposed |
| 38 | // as core GL functions on this implementation. |
| 39 | bool use_core_framebuffer_multisample; |
| 40 | bool multisampled_render_to_texture; |
| 41 | // Use the IMG GLenum values and functions rather than EXT. |
| 42 | bool use_img_for_multisampled_render_to_texture; |
| 43 | bool oes_standard_derivatives; |
| 44 | bool oes_egl_image_external; |
| 45 | bool oes_depth24; |
| 46 | bool oes_compressed_etc1_rgb8_texture; |
| 47 | bool packed_depth24_stencil8; |
| 48 | bool npot_ok; |
| 49 | bool enable_texture_float_linear; |
| 50 | bool enable_texture_half_float_linear; |
| 51 | bool angle_translated_shader_source; |
| 52 | bool angle_pack_reverse_row_order; |
| 53 | bool arb_texture_rectangle; |
| 54 | bool angle_instanced_arrays; |
| 55 | bool occlusion_query_boolean; |
| 56 | bool use_arb_occlusion_query2_for_occlusion_query_boolean; |
| 57 | bool use_arb_occlusion_query_for_occlusion_query_boolean; |
| 58 | bool native_vertex_array_object; |
| 59 | bool ext_texture_format_bgra8888; |
| 60 | bool enable_shader_name_hashing; |
| 61 | bool enable_samplers; |
| 62 | bool ext_draw_buffers; |
James Robinson | e2ac7e8 | 2014-10-15 13:21:59 -0700 | [diff] [blame] | 63 | bool nv_draw_buffers; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 64 | bool ext_frag_depth; |
| 65 | bool ext_shader_texture_lod; |
| 66 | bool use_async_readpixels; |
| 67 | bool map_buffer_range; |
| 68 | bool ext_discard_framebuffer; |
| 69 | bool angle_depth_texture; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 70 | bool is_swiftshader; |
| 71 | bool angle_texture_usage; |
| 72 | bool ext_texture_storage; |
| 73 | bool chromium_path_rendering; |
James Robinson | 30d547e | 2014-10-23 18:20:06 -0700 | [diff] [blame] | 74 | bool blend_equation_advanced; |
| 75 | bool blend_equation_advanced_coherent; |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 76 | bool ext_texture_rg; |
| 77 | bool enable_subscribe_uniform; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | struct Workarounds { |
| 81 | Workarounds(); |
| 82 | |
| 83 | #define GPU_OP(type, name) bool name; |
| 84 | GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) |
| 85 | #undef GPU_OP |
| 86 | |
| 87 | // Note: 0 here means use driver limit. |
| 88 | GLint max_texture_size; |
| 89 | GLint max_cube_map_texture_size; |
| 90 | GLint max_fragment_uniform_vectors; |
| 91 | GLint max_varying_vectors; |
| 92 | GLint max_vertex_uniform_vectors; |
| 93 | }; |
| 94 | |
| 95 | // Constructor with workarounds taken from the current process's CommandLine |
| 96 | FeatureInfo(); |
| 97 | |
| 98 | // Constructor with workarounds taken from |command_line| |
| 99 | FeatureInfo(const base::CommandLine& command_line); |
| 100 | |
| 101 | // Initializes the feature information. Needs a current GL context. |
| 102 | bool Initialize(); |
| 103 | bool Initialize(const DisallowedFeatures& disallowed_features); |
| 104 | |
| 105 | const Validators* validators() const { |
| 106 | return &validators_; |
| 107 | } |
| 108 | |
| 109 | const ValueValidator<GLenum>& GetTextureFormatValidator(GLenum format) { |
| 110 | return texture_format_validators_[format]; |
| 111 | } |
| 112 | |
| 113 | const std::string& extensions() const { |
| 114 | return extensions_; |
| 115 | } |
| 116 | |
| 117 | const FeatureFlags& feature_flags() const { |
| 118 | return feature_flags_; |
| 119 | } |
| 120 | |
| 121 | const Workarounds& workarounds() const { |
| 122 | return workarounds_; |
| 123 | } |
| 124 | |
James Robinson | d2015d9 | 2014-12-08 13:45:40 -0800 | [diff] [blame] | 125 | const gfx::GLVersionInfo& gl_version_info() const { |
| 126 | CHECK(gl_version_info_.get()); |
| 127 | return *(gl_version_info_.get()); |
| 128 | } |
| 129 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 130 | private: |
| 131 | friend class base::RefCounted<FeatureInfo>; |
| 132 | friend class BufferManagerClientSideArraysTest; |
| 133 | |
| 134 | typedef base::hash_map<GLenum, ValueValidator<GLenum> > ValidatorMap; |
| 135 | ValidatorMap texture_format_validators_; |
| 136 | |
| 137 | ~FeatureInfo(); |
| 138 | |
| 139 | void AddExtensionString(const char* s); |
| 140 | void InitializeBasicState(const base::CommandLine& command_line); |
| 141 | void InitializeFeatures(); |
| 142 | |
| 143 | Validators validators_; |
| 144 | |
| 145 | DisallowedFeatures disallowed_features_; |
| 146 | |
| 147 | // The extensions string returned by glGetString(GL_EXTENSIONS); |
| 148 | std::string extensions_; |
| 149 | |
| 150 | // Flags for some features |
| 151 | FeatureFlags feature_flags_; |
| 152 | |
| 153 | // Flags for Workarounds. |
| 154 | Workarounds workarounds_; |
| 155 | |
James Robinson | d2015d9 | 2014-12-08 13:45:40 -0800 | [diff] [blame] | 156 | scoped_ptr<gfx::GLVersionInfo> gl_version_info_; |
| 157 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 158 | DISALLOW_COPY_AND_ASSIGN(FeatureInfo); |
| 159 | }; |
| 160 | |
| 161 | } // namespace gles2 |
| 162 | } // namespace gpu |
| 163 | |
| 164 | #endif // GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_ |