Bug 1184402 - Part 3: Add WebGL1 formats when enabling extensions. r=jgilbert

This commit is contained in:
Dan Glastonbury 2015-07-17 10:27:26 +10:00
Родитель 7a704c1521
Коммит 2ff8750146
11 изменённых файлов: 202 добавлений и 6 удалений

Просмотреть файл

@ -58,9 +58,7 @@ static const WebGLExtensionID kNativelySupportedExtensions[] = {
WebGLExtensionID::EXT_sRGB,
WebGLExtensionID::OES_element_index_uint,
WebGLExtensionID::OES_standard_derivatives,
WebGLExtensionID::OES_texture_float,
WebGLExtensionID::OES_texture_float_linear,
WebGLExtensionID::OES_texture_half_float,
WebGLExtensionID::OES_texture_half_float_linear,
WebGLExtensionID::OES_vertex_array_object,
WebGLExtensionID::WEBGL_depth_texture,

Просмотреть файл

@ -7,13 +7,34 @@
#include "GLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
WebGLExtensionColorBufferFloat::WebGLExtensionColorBufferFloat(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto updateUsage = [authority](EffectiveFormat effectiveFormat) {
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
MOZ_ASSERT(usage);
usage->asRenderbuffer = usage->isRenderable = true;
};
// Ensure require formats are initialized.
WebGLExtensionTextureFloat::InitWebGLFormats(authority);
// Update usage to allow asRenderbuffer and isRenderable
updateUsage(EffectiveFormat::RGBA32F);
updateUsage(EffectiveFormat::RGB32F);
updateUsage(EffectiveFormat::Luminance32FAlpha32F);
updateUsage(EffectiveFormat::Luminance32F);
updateUsage(EffectiveFormat::Alpha32F);
}
WebGLExtensionColorBufferFloat::~WebGLExtensionColorBufferFloat()

Просмотреть файл

@ -7,13 +7,34 @@
#include "GLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto updateUsage = [authority](EffectiveFormat effectiveFormat) {
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
MOZ_ASSERT(usage);
usage->asRenderbuffer = usage->isRenderable = true;
};
// Ensure require formats are initialized.
WebGLExtensionTextureHalfFloat::InitWebGLFormats(authority);
// Update usage to allow asRenderbuffer and isRenderable
updateUsage(EffectiveFormat::RGBA16F);
updateUsage(EffectiveFormat::RGB16F);
updateUsage(EffectiveFormat::Luminance16FAlpha16F);
updateUsage(EffectiveFormat::Luminance16F);
updateUsage(EffectiveFormat::Alpha16F);
}
WebGLExtensionColorBufferHalfFloat::~WebGLExtensionColorBufferHalfFloat()

Просмотреть файл

@ -8,9 +8,13 @@
#include "GLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
WebGLExtensionSRGB::WebGLExtensionSRGB(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
@ -23,6 +27,21 @@ WebGLExtensionSRGB::WebGLExtensionSRGB(WebGLContext* webgl)
gl->MakeCurrent();
gl->fEnable(LOCAL_GL_FRAMEBUFFER_SRGB_EXT);
}
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto addFormatIfMissing = [authority](EffectiveFormat effectiveFormat,
GLenum unpackFormat, GLenum unpackType,
bool asRenderbuffer)
{
if (!authority->GetUsage(effectiveFormat)) {
authority->AddFormat(effectiveFormat, asRenderbuffer, asRenderbuffer, true, true);
authority->AddUnpackOption(unpackFormat, unpackType, effectiveFormat);
}
};
addFormatIfMissing(EffectiveFormat::SRGB8 , LOCAL_GL_SRGB , LOCAL_GL_UNSIGNED_BYTE, false);
addFormatIfMissing(EffectiveFormat::SRGB8_ALPHA8, LOCAL_GL_SRGB_ALPHA, LOCAL_GL_UNSIGNED_BYTE, true);
}
WebGLExtensionSRGB::~WebGLExtensionSRGB()

Просмотреть файл

@ -6,12 +6,55 @@
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
void
WebGLExtensionTextureFloat::InitWebGLFormats(webgl::FormatUsageAuthority* authority)
{
MOZ_ASSERT(authority);
auto addFormatIfMissing = [authority](EffectiveFormat effectiveFormat)
{
if (!authority->GetUsage(effectiveFormat)) {
authority->AddFormat(effectiveFormat, false, false, false, false);
}
};
// Populate authority with any missing effective formats.
addFormatIfMissing(EffectiveFormat::RGBA32F);
addFormatIfMissing(EffectiveFormat::RGB32F);
addFormatIfMissing(EffectiveFormat::Luminance32FAlpha32F);
addFormatIfMissing(EffectiveFormat::Luminance32F);
addFormatIfMissing(EffectiveFormat::Alpha32F);
}
WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto updateUsage = [authority](EffectiveFormat effectiveFormat,
GLenum unpackFormat, GLenum unpackType)
{
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
MOZ_ASSERT(usage);
usage->asTexture = true;
authority->AddUnpackOption(unpackFormat, unpackType, effectiveFormat);
};
// Ensure require formats are initialized.
InitWebGLFormats(authority);
// Update usage to allow asTexture and add unpack
updateUsage(EffectiveFormat::RGBA32F , LOCAL_GL_RGBA , LOCAL_GL_FLOAT);
updateUsage(EffectiveFormat::RGB32F , LOCAL_GL_RGB , LOCAL_GL_FLOAT);
updateUsage(EffectiveFormat::Luminance32FAlpha32F, LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_FLOAT);
updateUsage(EffectiveFormat::Luminance32F , LOCAL_GL_LUMINANCE , LOCAL_GL_FLOAT);
updateUsage(EffectiveFormat::Alpha32F , LOCAL_GL_ALPHA , LOCAL_GL_FLOAT);
}
WebGLExtensionTextureFloat::~WebGLExtensionTextureFloat()

