forked from mirrors/gecko-dev
(This is a combination of 31 commits) * Fix Linux compilation. * Fix mac compilation. * CI compile fixes. * printf's size_t is %zu. %tu would be unsigned ptrdiff_t. * No non-ref Maybe args. * MOZ_CRASH for noreturn * Handle implied texture sizes, rewrite comment stripping. * Replace e.g. WebGLProgramInner with simpler webgl::ProgramKeepAlive. * Bounce ValidateProgram call off driver. * Uniform name length limit, cubemap fb-attach, non-array uniforms, undersized texImage views. * alignas for uint8_t[sizeof(float)*N] pun buffers. * CC fixes? * Fill attrib0Active. * Repair max-warnings limit. * This is basically required in order for CI's logging to not explode. * Don't cache WebGLMemoryTracker. * Deleted prog/shader error, no texSubImage(null), client-side fingerprint resist for exts. * Fix GetUniformIndices and MakeRangeFromView. * CC Traverse base class from within derived class to fix leaking the world. :( * PauseTransformFeedback * TexImage video fastpath * GetFragLocation for arrays * Forbid BindBufferRange during TF * Mark tests and fix RBAB query and test. * Change(!) query deletion behavior to match spec. * Mark conformance2/query/query.html failing for now. * Implicitly EndQuery on DeleteQuery while spec is in flux. * Fix error code for test. * RAII LruPosition for WebGL context limit. * Include std::list. * Mark CompileResult and LinkResult.pending as false when retrieved. * Hold strong-ref to NotLostData during Run<> to prevent LoseContext=>UAF. * Don't assume GetUniformLocation(foo+'[0]') means foo is an array. * Don't assume !mCanvasElement means !!mOffscreenCanvas. * Handle composition while context-lost. * All non-value-init members must be const or have inline init. * Mark passing tests on Linux. Depends on D54019 Differential Revision: https://phabricator.services.mozilla.com/D55739 --HG-- extra : moz-landing-system : lando
119 lines
3.2 KiB
C++
119 lines
3.2 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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 "WebGL2Context.h"
|
|
#include "GLContext.h"
|
|
#include "WebGLQuery.h"
|
|
#include "nsThreadUtils.h"
|
|
|
|
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.
|
|
*/
|
|
|
|
RefPtr<WebGLQuery>* WebGLContext::ValidateQuerySlotByTarget(GLenum target) {
|
|
if (IsWebGL2()) {
|
|
switch (target) {
|
|
case LOCAL_GL_ANY_SAMPLES_PASSED:
|
|
case LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
|
|
return &mQuerySlot_SamplesPassed;
|
|
|
|
case LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
|
return &mQuerySlot_TFPrimsWritten;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (IsExtensionEnabled(WebGLExtensionID::EXT_disjoint_timer_query)) {
|
|
switch (target) {
|
|
case LOCAL_GL_TIME_ELAPSED_EXT:
|
|
return &mQuerySlot_TimeElapsed;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
ErrorInvalidEnumInfo("target", target);
|
|
return nullptr;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Query Objects
|
|
|
|
RefPtr<WebGLQuery> WebGLContext::CreateQuery() {
|
|
const FuncScope funcScope(*this, "createQuery");
|
|
if (IsContextLost()) return nullptr;
|
|
|
|
return new WebGLQuery(this);
|
|
}
|
|
|
|
void WebGLContext::BeginQuery(GLenum target, WebGLQuery& query) {
|
|
FuncScope funcScope(*this, "beginQuery");
|
|
if (IsContextLost()) return;
|
|
funcScope.mBindFailureGuard = true;
|
|
|
|
const auto& slot = ValidateQuerySlotByTarget(target);
|
|
if (!slot) return;
|
|
|
|
if (*slot) return ErrorInvalidOperation("Query target already active.");
|
|
|
|
const auto& curTarget = query.Target();
|
|
if (curTarget && target != curTarget) {
|
|
ErrorInvalidOperation("Queries cannot change targets.");
|
|
return;
|
|
}
|
|
|
|
////
|
|
|
|
query.BeginQuery(target, *slot);
|
|
|
|
funcScope.mBindFailureGuard = false;
|
|
}
|
|
|
|
void WebGLContext::EndQuery(GLenum target) {
|
|
FuncScope funcScope(*this, "endQuery");
|
|
if (IsContextLost()) return;
|
|
funcScope.mBindFailureGuard = true;
|
|
|
|
const auto& slot = ValidateQuerySlotByTarget(target);
|
|
if (!slot) return;
|
|
|
|
const auto query = *slot; // Grab a strong reference.
|
|
if (!query) return ErrorInvalidOperation("Query target not active.");
|
|
|
|
query->EndQuery();
|
|
|
|
funcScope.mBindFailureGuard = false;
|
|
}
|
|
|
|
Maybe<double> WebGLContext::GetQueryParameter(const WebGLQuery& query,
|
|
GLenum pname) const {
|
|
const FuncScope funcScope(*this, "getQueryParameter");
|
|
if (IsContextLost()) return Nothing();
|
|
|
|
return query.GetQueryParameter(pname);
|
|
}
|
|
|
|
// disjoint_timer_queries
|
|
|
|
void WebGLContext::QueryCounter(WebGLQuery& query) const {
|
|
const WebGLContext::FuncScope funcScope(*this, "queryCounterEXT");
|
|
if (IsContextLost()) return;
|
|
|
|
query.QueryCounter();
|
|
}
|
|
|
|
} // namespace mozilla
|