bug 892978 - [WebGL 2.0] Query objects (GL_ARB_occlusion_query_boolean) - r=jgilbert

This commit is contained in:
Guillaume Abadie 2013-08-06 17:23:46 -04:00
parent 1276b126cd
commit 5e549ecde2
14 changed files with 576 additions and 5 deletions

View File

@ -18,4 +18,4 @@
# Modifying this file will now automatically clobber the buildbot machines \o/
#
Removal of XPIDL for bug 893117 requires a clobber to make sure interfaces aren't generated.
Add an WebIDL interface for bug 892978 requires a clobber for Windows.

View File

@ -13,6 +13,7 @@
#include "WebGLMemoryMultiReporterWrapper.h"
#include "WebGLFramebuffer.h"
#include "WebGLVertexArray.h"
#include "WebGLQuery.h"
#include "AccessCheck.h"
#include "nsIConsoleService.h"
@ -237,6 +238,7 @@ WebGLContext::DestroyResourcesAndContext()
mBoundArrayBuffer = nullptr;
mCurrentProgram = nullptr;
mBoundFramebuffer = nullptr;
mActiveOcclusionQuery = nullptr;
mBoundRenderbuffer = nullptr;
mBoundVertexArray = nullptr;
mDefaultVertexArray = nullptr;
@ -255,6 +257,8 @@ WebGLContext::DestroyResourcesAndContext()
mShaders.getLast()->DeleteOnce();
while (!mPrograms.isEmpty())
mPrograms.getLast()->DeleteOnce();
while (!mQueries.isEmpty())
mQueries.getLast()->DeleteOnce();
if (mBlackTexturesAreInitialized) {
gl->fDeleteTextures(1, &mBlackTexture2D);
@ -1599,7 +1603,7 @@ WebGLContext::GetSupportedExtensions(JSContext *cx, Nullable< nsTArray<nsString>
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLContext)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLContext)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_9(WebGLContext,
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_10(WebGLContext,
mCanvasElement,
mExtensions,
mBound2DTextures,
@ -1608,7 +1612,8 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_9(WebGLContext,
mCurrentProgram,
mBoundFramebuffer,
mBoundRenderbuffer,
mBoundVertexArray)
mBoundVertexArray,
mActiveOcclusionQuery)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLContext)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY

View File

@ -71,6 +71,7 @@ class WebGLBuffer;
class WebGLVertexAttribData;
class WebGLShader;
class WebGLProgram;
class WebGLQuery;
class WebGLUniformLocation;
class WebGLFramebuffer;
class WebGLRenderbuffer;
@ -793,6 +794,21 @@ public:
WebGLintptr byteOffset);
void Viewport(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei height);
// -----------------------------------------------------------------------------
// Asynchronous Queries (WebGLContextAsyncQueries.cpp)
public:
already_AddRefed<WebGLQuery> CreateQuery();
void DeleteQuery(WebGLQuery *query);
void BeginQuery(WebGLenum target, WebGLQuery *query);
void EndQuery(WebGLenum target);
bool IsQuery(WebGLQuery *query);
already_AddRefed<WebGLQuery> GetQuery(WebGLenum target, WebGLenum pname);
JS::Value GetQueryObject(JSContext* cx, WebGLQuery *query, WebGLenum pname);
private:
bool ValidateTargetParameter(WebGLenum target, const char* infos);
WebGLRefPtr<WebGLQuery>& GetActiveQueryByTarget(WebGLenum target);
// -----------------------------------------------------------------------------
// Vertices Feature (WebGLContextVertices.cpp)
public:
@ -1088,10 +1104,12 @@ protected:
WebGLRefPtr<WebGLFramebuffer> mBoundFramebuffer;
WebGLRefPtr<WebGLRenderbuffer> mBoundRenderbuffer;
WebGLRefPtr<WebGLVertexArray> mBoundVertexArray;
WebGLRefPtr<WebGLQuery> mActiveOcclusionQuery;
LinkedList<WebGLTexture> mTextures;
LinkedList<WebGLBuffer> mBuffers;
LinkedList<WebGLProgram> mPrograms;
LinkedList<WebGLQuery> mQueries;
LinkedList<WebGLShader> mShaders;
LinkedList<WebGLRenderbuffer> mRenderbuffers;
LinkedList<WebGLFramebuffer> mFramebuffers;
@ -1180,6 +1198,7 @@ public:
friend class WebGLFramebuffer;
friend class WebGLRenderbuffer;
friend class WebGLProgram;
friend class WebGLQuery;
friend class WebGLBuffer;
friend class WebGLShader;
friend class WebGLUniformLocation;

View File

@ -0,0 +1,331 @@
/* -*- Mode: C++; tab-width: 4; 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 "WebGLContext.h"
#include "WebGLQuery.h"
using namespace mozilla;
/*
* We fake ANY_SAMPLES_PASSED and ANY_SAMPLES_PASSED_CONSERVATIVE with
* SAMPLES_PASSED on desktop.
*
* OpenGL ES 3.0 spec 4.1.6
* If the target of the query is ANY_SAMPLES_PASSED_CONSERVATIVE, an implementation
* may choose to use a less precise version of the test which can additionally set
* the samples-boolean state to TRUE in some other implementation-dependent cases.
*/
static const char*
GetQueryTargetEnumString(WebGLenum target)
{
switch (target)
{
case LOCAL_GL_ANY_SAMPLES_PASSED:
return "ANY_SAMPLES_PASSED";
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
return "ANY_SAMPLES_PASSED_CONSERVATIVE";
default:
break;
}
MOZ_ASSERT(false, "Unknown query `target`.");
return "UNKNOWN_QUERY_TARGET";
}
already_AddRefed<WebGLQuery>
WebGLContext::CreateQuery()
{
if (!IsContextStable())
return nullptr;
if (mActiveOcclusionQuery && !gl->IsGLES2()) {
/* http://www.opengl.org/registry/specs/ARB/occlusion_query.txt
* Calling either GenQueriesARB or DeleteQueriesARB while any query of
* any target is active causes an INVALID_OPERATION error to be
* generated.
*/
GenerateWarning("createQuery: the WebGL 2 prototype might generate INVALID_OPERATION"
"when creating a query object while one other is active.");
/*
* We *need* to lock webgl2 to GL>=3.0 on desktop, but we don't have a good
* mechanism to do this yet. See bug 898404.
*/
}
nsRefPtr<WebGLQuery> globj = new WebGLQuery(this);
return globj.forget();
}
void
WebGLContext::DeleteQuery(WebGLQuery *query)
{
if (!IsContextStable())
return;
if (!query)
return;
if (query->IsDeleted())
return;
if (query->IsActive()) {
EndQuery(query->mType);
}
if (mActiveOcclusionQuery && !gl->IsGLES2()) {
/* http://www.opengl.org/registry/specs/ARB/occlusion_query.txt
* Calling either GenQueriesARB or DeleteQueriesARB while any query of
* any target is active causes an INVALID_OPERATION error to be
* generated.
*/
GenerateWarning("deleteQuery: the WebGL 2 prototype might generate INVALID_OPERATION"
"when deleting a query object while one other is active.");
}
query->RequestDelete();
}
void
WebGLContext::BeginQuery(WebGLenum target, WebGLQuery *query)
{
if (!IsContextStable())
return;
if (!ValidateTargetParameter(target, "beginQuery")) {
return;
}
if (!query) {
/* SPECS BeginQuery.1
* http://www.khronos.org/registry/gles/extensions/EXT/EXT_occlusion_query_boolean.txt
* BeginQueryEXT sets the active query object name for the query type given
* by <target> to <id>. If BeginQueryEXT is called with an <id> of zero, if
* the active query object name for <target> is non-zero (for the targets
* ANY_SAMPLES_PASSED_EXT and ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, if the
* active query for either target is non-zero), if <id> is the name of an
* existing query object whose type does not match <target>, or if <id> is the
* active query object name for any query type, the error INVALID_OPERATION is
* generated.
*/
ErrorInvalidOperation("beginQuery: query should not be null");
return;
}
if (query->IsDeleted()) {
/* http://www.khronos.org/registry/gles/extensions/EXT/EXT_occlusion_query_boolean.txt
* BeginQueryEXT fails and an INVALID_OPERATION error is generated if <id>
* is not a name returned from a previous call to GenQueriesEXT, or if such
* a name has since been deleted with DeleteQueriesEXT.
*/
ErrorInvalidOperation("beginQuery: query has been deleted");
return;
}
if (query->HasEverBeenActive() &&
query->mType != target)
{
/*
* See SPECS BeginQuery.1
*/
ErrorInvalidOperation("beginQuery: target doesn't match with the query type");
return;
}
if (GetActiveQueryByTarget(target)) {
/*
* See SPECS BeginQuery.1
*/
ErrorInvalidOperation("beginQuery: an other query already active");
return;
}
if (!query->HasEverBeenActive()) {
query->mType = target;
}
MakeContextCurrent();
if (!gl->IsGLES2()) {
gl->fBeginQuery(LOCAL_GL_SAMPLES_PASSED, query->mGLName);
} else {
gl->fBeginQuery(target, query->mGLName);
}
GetActiveQueryByTarget(target) = query;
}
void
WebGLContext::EndQuery(WebGLenum target)
{
if (!IsContextStable())
return;
if (!ValidateTargetParameter(target, "endQuery")) {
return;
}
if (!GetActiveQueryByTarget(target) ||
target != GetActiveQueryByTarget(target)->mType)
{
/* http://www.khronos.org/registry/gles/extensions/EXT/EXT_occlusion_query_boolean.txt
* marks the end of the sequence of commands to be tracked for the query type
* given by <target>. The active query object for <target> is updated to
* indicate that query results are not available, and the active query object
* name for <target> is reset to zero. When the commands issued prior to
* EndQueryEXT have completed and a final query result is available, the
* query object active when EndQueryEXT is called is updated by the GL. The
* query object is updated to indicate that the query results are available
* and to contain the query result. If the active query object name for
* <target> is zero when EndQueryEXT is called, the error INVALID_OPERATION
* is generated.
*/
ErrorInvalidOperation("endQuery: There is no active query of type %s.",
GetQueryTargetEnumString(target));
return;
}
MakeContextCurrent();
if (!gl->IsGLES2()) {
gl->fEndQuery(LOCAL_GL_SAMPLES_PASSED);
} else {
gl->fEndQuery(target);
}
GetActiveQueryByTarget(target) = nullptr;
}
bool
WebGLContext::IsQuery(WebGLQuery *query)
{
if (!IsContextStable())
return false;
if (!query)
return false;
return ValidateObjectAllowDeleted("isQuery", query) &&
!query->IsDeleted() &&
query->HasEverBeenActive();
}
already_AddRefed<WebGLQuery>
WebGLContext::GetQuery(WebGLenum target, WebGLenum pname)
{
if (!IsContextStable())
return nullptr;
if (!ValidateTargetParameter(target, "getQuery")) {
return nullptr;
}
if (pname != LOCAL_GL_CURRENT_QUERY) {
/* OpenGL ES 3.0 spec 6.1.7
* pname must be CURRENT_QUERY.
*/
ErrorInvalidEnum("getQuery: pname must be CURRENT_QUERY");
return nullptr;
}
nsRefPtr<WebGLQuery> tmp = GetActiveQueryByTarget(target).get();
return tmp.forget();
}
JS::Value
WebGLContext::GetQueryObject(JSContext* cx, WebGLQuery *query, WebGLenum pname)
{
if (!IsContextStable())
return JS::NullValue();
if (!query) {
/* OpenGL ES 3.0 spec 6.1.7 (spec getQueryObject 1)
* If id is not the name of a query object, or if the query object named by id is
* currently active, then an INVALID_OPERATION error is generated. pname must be
* QUERY_RESULT or QUERY_RESULT_AVAILABLE.
*/
ErrorInvalidOperation("getQueryObject: query should not be null");
return JS::NullValue();
}
if (query->IsDeleted()) {
// See (spec getQueryObject 1)
ErrorInvalidOperation("getQueryObject: query has been deleted");
return JS::NullValue();
}
if (query->IsActive()) {
// See (spec getQueryObject 1)
ErrorInvalidOperation("getQueryObject: query is active");
return JS::NullValue();
}
if (!query->HasEverBeenActive()) {
/* See (spec getQueryObject 1)
* If this instance of WebGLQuery has never been active before, that mean that
* query->mGLName is not a query object yet.
*/
ErrorInvalidOperation("getQueryObject: query has never been active");
return JS::NullValue();
}
switch (pname)
{
case LOCAL_GL_QUERY_RESULT_AVAILABLE:
{
GLuint returned = 0;
MakeContextCurrent();
gl->fGetQueryObjectuiv(query->mGLName, LOCAL_GL_QUERY_RESULT_AVAILABLE, &returned);
return JS::BooleanValue(returned != 0);
}
case LOCAL_GL_QUERY_RESULT:
{
GLuint returned = 0;
MakeContextCurrent();
gl->fGetQueryObjectuiv(query->mGLName, LOCAL_GL_QUERY_RESULT, &returned);
/*
* test (returned != 0) is important because ARB_occlusion_query on desktop drivers
* return the number of samples drawed when the OpenGL ES extension
* ARB_occlusion_query_boolean return only a boolean if a sample has been drawed.
*/
return JS::BooleanValue(returned != 0);
}
default:
break;
}
ErrorInvalidEnum("getQueryObject: pname must be QUERY_RESULT{_AVAILABLE}");
return JS::NullValue();
}
bool
WebGLContext::ValidateTargetParameter(WebGLenum target, const char* infos)
{
if (target != LOCAL_GL_ANY_SAMPLES_PASSED &&
target != LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE)
{
ErrorInvalidEnum("%s: target must be ANY_SAMPLES_PASSED{_CONSERVATIVE}", infos);
return false;
}
return true;
}
WebGLRefPtr<WebGLQuery>&
WebGLContext::GetActiveQueryByTarget(WebGLenum target)
{
MOZ_ASSERT(ValidateTargetParameter(target, "private WebGLContext::GetActiveQueryByTarget"));
return mActiveOcclusionQuery;
}

