2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-09-18 02:08:41 +04:00
|
|
|
/* 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"
|
2014-06-18 08:25:53 +04:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
#include "GLContext.h"
|
2014-06-18 08:25:53 +04:00
|
|
|
#include "WebGLSync.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_webgl.h"
|
2014-09-18 02:08:41 +04:00
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
namespace mozilla {
|
2014-09-18 02:08:41 +04:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Sync objects
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
RefPtr<WebGLSync> WebGL2Context::FenceSync(GLenum condition, GLbitfield flags) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "fenceSync");
|
2016-11-30 05:30:28 +03:00
|
|
|
if (IsContextLost()) return nullptr;
|
|
|
|
|
|
|
|
if (condition != LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE) {
|
2018-07-27 07:46:33 +03:00
|
|
|
ErrorInvalidEnum("condition must be SYNC_GPU_COMMANDS_COMPLETE");
|
2016-11-30 05:30:28 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags != 0) {
|
|
|
|
ErrorInvalidValue("flags must be 0");
|
|
|
|
return nullptr;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2018-02-21 04:34:25 +03:00
|
|
|
|
|
|
|
RefPtr<WebGLSync> globj = new WebGLSync(this, condition, flags);
|
2020-01-09 01:19:16 +03:00
|
|
|
return globj;
|
2014-06-18 08:25:53 +04:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
GLenum WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags,
|
|
|
|
GLuint64 timeout) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "clientWaitSync");
|
2014-06-18 08:25:53 +04:00
|
|
|
if (IsContextLost()) return LOCAL_GL_WAIT_FAILED;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
if (!ValidateObject("sync", sync)) return LOCAL_GL_WAIT_FAILED;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-06-18 08:25:53 +04:00
|
|
|
if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
|
2018-07-27 07:46:33 +03:00
|
|
|
ErrorInvalidValue("`flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.");
|
2014-06-18 08:25:53 +04:00
|
|
|
return LOCAL_GL_WAIT_FAILED;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2016-12-20 06:31:18 +03:00
|
|
|
if (timeout > kMaxClientWaitSyncTimeoutNS) {
|
2018-07-27 07:46:33 +03:00
|
|
|
ErrorInvalidOperation("`timeout` must not exceed %s nanoseconds.",
|
2016-12-20 06:31:18 +03:00
|
|
|
"MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
|
|
|
|
return LOCAL_GL_WAIT_FAILED;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2018-02-21 04:34:25 +03:00
|
|
|
const auto ret = gl->fClientWaitSync(sync.mGLName, flags, timeout);
|
|
|
|
|
2017-12-15 20:47:29 +03:00
|
|
|
if (ret == LOCAL_GL_CONDITION_SATISFIED || ret == LOCAL_GL_ALREADY_SIGNALED) {
|
|
|
|
sync.MarkSignaled();
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2017-12-15 20:47:29 +03:00
|
|
|
|
|
|
|
return ret;
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
} // namespace mozilla
|