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"
9 #include "js/Array.h" // JS::NewArrayObject
10 #include "mozilla/dom/WebGL2RenderingContextBinding.h"
11 #include "mozilla/RefPtr.h"
12 #include "WebGLBuffer.h"
13 #include "WebGLContext.h"
14 #include "WebGLProgram.h"
15 #include "WebGLTransformFeedback.h"
16 #include "WebGLVertexArray.h"
20 // -------------------------------------------------------------------------
21 // Uniform Buffer Objects and Transform Feedback Buffers
23 Maybe
<double> WebGL2Context::GetIndexedParameter(const GLenum pname
,
24 const uint32_t index
) const {
25 const FuncScope
funcScope(*this, "getIndexedParameter");
26 if (IsContextLost()) return {};
28 const auto* bindings
= &mIndexedUniformBufferBindings
;
29 const char* limitStr
= "MAX_UNIFORM_BUFFER_BINDINGS";
31 case LOCAL_GL_UNIFORM_BUFFER_START
:
32 case LOCAL_GL_UNIFORM_BUFFER_SIZE
:
35 case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_START
:
36 case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
37 bindings
= &(mBoundTransformFeedback
->mIndexedBindings
);
38 limitStr
= "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS";
42 ErrorInvalidEnumInfo("pname", pname
);
46 if (index
>= bindings
->size()) {
47 ErrorInvalidValue("`index` must be < %s.", limitStr
);
50 const auto& binding
= (*bindings
)[index
];
53 case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_START
:
54 case LOCAL_GL_UNIFORM_BUFFER_START
:
55 return Some(binding
.mRangeStart
);
58 case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE
:
59 case LOCAL_GL_UNIFORM_BUFFER_SIZE
:
60 return Some(binding
.mRangeSize
);
63 MOZ_CRASH("impossible");
67 void WebGL2Context::UniformBlockBinding(WebGLProgram
& program
,
68 GLuint uniformBlockIndex
,
69 GLuint uniformBlockBinding
) {
70 const FuncScope
funcScope(*this, "uniformBlockBinding");
71 if (IsContextLost()) return;
73 if (!ValidateObject("program", program
)) return;
75 program
.UniformBlockBinding(uniformBlockIndex
, uniformBlockBinding
);
78 } // namespace mozilla