View File

@ -1078,9 +1078,11 @@ WebGLContext::InitAndValidateGL()
!IsExtensionSupported(WEBGL_draw_buffers) ||
!gl->IsExtensionSupported(gl::GLContext::EXT_gpu_shader4) ||
!gl->IsExtensionSupported(gl::GLContext::EXT_blend_minmax) ||
!gl->IsExtensionSupported(gl::GLContext::XXX_draw_instanced)
!gl->IsExtensionSupported(gl::GLContext::XXX_draw_instanced) ||
(gl->IsGLES2() && !gl->IsExtensionSupported(gl::GLContext::EXT_occlusion_query_boolean))
))
{
// Todo: Bug 898404: Only allow WebGL2 on GL>=3.0 on desktop GL.
return false;
}

View File

@ -0,0 +1,45 @@
/* -*- 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 "WebGLContext.h"
#include "WebGLQuery.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "nsContentUtils.h"
using namespace mozilla;
JSObject*
WebGLQuery::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) {
return dom::WebGLQueryBinding::Wrap(cx, scope, this);
}
WebGLQuery::WebGLQuery(WebGLContext* context)
: WebGLContextBoundObject(context)
, mGLName(0)
, mType(0)
{
SetIsDOMBinding();
mContext->mQueries.insertBack(this);
mContext->MakeContextCurrent();
mContext->gl->fGenQueries(1, &mGLName);
}
void WebGLQuery::Delete() {
mContext->MakeContextCurrent();
mContext->gl->fDeleteQueries(1, &mGLName);
LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebGLQuery)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebGLQuery)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLQuery)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END

View File

@ -0,0 +1,89 @@
/* -*- Mode: C++; tab-width: 4; 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/. */
#ifndef WEBGLQUERY_H_
#define WEBGLQUERY_H_
#include "WebGLObjectModel.h"
#include "WebGLContext.h"
#include "nsWrapperCache.h"
#include "mozilla/LinkedList.h"
namespace mozilla {
class WebGLQuery MOZ_FINAL
: public nsISupports
, public WebGLRefCountedObject<WebGLQuery>
, public LinkedListElement<WebGLQuery>
, public WebGLContextBoundObject
, public nsWrapperCache
{
// -----------------------------------------------------------------------------
// PUBLIC
public:
// -------------------------------------------------------------------------
// CONSTRUCTOR & DESTRUCTOR
WebGLQuery(WebGLContext *context);
~WebGLQuery() {
DeleteOnce();
};
// -------------------------------------------------------------------------
// MEMBER FUNCTIONS
bool IsActive() const
{
return mContext->GetActiveQueryByTarget(mType) == this;
}
bool HasEverBeenActive()
{
return mType != 0;
}
// -------------------------------------------------------------------------
// IMPLEMENT WebGLRefCountedObject and WebGLContextBoundObject
void Delete();
WebGLContext* GetParentObject() const
{
return Context();
}
// -------------------------------------------------------------------------
// IMPLEMENT NS
virtual JSObject* WrapObject(JSContext *cx,
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WebGLQuery)
// -----------------------------------------------------------------------------
// PRIVATE
private:
// -------------------------------------------------------------------------
// MEMBERS
WebGLuint mGLName;
WebGLenum mType;
// -------------------------------------------------------------------------
// FRIENDSHIPS
friend class WebGLContext;
};
} // namespace mozilla
#endif

