bug 902063 - GLContext complete extension group queries - r=bjacob,jgilbert

This commit is contained in:
Guillaume Abadie 2013-08-15 15:58:20 -04:00
parent beb80491c9
commit 55c9d6f3f5
5 changed files with 264 additions and 100 deletions

View File

@ -969,22 +969,16 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
switch (ext) {
case OES_element_index_uint:
if (!gl->IsGLES2())
return true;
return gl->IsExtensionSupported(GLContext::OES_element_index_uint);
return gl->IsExtensionSupported(GLContext::XXX_element_index_uint);
case OES_standard_derivatives:
if (!gl->IsGLES2())
return true;
return gl->IsExtensionSupported(GLContext::OES_standard_derivatives);
return gl->IsExtensionSupported(GLContext::XXX_standard_derivatives);
case WEBGL_lose_context:
// We always support this extension.
return true;
case OES_texture_float:
return gl->IsExtensionSupported(gl->IsGLES2() ? GLContext::OES_texture_float
: GLContext::ARB_texture_float);
return gl->IsExtensionSupported(GLContext::XXX_texture_float);
case OES_texture_float_linear:
return gl->IsExtensionSupported(gl->IsGLES2() ? GLContext::OES_texture_float_linear
: GLContext::ARB_texture_float);
return gl->IsExtensionSupported(GLContext::XXX_texture_float_linear);
case OES_vertex_array_object:
return WebGLExtensionVertexArray::IsSupported(this);
case EXT_texture_filter_anisotropic:
@ -1005,18 +999,8 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
case WEBGL_compressed_texture_pvrtc:
return gl->IsExtensionSupported(GLContext::IMG_texture_compression_pvrtc);
case WEBGL_depth_texture:
if (gl->IsGLES2() &&
gl->IsExtensionSupported(GLContext::OES_packed_depth_stencil) &&
gl->IsExtensionSupported(GLContext::OES_depth_texture))
{
return true;
}
else if (!gl->IsGLES2() &&
gl->IsExtensionSupported(GLContext::EXT_packed_depth_stencil))
{
return true;
}
return false;
return gl->IsExtensionSupported(GLContext::XXX_packed_depth_stencil) &&
gl->IsExtensionSupported(GLContext::XXX_depth_texture);
case ANGLE_instanced_arrays:
return WebGLExtensionInstancedArrays::IsSupported(this);
default:

View File

@ -899,7 +899,7 @@ WebGLContext::InitAndValidateGL()
mGLMaxVertexUniformVectors = MINVALUE_GL_MAX_VERTEX_UNIFORM_VECTORS;
mGLMaxVaryingVectors = MINVALUE_GL_MAX_VARYING_VECTORS;
} else {
if (gl->HasES2Compatibility()) {
if (gl->IsExtensionSupported(gl::GLContext::XXX_ES2_compatibility)) {
gl->fGetIntegerv(LOCAL_GL_MAX_FRAGMENT_UNIFORM_VECTORS, &mGLMaxFragmentUniformVectors);
gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_UNIFORM_VECTORS, &mGLMaxVertexUniformVectors);
gl->fGetIntegerv(LOCAL_GL_MAX_VARYING_VECTORS, &mGLMaxVaryingVectors);
@ -998,7 +998,8 @@ WebGLContext::InitAndValidateGL()
!IsExtensionSupported(ANGLE_instanced_arrays) ||
!gl->IsExtensionSupported(gl::GLContext::EXT_gpu_shader4) ||
!gl->IsExtensionSupported(gl::GLContext::EXT_blend_minmax) ||
(gl->IsGLES2() && !gl->IsExtensionSupported(gl::GLContext::EXT_occlusion_query_boolean))
(!gl->IsExtensionSupported(gl::GLContext::XXX_occlusion_query) &&
!gl->IsExtensionSupported(gl::GLContext::XXX_occlusion_query_boolean))
))
{
// Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.

View File

@ -54,6 +54,7 @@ static const char *sExtensionNames[] = {
"GL_OES_depth32",
"GL_OES_stencil8",
"GL_OES_texture_npot",
"GL_ARB_depth_texture",
"GL_OES_depth_texture",
"GL_OES_packed_depth_stencil",
"GL_IMG_read_format",
@ -62,6 +63,7 @@ static const char *sExtensionNames[] = {
"GL_ARB_texture_non_power_of_two",
"GL_ARB_pixel_buffer_object",
"GL_ARB_ES2_compatibility",
"GL_ARB_ES3_compatibility",
"GL_OES_texture_float",
"GL_OES_texture_float_linear",
"GL_ARB_texture_float",
@ -101,6 +103,7 @@ static const char *sExtensionNames[] = {
"GL_NV_instanced_arrays",
"GL_ANGLE_instanced_arrays",
"GL_EXT_occlusion_query_boolean",
"GL_ARB_occlusion_query2",
nullptr
};
@ -317,14 +320,6 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fMapBuffer, { "MapBuffer", nullptr } },
{ (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
{ (PRFuncPtr*) &mSymbols.fPointParameterf, { "PointParameterf", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuiv", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueries", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueries", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryiv", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQuery", nullptr } },
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQuery", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDrawBuffer, { "DrawBuffer", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
{ nullptr, { nullptr } },
@ -657,8 +652,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
}
}
if (IsGLES2() &&
IsExtensionSupported(EXT_occlusion_query_boolean)) {
if (IsExtensionSupported(XXX_query_objects)) {
SymLoadStruct queryObjectsSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", "BeginQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueries", "GenQueriesEXT", nullptr } },
@ -671,20 +665,37 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
};
if (!LoadSymbols(queryObjectsSymbols, trygl, prefix)) {
NS_ERROR("GL ES supports query objects without supplying its functions.");
NS_ERROR("GL supports query objects without supplying its functions.");
MarkExtensionUnsupported(EXT_occlusion_query_boolean);
mInitialized &= MarkExtensionGroupUnsupported(XXX_query_objects);
mInitialized &= MarkExtensionGroupUnsupported(XXX_get_query_object_iv);
mInitialized &= MarkExtensionGroupUnsupported(XXX_occlusion_query);
MarkExtensionGroupUnsupported(XXX_occlusion_query_boolean);
MarkExtensionGroupUnsupported(XXX_occlusion_query2);
mSymbols.fBeginQuery = nullptr;
mSymbols.fGenQueries = nullptr;
mSymbols.fDeleteQueries = nullptr;
mSymbols.fEndQuery = nullptr;
mSymbols.fGetQueryiv = nullptr;
mSymbols.fGetQueryObjectiv = nullptr;
mSymbols.fGetQueryObjectuiv = nullptr;
mSymbols.fIsQuery = nullptr;
}
}
if (IsExtensionSupported(XXX_get_query_object_iv)) {
SymLoadStruct queryObjectsSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", "GetQueryObjectivEXT", nullptr } },
{ nullptr, { nullptr } },
};
if (!LoadSymbols(queryObjectsSymbols, trygl, prefix)) {
NS_ERROR("GL supports query objects iv getter without supplying its function.");
mInitialized &= MarkExtensionGroupUnsupported(XXX_get_query_object_iv);
mSymbols.fGetQueryObjectiv = nullptr;
}
}
// Load developer symbols, don't fail if we can't find them.
SymLoadStruct auxSymbols[] = {
@ -2956,7 +2967,7 @@ GLContext::CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNam
}
static void
RemoveNamesFromArray(GLContext *aOrigin, GLsizei aCount, GLuint *aNames, nsTArray<GLContext::NamedResource>& aArray)
RemoveNamesFromArray(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames, nsTArray<GLContext::NamedResource>& aArray)
{
for (GLsizei j = 0; j < aCount; ++j) {
GLuint name = aNames[j];
@ -2992,7 +3003,7 @@ GLContext::DeletedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
}
void
GLContext::DeletedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
GLContext::DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
{
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedQueries);
}

View File

@ -273,14 +273,6 @@ public:
return IsAtLeast(ContextProfile::OpenGLES, 200);
}
/**
* Returns true if either this is the GLES2 API, or had the GL_ARB_ES2_compatibility extension
* We would like to introduce a XXX_ES2_compatibility
*/
bool HasES2Compatibility() const {
return IsGLES2() || IsExtensionSupported(ARB_ES2_compatibility);
}
protected:
@ -337,6 +329,7 @@ public:
OES_depth32,
OES_stencil8,
OES_texture_npot,
ARB_depth_texture,
OES_depth_texture,
OES_packed_depth_stencil,
IMG_read_format,
@ -345,6 +338,7 @@ public:
ARB_texture_non_power_of_two,
ARB_pixel_buffer_object,
ARB_ES2_compatibility,
ARB_ES3_compatibility,
OES_texture_float,
OES_texture_float_linear,
ARB_texture_float,
@ -384,6 +378,7 @@ public:
NV_instanced_arrays,
ANGLE_instanced_arrays,
EXT_occlusion_query_boolean,
ARB_occlusion_query2,
Extensions_Max,
Extensions_End
};
@ -477,14 +472,26 @@ public:
* This enum should be sorted by name.
*/
enum GLExtensionGroup {
XXX_depth_texture,
XXX_draw_buffers,
XXX_draw_instanced,
XXX_element_index_uint,
XXX_ES2_compatibility,
XXX_ES3_compatibility,
XXX_framebuffer_blit,
XXX_framebuffer_multisample,
XXX_framebuffer_object,
XXX_get_query_object_iv,
XXX_instanced_arrays,
XXX_occlusion_query,
XXX_occlusion_query_boolean,
XXX_occlusion_query2,
XXX_packed_depth_stencil,
XXX_query_objects,
XXX_robustness,
XXX_standard_derivatives,
XXX_texture_float,
XXX_texture_float_linear,
XXX_texture_non_power_of_two,
XXX_vertex_array_object,
ExtensionGroup_Max
@ -1044,27 +1051,6 @@ public:
return retval;
}
void fGetQueryiv(GLenum target, GLenum pname, GLint* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetQueryiv);
mSymbols.fGetQueryiv(target, pname, params);
AFTER_GL_CALL;
}
void fGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv);
mSymbols.fGetQueryObjectiv(id, pname, params);
AFTER_GL_CALL;
}
void fGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv);
mSymbols.fGetQueryObjectuiv(id, pname, params);
AFTER_GL_CALL;
}
private:
void raw_fGetIntegerv(GLenum pname, GLint *params) {
BEFORE_GL_CALL;
@ -1273,14 +1259,6 @@ public:
return retval;
}
realGLboolean fIsQuery(GLuint query) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fIsQuery);
realGLboolean retval = mSymbols.fIsQuery(query);
AFTER_GL_CALL;
return retval;
}
realGLboolean fIsShader(GLuint shader) {
BEFORE_GL_CALL;
realGLboolean retval = mSymbols.fIsShader(shader);
@ -1841,13 +1819,6 @@ private:
AFTER_GL_CALL;
}
void GLAPIENTRY raw_fGenQueries(GLsizei n, GLuint* names) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGenQueries);
mSymbols.fGenQueries(n, names);
AFTER_GL_CALL;
}
void GLAPIENTRY raw_fGenRenderbuffers(GLsizei n, GLuint* names) {
BEFORE_GL_CALL;
mSymbols.fGenRenderbuffers(n, names);
@ -1883,11 +1854,6 @@ public:
TRACKING_CONTEXT(CreatedFramebuffers(this, n, names));
}
void fGenQueries(GLsizei n, GLuint* names) {
raw_fGenQueries(n, names);
TRACKING_CONTEXT(CreatedQueries(this, n, names));
}
void fGenRenderbuffers(GLsizei n, GLuint* names) {
raw_fGenRenderbuffers(n, names);
TRACKING_CONTEXT(CreatedRenderbuffers(this, n, names));
@ -1935,18 +1901,7 @@ private:
AFTER_GL_CALL;
}
void GLAPIENTRY raw_fDeleteQueries(GLsizei n, GLuint* names) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fDeleteQueries);
mSymbols.fDeleteQueries(n, names);
AFTER_GL_CALL;
}
public:
void GLAPIENTRY fDeleteQueries(GLsizei n, GLuint* names) {
raw_fDeleteQueries(n, names);
TRACKING_CONTEXT(DeletedQueries(this, n, names));
}
void fDeleteProgram(GLuint program) {
raw_fDeleteProgram(program);
@ -2155,6 +2110,80 @@ public:
}
// -----------------------------------------------------------------------------
// Package XXX_query_objects
/**
* XXX_query_objects:
* - provide all followed entry points
*
* XXX_occlusion_query2:
* - depends on XXX_query_objects
* - provide ANY_SAMPLES_PASSED
*
* XXX_occlusion_query_boolean:
* - depends on XXX_occlusion_query2
* - provide ANY_SAMPLES_PASSED_CONSERVATIVE
*/
public:
void fDeleteQueries(GLsizei n, const GLuint* names) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fDeleteQueries);
mSymbols.fDeleteQueries(n, names);
AFTER_GL_CALL;
TRACKING_CONTEXT(DeletedQueries(this, n, names));
}
void fGenQueries(GLsizei n, GLuint* names) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGenQueries);
mSymbols.fGenQueries(n, names);
AFTER_GL_CALL;
TRACKING_CONTEXT(CreatedQueries(this, n, names));
}
void fGetQueryiv(GLenum target, GLenum pname, GLint* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetQueryiv);
mSymbols.fGetQueryiv(target, pname, params);
AFTER_GL_CALL;
}
void fGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv);
mSymbols.fGetQueryObjectuiv(id, pname, params);
AFTER_GL_CALL;
}
realGLboolean fIsQuery(GLuint query) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fIsQuery);
realGLboolean retval = mSymbols.fIsQuery(query);
AFTER_GL_CALL;
return retval;
}
// -----------------------------------------------------------------------------
// Package XXX_get_query_object_iv
/**
* XXX_get_query_object_iv:
* - depends on XXX_query_objects
* - provide the followed entry point
*
* XXX_occlusion_query:
* - depends on XXX_get_query_object_iv
* - provide LOCAL_GL_SAMPLES_PASSED
*/
public:
void fGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv);
mSymbols.fGetQueryObjectiv(id, pname, params);
AFTER_GL_CALL;
}
// -----------------------------------------------------------------------------
// Package XXX_vertex_array_object
public:
@ -3286,7 +3315,7 @@ public:
void DeletedProgram(GLContext *aOrigin, GLuint aName);
void DeletedShader(GLContext *aOrigin, GLuint aName);
void DeletedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void DeletedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
void DeletedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
void DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);

