1 #ifndef LIBGLESV2_CAPS_H 2 #define LIBGLESV2_CAPS_H 3 4 // 5 // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. 6 // Use of this source code is governed by a BSD-style license that can be 7 // found in the LICENSE file. 8 // 9 10 #include "angle_gl.h" 11 12 #include <set> 13 #include <unordered_map> 14 #include <vector> 15 #include <string> 16 17 namespace gl 18 { 19 20 typedef std::set<GLuint> SupportedSampleSet; 21 22 struct TextureCaps 23 { 24 TextureCaps(); 25 26 // Supports for basic texturing: glTexImage, glTexSubImage, etc 27 bool texturable; 28 29 // Support for linear or anisotropic filtering 30 bool filterable; 31 32 // Support for being used as a framebuffer attachment or renderbuffer format 33 bool renderable; 34 35 SupportedSampleSet sampleCounts; 36 37 // Get the maximum number of samples supported 38 GLuint getMaxSamples() const; 39 40 // Get the number of supported samples that is at least as many as requested. Returns 0 if 41 // there are no sample counts available 42 GLuint getNearestSamples(GLuint requestedSamples) const; 43 }; 44 45 class TextureCapsMap 46 { 47 public: 48 typedef std::unordered_map<GLenum, TextureCaps>::const_iterator const_iterator; 49 50 void insert(GLenum internalFormat, const TextureCaps &caps); 51 void remove(GLenum internalFormat); 52 53 const TextureCaps &get(GLenum internalFormat) const; 54 55 const_iterator begin() const; 56 const_iterator end() const; 57 58 size_t size() const; 59 60 private: 61 typedef std::unordered_map<GLenum, TextureCaps> InternalFormatToCapsMap; 62 InternalFormatToCapsMap mCapsMap; 63 }; 64 65 struct Extensions 66 { 67 Extensions(); 68 69 // Generate a vector of supported extension strings 70 std::vector<std::string> getStrings() const; 71 72 // Set all texture related extension support based on the supported textures. 73 // Determines support for: 74 // GL_OES_rgb8_rgba8 75 // GL_EXT_texture_format_BGRA8888 76 // GL_OES_texture_half_float, GL_OES_texture_half_float_linear 77 // GL_OES_texture_float, GL_OES_texture_float_linear 78 // GL_EXT_texture_rg 79 // GL_EXT_texture_compression_dxt1, GL_ANGLE_texture_compression_dxt3, GL_ANGLE_texture_compression_dxt5 80 // GL_EXT_sRGB 81 // GL_ANGLE_depth_texture 82 // GL_EXT_color_buffer_float 83 void setTextureExtensionSupport(const TextureCapsMap &textureCaps); 84 85 // ES2 Extension support 86 87 // GL_OES_element_index_uint 88 bool elementIndexUint; 89 90 // GL_OES_packed_depth_stencil 91 bool packedDepthStencil; 92 93 // GL_OES_get_program_binary 94 bool getProgramBinary; 95 96 // GL_OES_rgb8_rgba8 97 // Implies that TextureCaps for GL_RGB8 and GL_RGBA8 exist 98 bool rgb8rgba8; 99 100 // GL_EXT_texture_format_BGRA8888 101 // Implies that TextureCaps for GL_BGRA8 exist 102 bool textureFormatBGRA8888; 103 104 // GL_EXT_read_format_bgra 105 bool readFormatBGRA; 106 107 // GL_NV_pixel_buffer_object 108 bool pixelBufferObject; 109 110 // GL_OES_mapbuffer and GL_EXT_map_buffer_range 111 bool mapBuffer; 112 bool mapBufferRange; 113 114 // GL_OES_texture_half_float and GL_OES_texture_half_float_linear 115 // Implies that TextureCaps for GL_RGB16F, GL_RGBA16F, GL_ALPHA32F_EXT, GL_LUMINANCE32F_EXT and 116 // GL_LUMINANCE_ALPHA32F_EXT exist 117 bool textureHalfFloat; 118 bool textureHalfFloatLinear; 119 120 // GL_OES_texture_float and GL_OES_texture_float_linear 121 // Implies that TextureCaps for GL_RGB32F, GL_RGBA32F, GL_ALPHA16F_EXT, GL_LUMINANCE16F_EXT and 122 // GL_LUMINANCE_ALPHA16F_EXT exist 123 bool textureFloat; 124 bool textureFloatLinear; 125 126 // GL_EXT_texture_rg 127 // Implies that TextureCaps for GL_R8, GL_RG8 (and floating point R/RG texture formats if floating point extensions 128 // are also present) exist 129 bool textureRG; 130 131 // GL_EXT_texture_compression_dxt1, GL_ANGLE_texture_compression_dxt3 and GL_ANGLE_texture_compression_dxt5 132 // Implies that TextureCaps for GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 133 // GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE and GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 134 bool textureCompressionDXT1; 135 bool textureCompressionDXT3; 136 bool textureCompressionDXT5; 137 138 // GL_EXT_sRGB 139 // Implies that TextureCaps for GL_SRGB8_ALPHA8 and GL_SRGB8 exist 140 // TODO: Don't advertise this extension in ES3 141 bool sRGB; 142 143 // GL_ANGLE_depth_texture 144 bool depthTextures; 145 146 // GL_EXT_texture_storage 147 bool textureStorage; 148 149 // GL_OES_texture_npot 150 bool textureNPOT; 151 152 // GL_EXT_draw_buffers 153 bool drawBuffers; 154 155 // GL_EXT_texture_filter_anisotropic 156 bool textureFilterAnisotropic; 157 GLfloat maxTextureAnisotropy; 158 159 // GL_EXT_occlusion_query_boolean 160 bool occlusionQueryBoolean; 161 162 // GL_NV_fence 163 bool fence; 164 165 // GL_ANGLE_timer_query 166 bool timerQuery; 167 168 // GL_EXT_robustness 169 bool robustness; 170 171 // GL_EXT_blend_minmax 172 bool blendMinMax; 173 174 // GL_ANGLE_framebuffer_blit 175 bool framebufferBlit; 176 177 // GL_ANGLE_framebuffer_multisample 178 bool framebufferMultisample; 179 GLuint maxSamples; 180 181 // GL_ANGLE_instanced_arrays 182 bool instancedArrays; 183 184 // GL_ANGLE_pack_reverse_row_order 185 bool packReverseRowOrder; 186 187 // GL_OES_standard_derivatives 188 bool standardDerivatives; 189 190 // GL_EXT_shader_texture_lod 191 bool shaderTextureLOD; 192 193 // GL_EXT_frag_depth 194 bool fragDepth; 195 196 // GL_ANGLE_texture_usage 197 bool textureUsage; 198 199 // GL_ANGLE_translated_shader_source 200 bool translatedShaderSource; 201 202 // ES3 Extension support 203 204 // GL_EXT_color_buffer_float 205 bool colorBufferFloat; 206 }; 207 208 struct Caps 209 { 210 Caps(); 211 212 // Table 6.28, implementation dependent values 213 GLuint64 maxElementIndex; 214 GLuint max3DTextureSize; 215 GLuint max2DTextureSize; 216 GLuint maxArrayTextureLayers; 217 GLfloat maxLODBias; 218 GLuint maxCubeMapTextureSize; 219 GLuint maxRenderbufferSize; 220 GLuint maxDrawBuffers; 221 GLuint maxColorAttachments; 222 GLuint maxViewportWidth; 223 GLuint maxViewportHeight; 224 GLfloat minAliasedPointSize; 225 GLfloat maxAliasedPointSize; 226 GLfloat minAliasedLineWidth; 227 GLfloat maxAliasedLineWidth; 228 229 // Table 6.29, implementation dependent values (cont.) 230 GLuint maxElementsIndices; 231 GLuint maxElementsVertices; 232 std::vector<GLenum> compressedTextureFormats; 233 std::vector<GLenum> programBinaryFormats; 234 std::vector<GLenum> shaderBinaryFormats; 235 GLuint64 maxServerWaitTimeout; 236 237 // Table 6.31, implementation dependent vertex shader limits 238 GLuint maxVertexAttributes; 239 GLuint maxVertexUniformComponents; 240 GLuint maxVertexUniformVectors; 241 GLuint maxVertexUniformBlocks; 242 GLuint maxVertexOutputComponents; 243 GLuint maxVertexTextureImageUnits; 244 245 // Table 6.32, implementation dependent fragment shader limits 246 GLuint maxFragmentUniformComponents; 247 GLuint maxFragmentUniformVectors; 248 GLuint maxFragmentUniformBlocks; 249 GLuint maxFragmentInputComponents; 250 GLuint maxTextureImageUnits; 251 GLint minProgramTexelOffset; 252 GLint maxProgramTexelOffset; 253 254 // Table 6.33, implementation dependent aggregate shader limits 255 GLuint maxUniformBufferBindings; 256 GLuint64 maxUniformBlockSize; 257 GLuint uniformBufferOffsetAlignment; 258 GLuint maxCombinedUniformBlocks; 259 GLuint64 maxCombinedVertexUniformComponents; 260 GLuint64 maxCombinedFragmentUniformComponents; 261 GLuint maxVaryingComponents; 262 GLuint maxVaryingVectors; 263 GLuint maxCombinedTextureImageUnits; 264 265 // Table 6.34, implementation dependent transform feedback limits 266 GLuint maxTransformFeedbackInterleavedComponents; 267 GLuint maxTransformFeedbackSeparateAttributes; 268 GLuint maxTransformFeedbackSeparateComponents; 269 }; 270 271 } 272 273 #endif // LIBGLESV2_CAPS_H 274