Home | History | Annotate | Download | only in service
      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     bool multisampled_render_to_texture;
     31     // Use the IMG GLenum values and functions rather than EXT.
     32     bool use_img_for_multisampled_render_to_texture;
     33     bool oes_standard_derivatives;
     34     bool oes_egl_image_external;
     35     bool npot_ok;
     36     bool enable_texture_float_linear;
     37     bool enable_texture_half_float_linear;
     38     bool chromium_stream_texture;
     39     bool angle_translated_shader_source;
     40     bool angle_pack_reverse_row_order;
     41     bool arb_texture_rectangle;
     42     bool angle_instanced_arrays;
     43     bool occlusion_query_boolean;
     44     bool use_arb_occlusion_query2_for_occlusion_query_boolean;
     45     bool use_arb_occlusion_query_for_occlusion_query_boolean;
     46     bool native_vertex_array_object;
     47     bool enable_shader_name_hashing;
     48     bool enable_samplers;
     49     bool ext_draw_buffers;
     50     bool ext_frag_depth;
     51     bool use_async_readpixels;
     52   };
     53 
     54   struct Workarounds {
     55     Workarounds();
     56 
     57 #define GPU_OP(type, name) bool name;
     58     GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
     59 #undef GPU_OP
     60 
     61     // Note: 0 here means use driver limit.
     62     GLint max_texture_size;
     63     GLint max_cube_map_texture_size;
     64   };
     65 
     66   FeatureInfo();
     67 
     68   // If allowed features = NULL or "*", all features are allowed. Otherwise
     69   // only features that match the strings in allowed_features are allowed.
     70   bool Initialize(const char* allowed_features);
     71   bool Initialize(const DisallowedFeatures& disallowed_features,
     72                   const char* allowed_features);
     73 
     74   // Turns on certain features if they can be turned on.
     75   void AddFeatures(const CommandLine& command_line);
     76 
     77   const Validators* validators() const {
     78     return &validators_;
     79   }
     80 
     81   const ValueValidator<GLenum>& GetTextureFormatValidator(GLenum format) {
     82     return texture_format_validators_[format];
     83   }
     84 
     85   const std::string& extensions() const {
     86     return extensions_;
     87   }
     88 
     89   const FeatureFlags& feature_flags() const {
     90     return feature_flags_;
     91   }
     92 
     93   const Workarounds& workarounds() const {
     94     return workarounds_;
     95   }
     96 
     97  private:
     98   friend class base::RefCounted<FeatureInfo>;
     99   friend class BufferManagerClientSideArraysTest;
    100   friend class GLES2DecoderTestBase;
    101 
    102   typedef base::hash_map<GLenum, ValueValidator<GLenum> > ValidatorMap;
    103   ValidatorMap texture_format_validators_;
    104 
    105   ~FeatureInfo();
    106 
    107   void AddExtensionString(const std::string& str);
    108 
    109   Validators validators_;
    110 
    111   DisallowedFeatures disallowed_features_;
    112 
    113   // The extensions string returned by glGetString(GL_EXTENSIONS);
    114   std::string extensions_;
    115 
    116   // Flags for some features
    117   FeatureFlags feature_flags_;
    118 
    119   // Flags for Workarounds.
    120   Workarounds workarounds_;
    121 
    122   DISALLOW_COPY_AND_ASSIGN(FeatureInfo);
    123 };
    124 
    125 }  // namespace gles2
    126 }  // namespace gpu
    127 
    128 #endif  // GPU_COMMAND_BUFFER_SERVICE_FEATURE_INFO_H_
    129