View File

@ -31,6 +31,7 @@ if CONFIG['MOZ_WEBGL']:
'WebGL1Context.cpp',
'WebGL2Context.cpp',
'WebGLContext.cpp',
'WebGLContextAsyncQueries.cpp',
'WebGLContextGL.cpp',
'WebGLContextUtils.cpp',
'WebGLContextReporter.cpp',
@ -56,6 +57,7 @@ if CONFIG['MOZ_WEBGL']:
'WebGLFramebuffer.cpp',
'WebGLObjectModel.cpp',
'WebGLProgram.cpp',
'WebGLQuery.cpp',
'WebGLRenderbuffer.cpp',
'WebGLShader.cpp',
'WebGLShaderPrecisionFormat.cpp',

View File

@ -1275,6 +1275,11 @@ DOMInterfaces = {
'headerFile': 'WebGLProgram.h'
},
'WebGLQuery': {
'nativeType': 'mozilla::WebGLQuery',
'headerFile': 'WebGLQuery.h'
},
'WebGLRenderbuffer': {
'nativeType': 'mozilla::WebGLRenderbuffer',
'headerFile': 'WebGLRenderbuffer.h'

View File

@ -3,9 +3,13 @@
* 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/.
*
* This IDL depend on WebGLRenderingContext.webidl
* This IDL depends on WebGLRenderingContext.webidl
*/
[Pref="webgl.enable-prototype-webgl2"]
interface WebGLQuery {
};
[Pref="webgl.enable-prototype-webgl2"]
interface WebGL2RenderingContext : WebGLRenderingContext {
@ -53,13 +57,27 @@ interface WebGL2RenderingContext : WebGLRenderingContext {
const GLenum MIN = 0x8007;
const GLenum MAX = 0x8008;
/* query objects */
const GLenum ANY_SAMPLES_PASSED = 0x8C2F;
const GLenum ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A;
const GLenum CURRENT_QUERY = 0x8865;
const GLenum QUERY_RESULT = 0x8866;
const GLenum QUERY_RESULT_AVAILABLE = 0x8867;
void beginQuery(GLenum target, WebGLQuery? queryObject);
void bindVertexArray(WebGLVertexArray? arrayObject);
WebGLQuery? createQuery();
WebGLVertexArray? createVertexArray();
void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
void drawBuffers(sequence<GLenum> buffers);
void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei primcount);
void deleteQuery(WebGLQuery? queryObject);
void deleteVertexArray(WebGLVertexArray? arrayObject);
void endQuery(GLenum target);
WebGLQuery? getQuery(GLenum target, GLenum pname);
any getQueryObject(WebGLQuery? queryObject, GLenum pname);
[WebGLHandlesContextLoss] GLboolean isQuery(WebGLQuery? queryObject);
[WebGLHandlesContextLoss] GLboolean isVertexArray(WebGLVertexArray? arrayObject);
};

View File

@ -98,6 +98,7 @@ static const char *sExtensionNames[] = {
"GL_EXT_draw_instanced",
"GL_NV_draw_instanced",
"GL_ANGLE_instanced_array",
"GL_EXT_occlusion_query_boolean",
nullptr
};
@ -321,6 +322,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (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 } },
@ -632,6 +634,35 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
}
}
if (IsGLES2() &&
IsExtensionSupported(EXT_occlusion_query_boolean)) {
SymLoadStruct queryObjectsSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", "BeginQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueries", "GenQueriesEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueries", "DeleteQueriesEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQuery", "EndQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryiv", "GetQueryivEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuiv", "GetQueryObjectuivEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQuery", "IsQueryEXT", nullptr } },
{ nullptr, { nullptr } },
};
if (!LoadSymbols(queryObjectsSymbols, trygl, prefix)) {
NS_ERROR("GL ES supports query objects without supplying its functions.");
MarkExtensionUnsupported(EXT_occlusion_query_boolean);
mSymbols.fBeginQuery = nullptr;
mSymbols.fGenQueries = nullptr;
mSymbols.fDeleteQueries = nullptr;
mSymbols.fEndQuery = nullptr;
mSymbols.fGetQueryiv = nullptr;
mSymbols.fGetQueryObjectiv = nullptr;
mSymbols.fGetQueryObjectuiv = nullptr;
mSymbols.fIsQuery = nullptr;
}
}
// Load developer symbols, don't fail if we can't find them.
SymLoadStruct auxSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetTexImage, { "GetTexImage", nullptr } },

