Merge "Add Vulkan assets to apk when building for Android CTS." into nyc-dev
[platform/upstream/VK-GL-CTS.git] / framework / opengl / gluContextInfo.hpp
1 #ifndef _GLUCONTEXTINFO_HPP
2 #define _GLUCONTEXTINFO_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program OpenGL ES Utilities
5  * ------------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Context Info Class.
24  *//*--------------------------------------------------------------------*/
25
26 #include "gluDefs.hpp"
27
28 #include <vector>
29 #include <string>
30 #include <set>
31
32 namespace glu
33 {
34
35 class RenderContext;
36
37 template <typename T, class ComputeValue>
38 class CachedValue
39 {
40 public:
41         CachedValue (ComputeValue compute = ComputeValue(), const T& defaultValue = T())
42                 : m_compute             (compute)
43                 , m_value               (defaultValue)
44                 , m_isComputed  (false)
45         {
46         }
47
48         const T& getValue (const RenderContext& context) const
49         {
50                 if (!m_isComputed)
51                 {
52                         m_value                 = m_compute(context);
53                         m_isComputed    = true;
54                 }
55                 return m_value;
56         }
57
58 private:
59         ComputeValue    m_compute;
60         mutable T               m_value;
61         mutable bool    m_isComputed;
62 };
63
64 class GetCompressedTextureFormats
65 {
66 public:
67         std::set<int> operator() (const RenderContext& context) const;
68 };
69
70 typedef CachedValue<std::set<int>, GetCompressedTextureFormats> CompressedTextureFormats;
71
72 /*--------------------------------------------------------------------*//*!
73  * \brief Context information & limit query.
74  *//*--------------------------------------------------------------------*/
75 class ContextInfo
76 {
77 public:
78         virtual                                                                         ~ContextInfo                                            (void);
79
80         virtual int                                                                     getInt                                                          (int param) const;
81         virtual bool                                                            getBool                                                         (int param) const;
82         virtual const char*                                                     getString                                                       (int param) const;
83
84         virtual bool                                                            isVertexUniformLoopSupported            (void) const { return true; }
85         virtual bool                                                            isVertexDynamicLoopSupported            (void) const { return true; }
86         virtual bool                                                            isFragmentHighPrecisionSupported        (void) const { return true; }
87         virtual bool                                                            isFragmentUniformLoopSupported          (void) const { return true; }
88         virtual bool                                                            isFragmentDynamicLoopSupported          (void) const { return true; }
89
90         virtual bool                                                            isCompressedTextureFormatSupported      (int format) const;
91
92         const std::vector<std::string>&                         getExtensions                                           (void) const { return m_extensions; }
93         bool                                                                            isExtensionSupported                            (const char* extName) const;
94
95         static ContextInfo*                                                     create                                                          (const RenderContext& context);
96
97 protected:
98                                                                                                 ContextInfo                                                     (const RenderContext& context);
99
100         const RenderContext&                                            m_context;
101
102 private:
103                                                                                                 ContextInfo                                                     (const ContextInfo& other);
104         ContextInfo&                                                            operator=                                                       (const ContextInfo& other);
105
106         std::vector<std::string>                                        m_extensions;
107         CompressedTextureFormats                                        m_compressedTextureFormats;
108 };
109
110 } // glu
111
112 #endif // _GLUCONTEXTINFO_HPP