1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "WebGLExtensions.h"
8 #include "mozilla/dom/WebGLRenderingContextBinding.h"
9 #include "WebGLContext.h"
10 #include "WebGLFormats.h"
14 WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(
16 : WebGLExtensionBase(webgl
) {
17 MOZ_ASSERT(IsSupported(webgl
), "Don't construct extension if unsupported.");
18 SetRenderable(webgl::FormatRenderableState::Implicit(
19 WebGLExtensionID::EXT_color_buffer_half_float
));
22 void WebGLExtensionColorBufferHalfFloat::SetRenderable(
23 const webgl::FormatRenderableState state
) {
24 auto& fua
= mContext
->mFormatUsage
;
26 auto fnUpdateUsage
= [&](GLenum sizedFormat
, webgl::EffectiveFormat effFormat
,
27 const bool renderable
) {
28 auto usage
= fua
->EditUsage(effFormat
);
30 usage
->SetRenderable(state
);
32 fua
->AllowRBFormat(sizedFormat
, usage
, renderable
);
35 #define FOO(x, y) fnUpdateUsage(LOCAL_GL_##x, webgl::EffectiveFormat::x, y)
38 FOO(RGB16F
, false); // It's not required, thus not portable. (Also there's a
39 // wicked driver bug on Mac+Intel)
44 void WebGLExtensionColorBufferHalfFloat::OnSetExplicit() {
45 SetRenderable(webgl::FormatRenderableState::Explicit());
48 bool WebGLExtensionColorBufferHalfFloat::IsSupported(
49 const WebGLContext
* webgl
) {
50 if (webgl
->IsWebGL2()) return false;
52 const auto& gl
= webgl
->gl
;
53 return gl
->IsSupported(gl::GLFeature::renderbuffer_color_half_float
) &&
54 gl
->IsSupported(gl::GLFeature::frag_color_float
);
57 } // namespace mozilla