Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / gpu / command_buffer / service / feature_info.h
blob4a55c958fe468b0b50f0b0599b06e236c75e88ef
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 <string>
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
13 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
14 #include "gpu/config/gpu_driver_bug_workaround_type.h"
15 #include "gpu/gpu_export.h"
17 namespace base {
18 class CommandLine;
21 namespace gfx {
22 struct GLVersionInfo;
25 namespace gpu {
26 namespace gles2 {
28 // FeatureInfo records the features that are available for a ContextGroup.
29 class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
30 public:
31 struct FeatureFlags {
32 FeatureFlags();
34 bool chromium_color_buffer_float_rgba;
35 bool chromium_color_buffer_float_rgb;
36 bool chromium_framebuffer_multisample;
37 bool chromium_sync_query;
38 // Use glBlitFramebuffer() and glRenderbufferStorageMultisample() with
39 // GL_EXT_framebuffer_multisample-style semantics, since they are exposed
40 // as core GL functions on this implementation.
41 bool use_core_framebuffer_multisample;
42 bool multisampled_render_to_texture;
43 // Use the IMG GLenum values and functions rather than EXT.
44 bool use_img_for_multisampled_render_to_texture;
45 bool oes_standard_derivatives;
46 bool oes_egl_image_external;
47 bool oes_depth24;
48 bool oes_compressed_etc1_rgb8_texture;
49 bool packed_depth24_stencil8;
50 bool npot_ok;
51 bool enable_texture_float_linear;
52 bool enable_texture_half_float_linear;
53 bool angle_translated_shader_source;
54 bool angle_pack_reverse_row_order;
55 bool arb_texture_rectangle;
56 bool angle_instanced_arrays;
57 bool occlusion_query_boolean;
58 bool use_arb_occlusion_query2_for_occlusion_query_boolean;
59 bool use_arb_occlusion_query_for_occlusion_query_boolean;
60 bool native_vertex_array_object;
61 bool ext_texture_format_atc;
62 bool ext_texture_format_bgra8888;
63 bool ext_texture_format_dxt1;
64 bool ext_texture_format_dxt5;
65 bool enable_shader_name_hashing;
66 bool enable_samplers;
67 bool ext_draw_buffers;
68 bool nv_draw_buffers;
69 bool ext_frag_depth;
70 bool ext_shader_texture_lod;
71 bool use_async_readpixels;
72 bool map_buffer_range;
73 bool ext_discard_framebuffer;
74 bool angle_depth_texture;
75 bool is_swiftshader;
76 bool angle_texture_usage;
77 bool ext_texture_storage;
78 bool chromium_path_rendering;
79 bool blend_equation_advanced;
80 bool blend_equation_advanced_coherent;
81 bool ext_texture_rg;
82 bool enable_subscribe_uniform;
83 bool emulate_primitive_restart_fixed_index;
84 bool ext_render_buffer_format_bgra8888;
87 struct Workarounds {
88 Workarounds();
90 #define GPU_OP(type, name) bool name;
91 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
92 #undef GPU_OP
94 // Note: 0 here means use driver limit.
95 GLint max_texture_size;
96 GLint max_cube_map_texture_size;
97 GLint max_fragment_uniform_vectors;
98 GLint max_varying_vectors;
99 GLint max_vertex_uniform_vectors;
100 GLint max_copy_texture_chromium_size;
103 // Constructor with workarounds taken from the current process's CommandLine
104 FeatureInfo();
106 // Constructor with workarounds taken from |command_line|
107 FeatureInfo(const base::CommandLine& command_line);
109 // Initializes the feature information. Needs a current GL context.
110 bool Initialize();
111 bool Initialize(const DisallowedFeatures& disallowed_features);
113 const Validators* validators() const {
114 return &validators_;
117 const std::string& extensions() const {
118 return extensions_;
121 const FeatureFlags& feature_flags() const {
122 return feature_flags_;
125 const Workarounds& workarounds() const {
126 return workarounds_;
129 const gfx::GLVersionInfo& gl_version_info() const {
130 DCHECK(gl_version_info_.get());
131 return *(gl_version_info_.get());
134 bool IsES3Capable() const;
135 void EnableES3Validators();
137 bool IsES3Enabled() const {
138 return unsafe_es3_apis_enabled_;
141 private:
142 friend class base::RefCounted<FeatureInfo>;
143 friend class BufferManagerClientSideArraysTest;
145 ~FeatureInfo();
147 void AddExtensionString(const char* s);
148 void InitializeBasicState(const base::CommandLine* command_line);
149 void InitializeFeatures();
151 Validators validators_;
153 DisallowedFeatures disallowed_features_;
155 // The extensions string returned by glGetString(GL_EXTENSIONS);
156 std::string extensions_;
158 // Flags for some features
159 FeatureFlags feature_flags_;
161 // Flags for Workarounds.
162 Workarounds workarounds_;
164 // Whether the command line switch kEnableUnsafeES3APIs is passed in.
165 bool enable_unsafe_es3_apis_switch_;
167 bool unsafe_es3_apis_enabled_;
169 // Whether the command line switch kEnableGLPathRendering is passed in.
170 bool enable_gl_path_rendering_switch_;
172 scoped_ptr<gfx::GLVersionInfo> gl_version_info_;
174 DISALLOW_COPY_AND_ASSIGN(FeatureInfo);
177 } // namespace gles2
178 } // namespace gpu
180 #endif // GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_