1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "WebGL2Context.h"
10 #include "mozilla/StaticPrefs_webgl.h"
14 // -------------------------------------------------------------------------
17 RefPtr
<WebGLSync
> WebGL2Context::FenceSync(GLenum condition
, GLbitfield flags
) {
18 const FuncScope
funcScope(*this, "fenceSync");
19 if (IsContextLost()) return nullptr;
21 if (condition
!= LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE
) {
22 ErrorInvalidEnum("condition must be SYNC_GPU_COMMANDS_COMPLETE");
27 ErrorInvalidValue("flags must be 0");
31 RefPtr
<WebGLSync
> globj
= new WebGLSync(this, condition
, flags
);
35 GLenum
WebGL2Context::ClientWaitSync(const WebGLSync
& sync
, GLbitfield flags
,
37 const FuncScope
funcScope(*this, "clientWaitSync");
38 if (IsContextLost()) return LOCAL_GL_WAIT_FAILED
;
40 if (!ValidateObject("sync", sync
)) return LOCAL_GL_WAIT_FAILED
;
42 if (flags
!= 0 && flags
!= LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT
) {
43 ErrorInvalidValue("`flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.");
44 return LOCAL_GL_WAIT_FAILED
;
47 if (timeout
> kMaxClientWaitSyncTimeoutNS
) {
48 ErrorInvalidOperation("`timeout` must not exceed %s nanoseconds.",
49 "MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
50 return LOCAL_GL_WAIT_FAILED
;
53 const auto ret
= gl
->fClientWaitSync(sync
.mGLName
, flags
, timeout
);
55 if (ret
== LOCAL_GL_CONDITION_SATISFIED
|| ret
== LOCAL_GL_ALREADY_SIGNALED
) {
62 } // namespace mozilla