--- a/dom/canvas/WebGLFormats.cpp
+++ b/dom/canvas/WebGLFormats.cpp
@@ -427,32 +427,22 @@ FormatUsageInfo::IsUnpackValid(const Pac
return false;
*out_value = &(itr->second);
return true;
}
////////////////////////////////////////
-static inline void
-SetUsage(FormatUsageAuthority* fua, EffectiveFormat effFormat, bool isRenderable,
- bool isFilterable)
-{
- MOZ_ASSERT(!fua->GetUsage(effFormat));
-
- auto usage = fua->EditUsage(effFormat);
- usage->isRenderable = isRenderable;
- usage->isFilterable = isFilterable;
-}
-
static void
AddSimpleUnsized(FormatUsageAuthority* fua, GLenum unpackFormat, GLenum unpackType,
EffectiveFormat effFormat)
{
auto usage = fua->EditUsage(effFormat);
+ usage->isFilterable = true;
const PackingInfo pi = {unpackFormat, unpackType};
const DriverUnpackInfo dui = {unpackFormat, unpackFormat, unpackType};
fua->AddTexUnpack(usage, pi, dui);
fua->AllowUnsizedTexFormat(pi, usage);
};
@@ -476,16 +466,17 @@ AddLegacyFormats_LA8(FormatUsageAuthorit
if (gl->IsCoreProfile()) {
PackingInfo pi;
DriverUnpackInfo dui;
const auto fnAdd = [fua, &pi, &dui](EffectiveFormat effFormat,
const GLint* swizzle)
{
auto usage = fua->EditUsage(effFormat);
+ usage->isFilterable = true;
usage->textureSwizzleRGBA = swizzle;
fua->AddTexUnpack(usage, pi, dui);
fua->AllowUnsizedTexFormat(pi, usage);
};
pi = {LOCAL_GL_LUMINANCE, LOCAL_GL_UNSIGNED_BYTE};
@@ -502,17 +493,17 @@ AddLegacyFormats_LA8(FormatUsageAuthorit
} else {
AddSimpleUnsized(fua, LOCAL_GL_LUMINANCE , LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Luminance8 );
AddSimpleUnsized(fua, LOCAL_GL_ALPHA , LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Alpha8 );
AddSimpleUnsized(fua, LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Luminance8Alpha8);
}
}
static void
-AddBasicUnsizedFormats(FormatUsageAuthority* fua, gl::GLContext* gl)
+AddUnsizedFormats(FormatUsageAuthority* fua, gl::GLContext* gl)
{
// GLES 2.0.25, p63, Table 3.4
AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE , EffectiveFormat::RGBA8 );
AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_4_4_4_4, EffectiveFormat::RGBA4 );
AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_5_5_5_1, EffectiveFormat::RGB5_A1);
AddSimpleUnsized(fua, LOCAL_GL_RGB , LOCAL_GL_UNSIGNED_BYTE , EffectiveFormat::RGB8 );
AddSimpleUnsized(fua, LOCAL_GL_RGB , LOCAL_GL_UNSIGNED_SHORT_5_6_5 , EffectiveFormat::RGB565 );
@@ -524,36 +515,45 @@ UniquePtr<FormatUsageAuthority>
FormatUsageAuthority::CreateForWebGL1(gl::GLContext* gl)
{
UniquePtr<FormatUsageAuthority> ret(new FormatUsageAuthority);
const auto ptr = ret.get();
////////////////////////////////////////////////////////////////////////////
// Usages
+ const auto fnSet = [ptr](EffectiveFormat effFormat, bool isRenderable,
+ bool isFilterable)
+ {
+ MOZ_ASSERT(!ptr->GetUsage(effFormat));
+
+ auto usage = ptr->EditUsage(effFormat);
+ usage->isRenderable = isRenderable;
+ usage->isFilterable = isFilterable;
+ };
+
// GLES 2.0.25, p117, Table 4.5
// RGBA8 is made renderable in WebGL 1.0, "Framebuffer Object Attachments"
+ // render filter
+ // able able
+ fnSet(EffectiveFormat::RGBA8 , true , true);
+ fnSet(EffectiveFormat::RGBA4 , true , true);
+ fnSet(EffectiveFormat::RGB5_A1, true , true);
+ fnSet(EffectiveFormat::RGB8 , false, true);
+ fnSet(EffectiveFormat::RGB565 , true , true);
- // render filter
- // able able
- SetUsage(ptr, EffectiveFormat::RGBA8 , true , true);
- SetUsage(ptr, EffectiveFormat::RGBA4 , true , true);
- SetUsage(ptr, EffectiveFormat::RGB5_A1, true , true);
- SetUsage(ptr, EffectiveFormat::RGB8 , false, true);
- SetUsage(ptr, EffectiveFormat::RGB565 , true , true);
+ fnSet(EffectiveFormat::Luminance8Alpha8, false, true);
+ fnSet(EffectiveFormat::Luminance8 , false, true);
+ fnSet(EffectiveFormat::Alpha8 , false, true);
- SetUsage(ptr, EffectiveFormat::Luminance8Alpha8, false, true);
- SetUsage(ptr, EffectiveFormat::Luminance8 , false, true);
- SetUsage(ptr, EffectiveFormat::Alpha8 , false, true);
-
- SetUsage(ptr, EffectiveFormat::DEPTH_COMPONENT16, true, false);
- SetUsage(ptr, EffectiveFormat::STENCIL_INDEX8 , true, false);
+ fnSet(EffectiveFormat::DEPTH_COMPONENT16, true, false);
+ fnSet(EffectiveFormat::STENCIL_INDEX8 , true, false);
// Added in WebGL 1.0 spec:
- SetUsage(ptr, EffectiveFormat::DEPTH24_STENCIL8, true, false);
+ fnSet(EffectiveFormat::DEPTH24_STENCIL8, true, false);
////////////////////////////////////
// RB formats
#define FOO(x) ptr->AllowRBFormat(LOCAL_GL_ ## x, ptr->GetUsage(EffectiveFormat::x))
FOO(RGBA4 );
FOO(RGB5_A1 );
@@ -564,17 +564,17 @@ FormatUsageAuthority::CreateForWebGL1(gl
#undef FOO
ptr->AllowRBFormat(LOCAL_GL_DEPTH_STENCIL,
ptr->GetUsage(EffectiveFormat::DEPTH24_STENCIL8));
////////////////////////////////////////////////////////////////////////////
- AddBasicUnsizedFormats(ptr, gl);
+ AddUnsizedFormats(ptr, gl);
return Move(ret);
}
UniquePtr<FormatUsageAuthority>
FormatUsageAuthority::CreateForWebGL2(gl::GLContext* gl)
{
UniquePtr<FormatUsageAuthority> ret(new FormatUsageAuthority);
@@ -685,20 +685,22 @@ FormatUsageAuthority::CreateForWebGL2(gl
#undef FOO
////////////////////////////////////////////////////////////////////////////
// For renderable, see GLES 3.0.4, p212 "Framebuffer Completeness"
// For filterable, see GLES 3.0.4, p161 "...a texture is complete unless..."
const auto fnAllowES3TexFormat = [ptr](GLenum sizedFormat, EffectiveFormat effFormat,
- bool isRenderable, bool isFilterable)
+ bool isRenderable, bool isFilterable)
{
- SetUsage(ptr, effFormat, isRenderable, isFilterable);
- auto usage = ptr->GetUsage(effFormat);
+ auto usage = ptr->EditUsage(effFormat);
+ usage->isRenderable = isRenderable;
+ usage->isFilterable = isFilterable;
+
ptr->AllowSizedTexFormat(sizedFormat, usage);
if (isRenderable) {
ptr->AllowRBFormat(sizedFormat, usage);
}
};
#define FOO(x) LOCAL_GL_ ## x, EffectiveFormat::x
@@ -767,19 +769,16 @@ FormatUsageAuthority::CreateForWebGL2(gl
// GLES 3.0.4, p133, table 3.14
fnAllowES3TexFormat(FOO(DEPTH_COMPONENT16 ), true, false);
fnAllowES3TexFormat(FOO(DEPTH_COMPONENT24 ), true, false);
fnAllowES3TexFormat(FOO(DEPTH_COMPONENT32F), true, false);
fnAllowES3TexFormat(FOO(DEPTH24_STENCIL8 ), true, false);
fnAllowES3TexFormat(FOO(DEPTH32F_STENCIL8 ), true, false);
- // GLES 3.0.4, p205-206, "Required Renderbuffer Formats"
- fnAllowES3TexFormat(FOO(STENCIL_INDEX8), true, false);
-
// GLES 3.0.4, p147, table 3.19
// GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats"
// Note that all compressed texture formats are filterable:
// GLES 3.0.4 p161:
// "[A] texture is complete unless any of the following conditions hold true:
// [...]
// * The effective internal format specified for the texture arrays is a sized
@@ -795,24 +794,28 @@ FormatUsageAuthority::CreateForWebGL2(gl
fnAllowES3TexFormat(FOO(COMPRESSED_RG11_EAC ), false, true);
fnAllowES3TexFormat(FOO(COMPRESSED_SIGNED_R11_EAC ), false, true);
fnAllowES3TexFormat(FOO(COMPRESSED_SIGNED_RG11_EAC ), false, true);
fnAllowES3TexFormat(FOO(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 ), false, true);
fnAllowES3TexFormat(FOO(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2), false, true);
#undef FOO
+ // GLES 3.0.4, p206, "Required Renderbuffer Formats":
+ // "Implementations are also required to support STENCIL_INDEX8. Requesting this
+ // internal format for a renderbuffer will allocate at least 8 stencil bit planes."
+
+ auto usage = ptr->EditUsage(EffectiveFormat::STENCIL_INDEX8);
+ usage->isRenderable = true;
+ ptr->AllowRBFormat(LOCAL_GL_STENCIL_INDEX8, usage);
+
////////////////
// Legacy formats
- SetUsage(ptr, EffectiveFormat::Luminance8Alpha8, false, true);
- SetUsage(ptr, EffectiveFormat::Luminance8 , false, true);
- SetUsage(ptr, EffectiveFormat::Alpha8 , false, true);
-
- AddBasicUnsizedFormats(ptr, gl);
+ AddUnsizedFormats(ptr, gl);
if (gfxPrefs::WebGL2CompatMode()) {
AddSimpleUnsized(ptr, LOCAL_GL_RGBA, LOCAL_GL_FLOAT, EffectiveFormat::RGBA32F);
AddSimpleUnsized(ptr, LOCAL_GL_RGB , LOCAL_GL_FLOAT, EffectiveFormat::RGB32F );
AddSimpleUnsized(ptr, LOCAL_GL_RGBA, LOCAL_GL_HALF_FLOAT_OES, EffectiveFormat::RGBA16F);
AddSimpleUnsized(ptr, LOCAL_GL_RGB , LOCAL_GL_HALF_FLOAT_OES, EffectiveFormat::RGB16F );
}
--- a/dom/canvas/test/webgl-conformance/conformance/extensions/ext-sRGB.html
+++ b/dom/canvas/test/webgl-conformance/conformance/extensions/ext-sRGB.html
@@ -73,36 +73,37 @@ function expectResult(target, successMes
}
}
if (!anyDiffer) {
testPassed(successMessage);
}
}
-function createGreysRGBTexture(gl, color) {
+function createGreySRGBATexture(gl, color) {
var numPixels = gl.drawingBufferWidth * gl.drawingBufferHeight;
- var size = numPixels * 3;
+ var size = numPixels * 4;
var buf = new Uint8Array(size);
for (var ii = 0; ii < numPixels; ++ii) {
var off = ii * 3;
buf[off + 0] = color;
buf[off + 1] = color;
buf[off + 2] = color;
+ buf[off + 3] = 0xff;
}
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D,
0,
- ext.SRGB_EXT,
+ ext.SRGB_ALPHA_EXT,
gl.drawingBufferWidth,
gl.drawingBufferHeight,
0,
- ext.SRGB_EXT,
+ ext.SRGB_ALPHA_EXT,
gl.UNSIGNED_BYTE,
buf);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
return tex;
}
@@ -261,36 +262,37 @@ function runTextureReadConversionTest()
[ 191, 133 ],
[ 255, 255 ]
];
var program = wtu.setupTexturedQuad(gl);
gl.uniform1i(gl.getUniformLocation(program, "tex2d"), 0);
for (var ii = 0; ii < conversions.length; ii++) {
- var tex = createGreysRGBTexture(gl, conversions[ii][0]);
+ var tex = createGreySRGBATexture(gl, conversions[ii][0]);
wtu.drawQuad(gl);
expectResult(conversions[ii][1],
- "sRGB texture read returned correct data",
- "sRGB texture read returned incorrect data");
+ "sRGBA texture read returned correct data",
+ "sRGBA texture read returned incorrect data");
}
}
function runFramebufferTextureConversionTest() {
debug("");
debug("Test the conversion of colors from linear to sRGB on framebuffer (texture) write");
var program = wtu.setupProgram(gl, ['vertexShader', 'fragmentShader'], ['aPosition'], [0]);
- var tex = createGreysRGBTexture(gl, 0);
+ var tex = createGreySRGBATexture(gl, 0);
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)', 'ext.SRGB_EXT');
+ glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
// Draw
var conversions = [
[ 0, 0 ],
[ 13, 63 ],
[ 54, 127 ],
[ 133, 191 ],
@@ -302,16 +304,17 @@ function runFramebufferTextureConversion
for (var ii = 0; ii < conversions.length; ii++) {
gl.uniform1f(gl.getUniformLocation(program, "uColor"), conversions[ii][0]/255.0);
wtu.drawQuad(gl, [0, 0, 0, 0]);
expectResult(conversions[ii][1],
"framebuffer (texture) read returned correct data",
"framebuffer (texture) read returned incorrect data");
}
+ glErrorShouldBe(gl, gl.NO_ERROR);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
function runFramebufferRenderbufferConversionTest() {
debug("");
debug("Test the conversion of colors from linear to sRGB on framebuffer (renderbuffer) write");
function createsRGBFramebuffer(gl, width, height) {
@@ -322,16 +325,17 @@ function runFramebufferRenderbufferConve
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0,
gl.RENDERBUFFER, rbo);
glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)', 'ext.SRGB_EXT');
+ glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
return fbo;
}
// Draw
var conversions = [
[ 0, 0 ],
@@ -347,16 +351,18 @@ function runFramebufferRenderbufferConve
for (var ii = 0; ii < conversions.length; ii++) {
gl.uniform1f(gl.getUniformLocation(program, "uColor"), conversions[ii][0]/255.0);
wtu.drawQuad(gl, [0, 0, 0, 0]);
expectResult(conversions[ii][1],
"framebuffer (renderbuffer) read returned the correct data",
"framebuffer (renderbuffer) read returned incorrect data");
}
+
+ glErrorShouldBe(gl, gl.NO_ERROR);
}
debug("");
var successfullyParsed = true;
</script>
<script>finishTest();</script>
</body>