зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1155470 - Fix queries. r=jgilbert
es3fTransformFeedbackTests exposed problems with queries. Queries are needed to get the number of transformed primitives.
This commit is contained in:
Родитель
5500eadc0e
Коммит
603c0dca5a
|
@ -31,6 +31,13 @@ WebGL1Context::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
|
||||||
return dom::WebGLRenderingContextBinding::Wrap(cx, this, aGivenProto);
|
return dom::WebGLRenderingContextBinding::Wrap(cx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
WebGL1Context::ValidateQueryTarget(GLenum target, const char* info)
|
||||||
|
{
|
||||||
|
// TODO: Implement this for EXT_disjoint_timer
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -35,7 +35,7 @@ private:
|
||||||
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
|
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
|
||||||
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
|
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
|
||||||
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) override;
|
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) override;
|
||||||
|
virtual bool ValidateQueryTarget(GLenum target, const char* info) override;
|
||||||
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
|
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -355,6 +355,8 @@ private:
|
||||||
|
|
||||||
JS::Value GetTexParameterInternal(const TexTarget& target, GLenum pname) override;
|
JS::Value GetTexParameterInternal(const TexTarget& target, GLenum pname) override;
|
||||||
|
|
||||||
|
void UpdateBoundQuery(GLenum target, WebGLQuery* query);
|
||||||
|
|
||||||
bool ValidateSizedInternalFormat(GLenum internalFormat, const char* info);
|
bool ValidateSizedInternalFormat(GLenum internalFormat, const char* info);
|
||||||
bool ValidateTexStorage(GLenum target, GLsizei levels, GLenum internalformat,
|
bool ValidateTexStorage(GLenum target, GLsizei levels, GLenum internalformat,
|
||||||
GLsizei width, GLsizei height, GLsizei depth,
|
GLsizei width, GLsizei height, GLsizei depth,
|
||||||
|
@ -365,7 +367,7 @@ private:
|
||||||
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
|
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
|
||||||
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
|
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
|
||||||
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) override;
|
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) override;
|
||||||
|
virtual bool ValidateQueryTarget(GLenum target, const char* info) override;
|
||||||
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
|
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#include "GLContext.h"
|
#include "GLContext.h"
|
||||||
#include "WebGLQuery.h"
|
#include "WebGLQuery.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
namespace mozilla {
|
||||||
using namespace mozilla::dom;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We fake ANY_SAMPLES_PASSED and ANY_SAMPLES_PASSED_CONSERVATIVE with
|
* We fake ANY_SAMPLES_PASSED and ANY_SAMPLES_PASSED_CONSERVATIVE with
|
||||||
|
@ -26,14 +25,14 @@ GetQueryTargetEnumString(GLenum target)
|
||||||
{
|
{
|
||||||
switch (target)
|
switch (target)
|
||||||
{
|
{
|
||||||
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
||||||
return "ANY_SAMPLES_PASSED";
|
return "ANY_SAMPLES_PASSED";
|
||||||
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
|
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
|
||||||
return "ANY_SAMPLES_PASSED_CONSERVATIVE";
|
return "ANY_SAMPLES_PASSED_CONSERVATIVE";
|
||||||
case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
||||||
return "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN";
|
return "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN";
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(false, "Unknown query `target`.");
|
MOZ_ASSERT(false, "Unknown query `target`.");
|
||||||
|
@ -56,19 +55,23 @@ SimulateOcclusionQueryTarget(const gl::GLContext* gl, GLenum target)
|
||||||
return LOCAL_GL_SAMPLES_PASSED;
|
return LOCAL_GL_SAMPLES_PASSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebGLRefPtr<WebGLQuery>*
|
WebGLRefPtr<WebGLQuery>&
|
||||||
WebGLContext::GetQueryTargetSlot(GLenum target)
|
WebGLContext::GetQuerySlotByTarget(GLenum target)
|
||||||
{
|
{
|
||||||
|
/* This function assumes that target has been validated for either
|
||||||
|
* WebGL1 or WebGL2.
|
||||||
|
*/
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
||||||
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
|
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
|
||||||
return &mActiveOcclusionQuery;
|
return mActiveOcclusionQuery;
|
||||||
|
|
||||||
case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
||||||
return &mActiveTransformFeedbackQuery;
|
return mActiveTransformFeedbackQuery;
|
||||||
|
|
||||||
|
default:
|
||||||
|
MOZ_CRASH("Should not get here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,11 +155,8 @@ WebGL2Context::BeginQuery(GLenum target, WebGLQuery* query)
|
||||||
if (IsContextLost())
|
if (IsContextLost())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target);
|
if (!ValidateQueryTarget(target, "beginQuery"))
|
||||||
if (!targetSlot) {
|
|
||||||
ErrorInvalidEnum("beginQuery: unknown query target");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
/* From GLES's EXT_occlusion_query_boolean:
|
/* From GLES's EXT_occlusion_query_boolean:
|
||||||
|
@ -193,10 +193,10 @@ WebGL2Context::BeginQuery(GLenum target, WebGLQuery* query)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*targetSlot) {
|
WebGLRefPtr<WebGLQuery>& querySlot = GetQuerySlotByTarget(target);
|
||||||
ErrorInvalidOperation("beginQuery: An other query already active.");
|
WebGLQuery* activeQuery = querySlot.get();
|
||||||
return;
|
if (activeQuery)
|
||||||
}
|
return ErrorInvalidOperation("beginQuery: An other query already active.");
|
||||||
|
|
||||||
if (!query->HasEverBeenActive())
|
if (!query->HasEverBeenActive())
|
||||||
query->mType = target;
|
query->mType = target;
|
||||||
|
@ -211,7 +211,7 @@ WebGL2Context::BeginQuery(GLenum target, WebGLQuery* query)
|
||||||
query->mGLName);
|
query->mGLName);
|
||||||
}
|
}
|
||||||
|
|
||||||
*targetSlot = query;
|
UpdateBoundQuery(target, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -220,14 +220,13 @@ WebGL2Context::EndQuery(GLenum target)
|
||||||
if (IsContextLost())
|
if (IsContextLost())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target);
|
if (!ValidateQueryTarget(target, "endQuery"))
|
||||||
if (!targetSlot) {
|
|
||||||
ErrorInvalidEnum("endQuery: unknown query target");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!*targetSlot ||
|
WebGLRefPtr<WebGLQuery>& querySlot = GetQuerySlotByTarget(target);
|
||||||
target != (*targetSlot)->mType)
|
WebGLQuery* activeQuery = querySlot.get();
|
||||||
|
|
||||||
|
if (!activeQuery || target != activeQuery->mType)
|
||||||
{
|
{
|
||||||
/* From GLES's EXT_occlusion_query_boolean:
|
/* From GLES's EXT_occlusion_query_boolean:
|
||||||
* marks the end of the sequence of commands to be tracked for the
|
* marks the end of the sequence of commands to be tracked for the
|
||||||
|
@ -255,7 +254,7 @@ WebGL2Context::EndQuery(GLenum target)
|
||||||
gl->fEndQuery(SimulateOcclusionQueryTarget(gl, target));
|
gl->fEndQuery(SimulateOcclusionQueryTarget(gl, target));
|
||||||
}
|
}
|
||||||
|
|
||||||
*targetSlot = nullptr;
|
UpdateBoundQuery(target, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<WebGLQuery>
|
already_AddRefed<WebGLQuery>
|
||||||
|
@ -264,11 +263,8 @@ WebGL2Context::GetQuery(GLenum target, GLenum pname)
|
||||||
if (IsContextLost())
|
if (IsContextLost())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target);
|
if (!ValidateQueryTarget(target, "getQuery"))
|
||||||
if (!targetSlot) {
|
|
||||||
ErrorInvalidEnum("getQuery: unknown query target");
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
if (pname != LOCAL_GL_CURRENT_QUERY) {
|
if (pname != LOCAL_GL_CURRENT_QUERY) {
|
||||||
/* OpenGL ES 3.0 spec 6.1.7:
|
/* OpenGL ES 3.0 spec 6.1.7:
|
||||||
|
@ -278,7 +274,9 @@ WebGL2Context::GetQuery(GLenum target, GLenum pname)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<WebGLQuery> tmp = targetSlot->get();
|
WebGLRefPtr<WebGLQuery>& targetSlot = GetQuerySlotByTarget(target);
|
||||||
|
|
||||||
|
nsRefPtr<WebGLQuery> tmp = targetSlot.get();
|
||||||
return tmp.forget();
|
return tmp.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,3 +351,27 @@ WebGL2Context::GetQueryParameter(JSContext*, WebGLQuery* query, GLenum pname,
|
||||||
|
|
||||||
ErrorInvalidEnum("getQueryObject: `pname` must be QUERY_RESULT{_AVAILABLE}.");
|
ErrorInvalidEnum("getQueryObject: `pname` must be QUERY_RESULT{_AVAILABLE}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WebGL2Context::UpdateBoundQuery(GLenum target, WebGLQuery* query)
|
||||||
|
{
|
||||||
|
WebGLRefPtr<WebGLQuery>& querySlot = GetQuerySlotByTarget(target);
|
||||||
|
querySlot = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
WebGL2Context::ValidateQueryTarget(GLenum target, const char* info)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
||||||
|
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
|
||||||
|
case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ErrorInvalidEnumInfo(info, target);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mozilla
|
||||||
|
|
|
@ -936,7 +936,7 @@ protected:
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Queries (WebGL2ContextQueries.cpp)
|
// Queries (WebGL2ContextQueries.cpp)
|
||||||
protected:
|
protected:
|
||||||
WebGLRefPtr<WebGLQuery>* GetQueryTargetSlot(GLenum target);
|
WebGLRefPtr<WebGLQuery>& GetQuerySlotByTarget(GLenum target);
|
||||||
|
|
||||||
WebGLRefPtr<WebGLQuery> mActiveOcclusionQuery;
|
WebGLRefPtr<WebGLQuery> mActiveOcclusionQuery;
|
||||||
WebGLRefPtr<WebGLQuery> mActiveTransformFeedbackQuery;
|
WebGLRefPtr<WebGLQuery> mActiveTransformFeedbackQuery;
|
||||||
|
@ -1389,6 +1389,7 @@ private:
|
||||||
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0;
|
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0;
|
||||||
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) = 0;
|
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) = 0;
|
||||||
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) = 0;
|
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) = 0;
|
||||||
|
virtual bool ValidateQueryTarget(GLenum usage, const char* info) = 0;
|
||||||
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) = 0;
|
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -40,10 +40,9 @@ WebGLQuery::Delete()
|
||||||
bool
|
bool
|
||||||
WebGLQuery::IsActive() const
|
WebGLQuery::IsActive() const
|
||||||
{
|
{
|
||||||
WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType);
|
WebGLRefPtr<WebGLQuery>& targetSlot = mContext->GetQuerySlotByTarget(mType);
|
||||||
|
|
||||||
MOZ_ASSERT(targetSlot, "unknown query object's type");
|
return targetSlot.get() == this;
|
||||||
return targetSlot && *targetSlot == this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче