Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / command_buffer / service / feature_info.h
blobaa9c0ba83134c79fa9234603c1a93f379f041755
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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_
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 #include "ui/gl/gl_version_info.h"
19 namespace base {
20 class CommandLine;
23 namespace gpu {
24 namespace gles2 {
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();
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_atc;
60 bool ext_texture_format_bgra8888;
61 bool ext_texture_format_dxt1;
62 bool ext_texture_format_dxt5;
63 bool enable_shader_name_hashing;
64 bool enable_samplers;
65 bool ext_draw_buffers;
66 bool nv_draw_buffers;
67 bool ext_frag_depth;
68 bool ext_shader_texture_lod;
69 bool use_async_readpixels;
70 bool map_buffer_range;
71 bool ext_discard_framebuffer;
72 bool angle_depth_texture;
73 bool is_swiftshader;
74 bool angle_texture_usage;
75 bool ext_texture_storage;
76 bool chromium_path_rendering;
77 bool blend_equation_advanced;
78 bool blend_equation_advanced_coherent;
79 bool ext_texture_rg;
80 bool enable_subscribe_uniform;
81 bool emulate_primitive_restart_fixed_index;
82 bool ext_render_buffer_format_bgra8888;
85 struct Workarounds {
86 Workarounds();
88 #define GPU_OP(type, name) bool name;
89 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
90 #undef GPU_OP
92 // Note: 0 here means use driver limit.
93 GLint max_texture_size;
94 GLint max_cube_map_texture_size;
95 GLint max_fragment_uniform_vectors;
96 GLint max_varying_vectors;
97 GLint max_vertex_uniform_vectors;
98 GLint max_copy_texture_chromium_size;
101 // Constructor with workarounds taken from the current process's CommandLine
102 FeatureInfo();
104 // Constructor with workarounds taken from |command_line|
105 FeatureInfo(const base::CommandLine& command_line);
107 // Initializes the feature information. Needs a current GL context.
108 bool Initialize();
109 bool Initialize(const DisallowedFeatures& disallowed_features);
111 const Validators* validators() const {
112 return &validators_;
115 const std::string& extensions() const {
116 return extensions_;
119 const FeatureFlags& feature_flags() const {
120 return feature_flags_;
123 const Workarounds& workarounds() const {
124 return workarounds_;
127 const gfx::GLVersionInfo& gl_version_info() const {
128 DCHECK(gl_version_info_.get());
129 return *(gl_version_info_.get());
132 bool IsES3Capable() const;
133 void EnableES3Validators();
135 bool IsES3Enabled() const {
136 return unsafe_es3_apis_enabled_;
139 private:
140 friend class base::RefCounted<FeatureInfo>;
141 friend class BufferManagerClientSideArraysTest;
143 ~FeatureInfo();
145 void AddExtensionString(const char* s);
146 void InitializeBasicState(const base::CommandLine& command_line);
147 void InitializeFeatures();
149 Validators validators_;
151 DisallowedFeatures disallowed_features_;
153 // The extensions string returned by glGetString(GL_EXTENSIONS);
154 std::string extensions_;
156 // Flags for some features
157 FeatureFlags feature_flags_;
159 // Flags for Workarounds.
160 Workarounds workarounds_;
162 // Whether the command line switch kEnableUnsafeES3APIs is passed in.
163 bool enable_unsafe_es3_apis_switch_;
165 bool unsafe_es3_apis_enabled_;
167 // Whether the command line switch kEnableGLPathRendering is passed in.
168 bool enable_gl_path_rendering_switch_;
170 scoped_ptr<gfx::GLVersionInfo> gl_version_info_;
172 DISALLOW_COPY_AND_ASSIGN(FeatureInfo);
175 } // namespace gles2
176 } // namespace gpu
178 #endif // GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_