1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "WebGL2Context.h"
10 #include "WebGLContextUtils.h"
11 #include "WebGLFormats.h"
15 Maybe
<std::vector
<int32_t>> WebGL2Context::GetInternalformatParameter(
16 GLenum target
, GLenum internalformat
, GLenum pname
) const {
17 const FuncScope
funcScope(*this, "getInternalfomratParameter");
18 if (IsContextLost()) return Nothing();
20 if (target
!= LOCAL_GL_RENDERBUFFER
) {
21 ErrorInvalidEnum("`target` must be RENDERBUFFER.");
25 // GLES 3.0.4 $4.4.4 p212:
26 // "An internal format is color-renderable if it is one of the formats from
28 // noted as color-renderable or if it is unsized format RGBA or RGB."
31 switch (internalformat
) {
33 sizedFormat
= LOCAL_GL_RGB8
;
36 sizedFormat
= LOCAL_GL_RGBA8
;
39 sizedFormat
= internalformat
;
43 // In RenderbufferStorage, we allow DEPTH_STENCIL. Therefore, it is accepted
44 // for internalformat as well. Please ignore the conformance test fail for
47 const auto usage
= mFormatUsage
->GetRBUsage(sizedFormat
);
50 "`internalformat` must be color-, depth-, or stencil-renderable, was: "
56 if (pname
!= LOCAL_GL_SAMPLES
) {
57 ErrorInvalidEnum("`pname` must be SAMPLES.");
61 std::vector
<int32_t> ret
;
62 GLint sampleCount
= 0;
63 gl
->fGetInternalformativ(LOCAL_GL_RENDERBUFFER
, internalformat
,
64 LOCAL_GL_NUM_SAMPLE_COUNTS
, 1, &sampleCount
);
66 ret
.resize(sampleCount
);
67 gl
->fGetInternalformativ(LOCAL_GL_RENDERBUFFER
, internalformat
,
68 LOCAL_GL_SAMPLES
, ret
.size(), ret
.data());
74 } // namespace mozilla