View File

@ -12,6 +12,12 @@ namespace gl {
const size_t kMAX_EXTENSION_GROUP_SIZE = 5;
// 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;
struct ExtensionGroupInfo
{
const char* mName;
@ -21,6 +27,16 @@ struct ExtensionGroupInfo
};
static const ExtensionGroupInfo sExtensionGroupInfoArr[] = {
{
"XXX_depth_texture",
200, // OpenGL version
300, // OpenGL ES version
{
GLContext::ARB_depth_texture,
GLContext::OES_depth_texture,
GLContext::Extensions_End
}
},
{
"XXX_draw_buffers",
200, // OpenGL version
@ -43,6 +59,33 @@ static const ExtensionGroupInfo sExtensionGroupInfoArr[] = {
GLContext::Extensions_End
}
},
{
"XXX_element_index_uint",
200, // OpenGL version
300, // OpenGL ES version
{
GLContext::OES_element_index_uint,
GLContext::Extensions_End
}
},
{
"XXX_ES2_compatibility",
kGLCoreVersionForES2Compat,
200, // OpenGL ES version
{
GLContext::ARB_ES2_compatibility,
GLContext::Extensions_End
}
},
{
"XXX_ES3_compatibility",
kGLCoreVersionForES3Compat,
300, // OpenGL ES version
{
GLContext::ARB_ES3_compatibility,
GLContext::Extensions_End
}
},
{
"XXX_framebuffer_blit",
300, // OpenGL version
@ -73,6 +116,18 @@ static const ExtensionGroupInfo sExtensionGroupInfoArr[] = {
GLContext::Extensions_End
}
},
{
"XXX_get_query_object_iv",
200, // OpenGL version
0, // OpenGL ES version
{
GLContext::Extensions_End
}
/*
* XXX_get_query_object_iv only provide GetQueryObjectiv provided by
* ARB_occlusion_query (added by OpenGL 2.0).
*/
},
{
"XXX_instanced_arrays",
330, // OpenGL version
@ -84,6 +139,71 @@ static const ExtensionGroupInfo sExtensionGroupInfoArr[] = {
GLContext::Extensions_End
}
},
{
"XXX_occlusion_query",
200, // OpenGL version
0, // OpenGL ES version
{
GLContext::Extensions_End
}
// XXX_occlusion_query depend on ARB_occlusion_query (added in OpenGL 2.0)
},
{
"XXX_occlusion_query_boolean",
kGLCoreVersionForES3Compat,
300, // OpenGL ES version
{
GLContext::ARB_ES3_compatibility,
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
* it is supported on desktop if ARB_ES3_compatibility because
* EXT_occlusion_query_boolean (added in OpenGL ES 3.0).
*/
},
{
"XXX_occlusion_query2",
330, // = min(330, kGLCoreVersionForES3Compat),
300, // OpenGL ES version
{
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
*/
},
{
"XXX_packed_depth_stencil",
300, // OpenGL version
300, // OpenGL ES version
{
GLContext::EXT_packed_depth_stencil,
GLContext::OES_packed_depth_stencil,
GLContext::Extensions_End
}
},
{
"XXX_query_objects",
200, // OpenGL version
300, // OpenGL ES version
{
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)
*/
},
{
"XXX_robustness",
0, // OpenGL version
@ -94,6 +214,15 @@ static const ExtensionGroupInfo sExtensionGroupInfoArr[] = {
GLContext::Extensions_End
}
},
{
"XXX_standard_derivatives",
200, // OpenGL version
300, // OpenGL ES version
{
GLContext::OES_standard_derivatives,
GLContext::Extensions_End
}
},
{
"XXX_texture_float",
310, // OpenGL version
@ -104,6 +233,16 @@ static const ExtensionGroupInfo sExtensionGroupInfoArr[] = {
GLContext::Extensions_End
}
},
{
"XXX_texture_float_linear",
310, // OpenGL version
300, // OpenGL ES version
{
GLContext::ARB_texture_float,
GLContext::OES_texture_float_linear,
GLContext::Extensions_End
}
},
{
"XXX_texture_non_power_of_two",
200, // OpenGL version