2014-03-08 01:26:17 +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 "WebGLExtensions.h"
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
|
|
|
#include "WebGLContext.h"
|
2015-07-17 03:27:26 +03:00
|
|
|
#include "WebGLFormats.h"
|
2014-03-08 01:26:17 +04:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
#ifdef FOO
|
|
|
|
#error FOO is already defined! We use FOO() macros to keep things succinct in this file.
|
|
|
|
#endif
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
namespace mozilla {
|
2015-11-24 08:55:59 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLExtensionColorBufferFloat::WebGLExtensionColorBufferFloat(WebGLContext* webgl)
|
|
|
|
: WebGLExtensionBase(webgl)
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
auto& fua = webgl->mFormatUsage;
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
auto fnUpdateUsage = [&fua](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
|
|
|
|
auto usage = fua->EditUsage(effFormat);
|
2016-06-06 23:43:18 +03:00
|
|
|
usage->SetRenderable();
|
2015-11-25 07:15:29 +03:00
|
|
|
fua->AllowRBFormat(sizedFormat, usage);
|
2015-07-17 03:27:26 +03:00
|
|
|
};
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
#define FOO(x) fnUpdateUsage(LOCAL_GL_ ## x, webgl::EffectiveFormat::x)
|
|
|
|
|
|
|
|
// The extension doesn't actually add RGB32F; only RGBA32F.
|
|
|
|
FOO(RGBA32F);
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
#undef FOO
|
2014-03-08 01:26:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WebGLExtensionColorBufferFloat::~WebGLExtensionColorBufferFloat()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLExtensionColorBufferFloat::IsSupported(const WebGLContext* webgl)
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
2017-12-23 00:21:26 +03:00
|
|
|
const auto& gl = webgl->gl;
|
|
|
|
if (gl->IsANGLE()) {
|
|
|
|
// ANGLE supports this, but doesn't have a way to advertize its support,
|
|
|
|
// since it's compliant with WEBGL_color_buffer_float's clamping, but not
|
|
|
|
// EXT_color_buffer_float.
|
|
|
|
// TODO: This probably isn't necessary anymore.
|
|
|
|
return true;
|
|
|
|
}
|
2014-11-22 02:04:08 +03:00
|
|
|
|
2017-12-23 00:21:26 +03:00
|
|
|
return gl->IsSupported(gl::GLFeature::renderbuffer_color_float) &&
|
|
|
|
gl->IsSupported(gl::GLFeature::frag_color_float);
|
2014-03-08 01:26:17 +04:00
|
|
|
}
|
|
|
|
|
2015-06-01 17:17:00 +03:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferFloat, WEBGL_color_buffer_float)
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|