View File

@ -381,6 +381,7 @@ public:
EXT_draw_instanced,
NV_draw_instanced,
ANGLE_instanced_array,
EXT_occlusion_query_boolean,
Extensions_Max,
Extensions_End
};
@ -732,6 +733,7 @@ public:
void fBeginQuery(GLenum target, GLuint id) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fBeginQuery);
mSymbols.fBeginQuery(target, id);
AFTER_GL_CALL;
}
@ -991,6 +993,7 @@ public:
void fEndQuery(GLenum target) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fEndQuery);
mSymbols.fEndQuery(target);
AFTER_GL_CALL;
}
@ -1040,18 +1043,21 @@ public:
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;
}
@ -1264,6 +1270,14 @@ 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);
@ -1826,6 +1840,7 @@ private:
void GLAPIENTRY raw_fGenQueries(GLsizei n, GLuint* names) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGenQueries);
mSymbols.fGenQueries(n, names);
AFTER_GL_CALL;
}
@ -1919,6 +1934,7 @@ private:
void GLAPIENTRY raw_fDeleteQueries(GLsizei n, GLuint* names) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fDeleteQueries);
mSymbols.fDeleteQueries(n, names);
AFTER_GL_CALL;
}

View File

@ -173,6 +173,8 @@ struct GLContextSymbols
PFNGLISENABLEDPROC fIsEnabled;
typedef realGLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program);
PFNGLISPROGRAMPROC fIsProgram;
typedef realGLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id);
PFNGLISQUERYPROC fIsQuery;
typedef realGLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader);
PFNGLISSHADERPROC fIsShader;
typedef realGLboolean (GLAPIENTRY * PFNGLISTEXTUREPROC) (GLuint texture);

View File

@ -3049,6 +3049,12 @@ typedef uint64_t EGLTime;
#define LOCAL_GL_CONDITION_SATISFIED 0x911C
#define LOCAL_GL_WAIT_FAILED 0x911D
// ARB_occlusion_query2
#define LOCAL_GL_ANY_SAMPLES_PASSED 0x8C2F
// EXT_occlusion_query_boolean
#define LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
// OES_EGL_image_external
#define LOCAL_GL_TEXTURE_EXTERNAL 0x8D65