2013-08-03 01:30:58 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "nsPrintfCString.h"
|
|
|
|
|
2013-12-03 22:44:38 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "nsCocoaFeatures.h"
|
|
|
|
#endif
|
|
|
|
|
2013-08-03 01:30:58 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
const size_t kMAX_EXTENSION_GROUP_SIZE = 5;
|
|
|
|
|
2013-08-15 23:58:20 +04:00
|
|
|
// ARB_ES2_compatibility is natively supported in OpenGL 4.1.
|
|
|
|
static const unsigned int kGLCoreVersionForES2Compat = 410;
|
|
|
|
|
|
|
|
// ARB_ES3_compatibility is natively supported in OpenGL 4.3.
|
|
|
|
static const unsigned int kGLCoreVersionForES3Compat = 430;
|
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
struct FeatureInfo
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
const char* mName;
|
2014-05-14 04:18:42 +04:00
|
|
|
|
|
|
|
/* The (desktop) OpenGL version that provides this feature */
|
2013-08-03 01:30:58 +04:00
|
|
|
unsigned int mOpenGLVersion;
|
2014-05-14 04:18:42 +04:00
|
|
|
|
|
|
|
/* The OpenGL ES version that provides this feature */
|
2013-08-03 01:30:58 +04:00
|
|
|
unsigned int mOpenGLESVersion;
|
2014-05-14 04:18:42 +04:00
|
|
|
|
|
|
|
/* If there is an ARB extension, and its function symbols are
|
|
|
|
* not decorated with an ARB suffix, then its extension ID should go
|
|
|
|
* here, and NOT in mExtensions. For example, ARB_vertex_array_object
|
|
|
|
* functions do not have an ARB suffix, because it is an extension that
|
|
|
|
* was created to match core GL functionality and will never differ.
|
|
|
|
* Some ARB extensions do have a suffix, if they were created before
|
|
|
|
* a core version of the functionality existed.
|
|
|
|
*
|
|
|
|
* If there is no such ARB extension, pass 0 (GLContext::Extension_None)
|
|
|
|
*/
|
|
|
|
GLContext::GLExtensions mARBExtensionWithoutARBSuffix;
|
|
|
|
|
|
|
|
/* Extensions that also provide this feature */
|
2013-08-03 01:30:58 +04:00
|
|
|
GLContext::GLExtensions mExtensions[kMAX_EXTENSION_GROUP_SIZE];
|
|
|
|
};
|
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
static const FeatureInfo sFeatureInfoArr[] = {
|
2013-08-20 19:36:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"bind_buffer_offset",
|
2013-08-20 19:36:20 +04:00
|
|
|
0, // OpenGL version
|
|
|
|
0, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-20 19:36:20 +04:00
|
|
|
{
|
2014-05-14 04:18:42 +04:00
|
|
|
|
2013-08-20 19:36:20 +04:00
|
|
|
GLContext::EXT_transform_feedback,
|
|
|
|
GLContext::NV_transform_feedback,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-27 01:12:54 +04:00
|
|
|
{
|
|
|
|
"blend_minmax",
|
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-27 01:12:54 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_blend_minmax,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-09-18 04:17:00 +04:00
|
|
|
{
|
|
|
|
"clear_buffers",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::Extension_None,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-05-27 14:13:09 +04:00
|
|
|
{
|
|
|
|
"copy_buffer",
|
|
|
|
310, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::ARB_copy_buffer,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"depth_texture",
|
2013-08-15 23:58:20 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_depth_texture,
|
|
|
|
GLContext::OES_depth_texture,
|
2013-10-01 04:58:57 +04:00
|
|
|
// Intentionally avoid putting ANGLE_depth_texture here,
|
|
|
|
// it does not offer quite the same functionality.
|
2013-08-15 23:58:20 +04:00
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"draw_buffers",
|
2013-08-03 01:30:58 +04:00
|
|
|
200, // OpenGL version
|
2014-09-02 18:57:55 +04:00
|
|
|
0, // Only enable when we have the extension on ES, bug 1056947
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_draw_buffers,
|
|
|
|
GLContext::EXT_draw_buffers,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"draw_instanced",
|
2013-08-03 01:30:58 +04:00
|
|
|
310, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_draw_instanced,
|
|
|
|
GLContext::EXT_draw_instanced,
|
|
|
|
GLContext::NV_draw_instanced,
|
2013-08-07 04:05:51 +04:00
|
|
|
GLContext::ANGLE_instanced_arrays,
|
2013-08-03 01:30:58 +04:00
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-03-17 18:50:15 +04:00
|
|
|
{
|
|
|
|
"draw_range_elements",
|
2014-03-17 18:52:56 +04:00
|
|
|
120, // OpenGL version
|
2014-03-17 18:50:15 +04:00
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-03-17 18:50:15 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_draw_range_elements,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"element_index_uint",
|
2013-08-15 23:58:20 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::OES_element_index_uint,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"ES2_compatibility",
|
2013-08-15 23:58:20 +04:00
|
|
|
kGLCoreVersionForES2Compat,
|
|
|
|
200, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::ARB_ES2_compatibility, // no suffix on ARB extension
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"ES3_compatibility",
|
2013-08-15 23:58:20 +04:00
|
|
|
kGLCoreVersionForES3Compat,
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::ARB_ES3_compatibility, // no suffix on ARB extension
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
|
|
|
// Removes clamping for float color outputs from frag shaders.
|
|
|
|
"frag_color_float",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_color_buffer_float,
|
|
|
|
GLContext::EXT_color_buffer_float,
|
|
|
|
GLContext::EXT_color_buffer_half_float,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-02-14 03:00:12 +04:00
|
|
|
{
|
|
|
|
"frag_depth",
|
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-02-14 03:00:12 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_frag_depth,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"framebuffer_blit",
|
2013-08-03 01:30:58 +04:00
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_framebuffer_blit,
|
|
|
|
GLContext::ANGLE_framebuffer_blit,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"framebuffer_multisample",
|
2013-08-03 01:30:58 +04:00
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_framebuffer_multisample,
|
|
|
|
GLContext::ANGLE_framebuffer_multisample,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"framebuffer_object",
|
2013-08-03 01:30:58 +04:00
|
|
|
300, // OpenGL version
|
|
|
|
200, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::ARB_framebuffer_object,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_framebuffer_object,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"get_query_object_iv",
|
2013-08-15 23:58:20 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
0, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XXX_get_query_object_iv only provide GetQueryObjectiv provided by
|
|
|
|
* ARB_occlusion_query (added by OpenGL 2.0).
|
|
|
|
*/
|
|
|
|
},
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"instanced_arrays",
|
2013-08-07 04:05:51 +04:00
|
|
|
330, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-07 04:05:51 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_instanced_arrays,
|
|
|
|
GLContext::NV_instanced_arrays,
|
|
|
|
GLContext::ANGLE_instanced_arrays,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-09-20 02:33:11 +04:00
|
|
|
{
|
|
|
|
"instanced_non_arrays",
|
|
|
|
330, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-09-20 02:33:11 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_instanced_arrays,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
/* This is an expanded version of `instanced_arrays` that allows for all
|
|
|
|
* enabled active attrib arrays to have non-zero divisors.
|
|
|
|
* ANGLE_instanced_arrays and NV_instanced_arrays forbid this, but GLES3
|
|
|
|
* has no such restriction.
|
|
|
|
*/
|
|
|
|
},
|
2014-09-23 09:38:01 +04:00
|
|
|
{
|
|
|
|
"integer_vertex_attribs",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-08-08 05:47:13 +04:00
|
|
|
{
|
|
|
|
"map_buffer_range",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::ARB_map_buffer_range,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"occlusion_query",
|
2013-08-15 23:58:20 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
0, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
// XXX_occlusion_query depend on ARB_occlusion_query (added in OpenGL 2.0)
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"occlusion_query_boolean",
|
2013-08-15 23:58:20 +04:00
|
|
|
kGLCoreVersionForES3Compat,
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::ARB_ES3_compatibility,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_occlusion_query_boolean,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XXX_occlusion_query_boolean provide ANY_SAMPLES_PASSED_CONSERVATIVE,
|
|
|
|
* but EXT_occlusion_query_boolean is only a OpenGL ES extension. But
|
2013-11-05 01:05:04 +04:00
|
|
|
* it is supported on desktop if ARB_ES3_compatibility because
|
2013-08-15 23:58:20 +04:00
|
|
|
* EXT_occlusion_query_boolean (added in OpenGL ES 3.0).
|
|
|
|
*/
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"occlusion_query2",
|
2013-08-15 23:58:20 +04:00
|
|
|
330, // = min(330, kGLCoreVersionForES3Compat),
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_occlusion_query2,
|
|
|
|
GLContext::ARB_ES3_compatibility,
|
|
|
|
GLContext::EXT_occlusion_query_boolean,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XXX_occlusion_query2 (add in OpenGL 3.3) provide ANY_SAMPLES_PASSED,
|
|
|
|
* which is provided by ARB_occlusion_query2, EXT_occlusion_query_boolean
|
|
|
|
* (added in OpenGL ES 3.0) and ARB_ES3_compatibility
|
|
|
|
*/
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"packed_depth_stencil",
|
2013-08-15 23:58:20 +04:00
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_packed_depth_stencil,
|
|
|
|
GLContext::OES_packed_depth_stencil,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"query_objects",
|
2013-08-15 23:58:20 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_occlusion_query_boolean,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* XXX_query_objects only provide entry points commonly supported by
|
|
|
|
* ARB_occlusion_query (added in OpenGL 2.0) and EXT_occlusion_query_boolean
|
|
|
|
* (added in OpenGL ES 3.0)
|
|
|
|
*/
|
|
|
|
},
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
|
|
|
"renderbuffer_float",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_texture_float,
|
|
|
|
GLContext::EXT_color_buffer_float,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"renderbuffer_half_float",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_texture_float,
|
|
|
|
GLContext::EXT_color_buffer_half_float,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"robustness",
|
2013-08-03 01:30:58 +04:00
|
|
|
0, // OpenGL version
|
|
|
|
0, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_robustness,
|
|
|
|
GLContext::EXT_robustness,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-11-05 01:05:04 +04:00
|
|
|
{
|
|
|
|
"sRGB",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-11-05 01:05:04 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_sRGB,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-09-23 09:45:34 +04:00
|
|
|
{
|
|
|
|
"sampler_objects",
|
|
|
|
330, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::ARB_sampler_objects,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"standard_derivatives",
|
2013-08-15 23:58:20 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::OES_standard_derivatives,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"texture_float",
|
2014-03-08 01:26:17 +04:00
|
|
|
300, // OpenGL version
|
2013-08-03 01:30:58 +04:00
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_texture_float,
|
|
|
|
GLContext::OES_texture_float,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"texture_float_linear",
|
2013-08-15 23:58:20 +04:00
|
|
|
310, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-15 23:58:20 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_texture_float,
|
|
|
|
GLContext::OES_texture_float_linear,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-01-23 21:47:56 +04:00
|
|
|
{
|
|
|
|
"texture_half_float",
|
2014-03-08 01:26:17 +04:00
|
|
|
300, // OpenGL version
|
2014-01-23 21:47:56 +04:00
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-01-23 21:47:56 +04:00
|
|
|
{
|
2014-02-11 03:03:12 +04:00
|
|
|
GLContext::ARB_half_float_pixel,
|
2014-01-23 21:47:56 +04:00
|
|
|
GLContext::ARB_texture_float,
|
|
|
|
GLContext::NV_half_float,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* We are not including OES_texture_half_float in this feature, because:
|
|
|
|
* GL_HALF_FLOAT = 0x140B
|
|
|
|
* GL_HALF_FLOAT_ARB = 0x140B == GL_HALF_FLOAT
|
|
|
|
* GL_HALF_FLOAT_NV = 0x140B == GL_HALF_FLOAT
|
|
|
|
* GL_HALF_FLOAT_OES = 0x8D61 != GL_HALF_FLOAT
|
2014-01-24 01:47:37 +04:00
|
|
|
* WebGL handles this specifically with an OES_texture_half_float check.
|
2014-01-23 21:47:56 +04:00
|
|
|
*/
|
|
|
|
},
|
2014-02-13 18:53:53 +04:00
|
|
|
{
|
|
|
|
"texture_half_float_linear",
|
|
|
|
310, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2014-02-13 18:53:53 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_half_float_pixel,
|
|
|
|
GLContext::ARB_texture_float,
|
|
|
|
GLContext::NV_half_float,
|
|
|
|
GLContext::OES_texture_half_float_linear,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"texture_non_power_of_two",
|
2013-08-03 01:30:58 +04:00
|
|
|
200, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::ARB_texture_non_power_of_two,
|
|
|
|
GLContext::OES_texture_npot,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-16 04:43:47 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"transform_feedback",
|
2013-08-16 04:43:47 +04:00
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::Extension_None,
|
2013-08-16 04:43:47 +04:00
|
|
|
{
|
|
|
|
GLContext::EXT_transform_feedback,
|
|
|
|
GLContext::NV_transform_feedback,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-07-14 08:34:17 +04:00
|
|
|
{
|
|
|
|
"uniform_buffer_object",
|
|
|
|
310, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::ARB_uniform_buffer_object,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2014-09-23 09:33:55 +04:00
|
|
|
{
|
|
|
|
"uniform_matrix_nonsquare",
|
|
|
|
210, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::Extension_None,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"uniform_uint",
|
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
|
|
|
GLContext::Extension_None,
|
|
|
|
{
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
},
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:05 +04:00
|
|
|
"vertex_array_object",
|
2013-08-03 01:30:58 +04:00
|
|
|
300, // OpenGL version
|
|
|
|
300, // OpenGL ES version
|
2014-05-14 04:18:42 +04:00
|
|
|
GLContext::ARB_vertex_array_object, // ARB extension
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
GLContext::OES_vertex_array_object,
|
|
|
|
GLContext::APPLE_vertex_array_object,
|
|
|
|
GLContext::Extensions_End
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
static inline const FeatureInfo&
|
2014-01-10 22:55:23 +04:00
|
|
|
GetFeatureInfo(GLFeature feature)
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:04 +04:00
|
|
|
static_assert(MOZ_ARRAY_LENGTH(sFeatureInfoArr) == size_t(GLFeature::EnumMax),
|
|
|
|
"Mismatched lengths for sFeatureInfoInfos and GLFeature enums");
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
MOZ_ASSERT(feature < GLFeature::EnumMax,
|
|
|
|
"GLContext::GetFeatureInfoInfo : unknown <feature>");
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
return sFeatureInfoArr[size_t(feature)];
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
2014-01-10 22:55:23 +04:00
|
|
|
ProfileVersionForFeature(GLFeature feature, ContextProfile profile)
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(profile != ContextProfile::Unknown,
|
2013-08-22 21:42:04 +04:00
|
|
|
"GLContext::ProfileVersionForFeature : unknown <profile>");
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
const FeatureInfo& featureInfo = GetFeatureInfo(feature);
|
2013-08-03 01:30:58 +04:00
|
|
|
|
|
|
|
if (profile == ContextProfile::OpenGLES) {
|
2013-08-22 21:42:04 +04:00
|
|
|
return featureInfo.mOpenGLESVersion;
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
return featureInfo.mOpenGLVersion;
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
bool
|
|
|
|
IsFeaturePartOfProfileVersion(GLFeature feature,
|
|
|
|
ContextProfile profile, unsigned int version)
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:04 +04:00
|
|
|
unsigned int profileVersion = ProfileVersionForFeature(feature, profile);
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
/**
|
|
|
|
* if `profileVersion` is zero, it means that no version of the profile
|
|
|
|
* added support for the feature.
|
|
|
|
*/
|
2013-08-03 01:30:58 +04:00
|
|
|
return profileVersion && version >= profileVersion;
|
|
|
|
}
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
bool
|
|
|
|
GLContext::IsFeatureProvidedByCoreSymbols(GLFeature feature)
|
|
|
|
{
|
|
|
|
if (IsFeaturePartOfProfileVersion(feature, mProfile, mVersion))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (IsExtensionSupported(GetFeatureInfo(feature).mARBExtensionWithoutARBSuffix))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-03 01:30:58 +04:00
|
|
|
const char*
|
2014-01-10 22:55:23 +04:00
|
|
|
GLContext::GetFeatureName(GLFeature feature)
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2013-08-22 21:42:04 +04:00
|
|
|
return GetFeatureInfo(feature).mName;
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
2013-12-03 22:44:38 +04:00
|
|
|
static bool
|
|
|
|
CanReadSRGBFromFBOTexture(GLContext* gl)
|
|
|
|
{
|
|
|
|
if (!gl->WorkAroundDriverBugs())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Bug 843668:
|
|
|
|
// MacOSX 10.6 reports to support EXT_framebuffer_sRGB and
|
|
|
|
// EXT_texture_sRGB but fails to convert from sRGB to linear
|
|
|
|
// when writing to an sRGB texture attached to an FBO.
|
|
|
|
if (!nsCocoaFeatures::OnLionOrLater()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif // XP_MACOSX
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
void
|
|
|
|
GLContext::InitFeatures()
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2014-01-10 22:55:23 +04:00
|
|
|
for (size_t feature_index = 0; feature_index < size_t(GLFeature::EnumMax); feature_index++)
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2014-01-10 22:55:23 +04:00
|
|
|
GLFeature feature = GLFeature(feature_index);
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
if (IsFeaturePartOfProfileVersion(feature, mProfile, mVersion)) {
|
2014-01-10 22:55:23 +04:00
|
|
|
mAvailableFeatures[feature_index] = true;
|
2013-08-24 03:33:42 +04:00
|
|
|
continue;
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
mAvailableFeatures[feature_index] = false;
|
2013-08-24 03:33:42 +04:00
|
|
|
|
|
|
|
const FeatureInfo& featureInfo = GetFeatureInfo(feature);
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
if (IsExtensionSupported(featureInfo.mARBExtensionWithoutARBSuffix))
|
|
|
|
{
|
|
|
|
mAvailableFeatures[feature_index] = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
for (size_t j = 0; true; j++)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(j < kMAX_EXTENSION_GROUP_SIZE, "kMAX_EXTENSION_GROUP_SIZE too small");
|
|
|
|
|
|
|
|
if (featureInfo.mExtensions[j] == GLContext::Extensions_End) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsExtensionSupported(featureInfo.mExtensions[j])) {
|
2014-01-10 22:55:23 +04:00
|
|
|
mAvailableFeatures[feature_index] = true;
|
2013-08-24 03:33:42 +04:00
|
|
|
break;
|
|
|
|
}
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
}
|
2013-11-05 01:05:04 +04:00
|
|
|
|
|
|
|
// Bug 843668: Work around limitation of the feature system.
|
|
|
|
// For sRGB support under OpenGL to match OpenGL ES spec, check for both
|
|
|
|
// EXT_texture_sRGB and EXT_framebuffer_sRGB is required.
|
|
|
|
const bool aresRGBExtensionsAvailable =
|
|
|
|
IsExtensionSupported(EXT_texture_sRGB) &&
|
|
|
|
(IsExtensionSupported(ARB_framebuffer_sRGB) ||
|
|
|
|
IsExtensionSupported(EXT_framebuffer_sRGB));
|
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
mAvailableFeatures[size_t(GLFeature::sRGB)] =
|
2013-11-05 01:05:04 +04:00
|
|
|
aresRGBExtensionsAvailable &&
|
2013-12-03 22:44:38 +04:00
|
|
|
CanReadSRGBFromFBOTexture(this);
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
void
|
2014-01-10 22:55:23 +04:00
|
|
|
GLContext::MarkUnsupported(GLFeature feature)
|
2013-08-03 01:30:58 +04:00
|
|
|
{
|
2014-01-10 22:55:23 +04:00
|
|
|
mAvailableFeatures[size_t(feature)] = false;
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
const FeatureInfo& featureInfo = GetFeatureInfo(feature);
|
2013-08-03 01:30:58 +04:00
|
|
|
|
|
|
|
for (size_t i = 0; true; i++)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(i < kMAX_EXTENSION_GROUP_SIZE, "kMAX_EXTENSION_GROUP_SIZE too small");
|
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
if (featureInfo.mExtensions[i] == GLContext::Extensions_End) {
|
2013-08-03 01:30:58 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
MarkExtensionUnsupported(featureInfo.mExtensions[i]);
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
MOZ_ASSERT(!IsSupported(feature), "GLContext::MarkUnsupported has failed!");
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2013-08-22 21:42:04 +04:00
|
|
|
NS_WARNING(nsPrintfCString("%s marked as unsupported", GetFeatureName(feature)).get());
|
2013-08-03 01:30:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|