Просмотреть файл

@ -6,12 +6,36 @@
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
WebGLExtensionTextureFloatLinear::WebGLExtensionTextureFloatLinear(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
// This update requires that the authority already be populated by
// WebGLExtensionTextureFloat. Enabling extensions to control
// features is a mess in WebGL
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto updateUsage = [authority](EffectiveFormat effectiveFormat) {
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
MOZ_ASSERT(usage);
usage->isFilterable = true;
};
// Ensure require formats are initialized.
WebGLExtensionTextureFloat::InitWebGLFormats(authority);
// Update usage to allow isFilterable
updateUsage(EffectiveFormat::RGBA32F);
updateUsage(EffectiveFormat::RGB32F);
updateUsage(EffectiveFormat::Luminance32FAlpha32F);
updateUsage(EffectiveFormat::Luminance32F);
updateUsage(EffectiveFormat::Alpha32F);
}
WebGLExtensionTextureFloatLinear::~WebGLExtensionTextureFloatLinear()

Просмотреть файл

@ -6,12 +6,54 @@
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
void
WebGLExtensionTextureHalfFloat::InitWebGLFormats(webgl::FormatUsageAuthority* authority)
{
MOZ_ASSERT(authority);
auto addFormatIfMissing = [authority](EffectiveFormat effectiveFormat)
{
if (!authority->GetUsage(effectiveFormat)) {
authority->AddFormat(effectiveFormat, false, false, false, false);
}
};
// Populate authority with any missing effective formats.
addFormatIfMissing(EffectiveFormat::RGBA16F);
addFormatIfMissing(EffectiveFormat::RGB16F);
addFormatIfMissing(EffectiveFormat::Luminance16FAlpha16F);
addFormatIfMissing(EffectiveFormat::Luminance16F);
addFormatIfMissing(EffectiveFormat::Alpha16F);
}
WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto updateUsage = [authority](EffectiveFormat effectiveFormat,
GLenum unpackFormat, GLenum unpackType)
{
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
MOZ_ASSERT(usage);
usage->asTexture = true;
authority->AddUnpackOption(unpackFormat, unpackType, effectiveFormat);
};
InitWebGLFormats(authority);
// Update usage to allow asTexture and add unpack
updateUsage(EffectiveFormat::RGBA16F , LOCAL_GL_RGBA , LOCAL_GL_HALF_FLOAT_OES);
updateUsage(EffectiveFormat::RGB16F , LOCAL_GL_RGB , LOCAL_GL_HALF_FLOAT_OES);
updateUsage(EffectiveFormat::Luminance16FAlpha16F, LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_HALF_FLOAT_OES);
updateUsage(EffectiveFormat::Luminance16F , LOCAL_GL_LUMINANCE , LOCAL_GL_HALF_FLOAT_OES);
updateUsage(EffectiveFormat::Alpha16F , LOCAL_GL_ALPHA , LOCAL_GL_HALF_FLOAT_OES);
}
WebGLExtensionTextureHalfFloat::~WebGLExtensionTextureHalfFloat()

Просмотреть файл

@ -6,12 +6,36 @@
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"
namespace mozilla {
using mozilla::webgl::EffectiveFormat;
WebGLExtensionTextureHalfFloatLinear::WebGLExtensionTextureHalfFloatLinear(WebGLContext* webgl)
: WebGLExtensionBase(webgl)
{
// This update requires that the authority already be populated by
// WebGLExtensionTextureHalfFloat. Enabling extensions to control
// features is a mess in WebGL
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
auto updateUsage = [authority](EffectiveFormat effectiveFormat) {
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
MOZ_ASSERT(usage);
usage->isFilterable = true;
};
// Ensure require formats are initialized.
WebGLExtensionTextureHalfFloat::InitWebGLFormats(authority);
// Update usage to allow isFilterable
updateUsage(EffectiveFormat::RGBA16F);
updateUsage(EffectiveFormat::RGB16F);
updateUsage(EffectiveFormat::Luminance16FAlpha16F);
updateUsage(EffectiveFormat::Luminance16F);
updateUsage(EffectiveFormat::Alpha16F);
}
WebGLExtensionTextureHalfFloatLinear::~WebGLExtensionTextureHalfFloatLinear()

Просмотреть файл

@ -20,6 +20,10 @@ template<typename T>
class Sequence;
} // namespace dom
namespace webgl {
class FormatUsageAuthority;
} // namespace webgl
class WebGLContext;
class WebGLShader;
class WebGLQuery;
@ -210,6 +214,8 @@ class WebGLExtensionTextureFloat
: public WebGLExtensionBase
{
public:
static void InitWebGLFormats(webgl::FormatUsageAuthority* authority);
explicit WebGLExtensionTextureFloat(WebGLContext*);
virtual ~WebGLExtensionTextureFloat();
@ -230,6 +236,8 @@ class WebGLExtensionTextureHalfFloat
: public WebGLExtensionBase
{
public:
static void InitWebGLFormats(webgl::FormatUsageAuthority* authority);
explicit WebGLExtensionTextureHalfFloat(WebGLContext*);
virtual ~WebGLExtensionTextureHalfFloat();

Просмотреть файл

@ -809,7 +809,5 @@ FormatUsageAuthority::AddUnpackOption(GLenum unpackFormat, GLenum unpackType,
MOZ_ALWAYS_TRUE(didInsert);
}
//////////////////////////////////////////////////////////////////////////////////////////
} // namespace webgl
} // namespace mozilla

Просмотреть файл

@ -259,8 +259,6 @@ public:
}
};
////////////////////////////////////////
} // namespace webgl
} // namespace mozilla