Closed Bug 943190 Opened 11 years ago Closed 11 years ago

Implement WEBGL_compressed_texture_etc1

Categories

(Core :: Graphics: CanvasWebGL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: u480271, Assigned: jgilbert)

References

Details

Attachments

(2 files, 4 obsolete files)

There is a webgl spec, but it says not to implement. I've implemented it anyway.
I'll get this moved to Draft.
Flags: needinfo?(jgilbert)
Assignee: nobody → dglastonbury
Blocks: 917505
Attachment #8340970 - Attachment is obsolete: true
Jeff, Looking for a sanity check on this one. Reading the spec at
https://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
says that:

INVALID_OPERATION is generated by CompressedTexSubImage2D,
TexSubImage2D, or CopyTexSubImage2D if the texture image <level>
bound to <target> has internal format ETC1_RGB8_OES.

which doesn't feel right.
Attachment #8341366 - Flags: review?(jgilbert)
Attachment #8340975 - Attachment is obsolete: true
(In reply to Dan Glastonbury :djg :kamidphish from comment #4)
> Created attachment 8341366 [details] [diff] [review]
> Add ETC1 compressed texture format to WebGL.
> 
> Jeff, Looking for a sanity check on this one. Reading the spec at
> https://www.khronos.org/registry/gles/extensions/OES/
> OES_compressed_ETC1_RGB8_texture.txt
> says that:
> 
> INVALID_OPERATION is generated by CompressedTexSubImage2D,
> TexSubImage2D, or CopyTexSubImage2D if the texture image <level>
> bound to <target> has internal format ETC1_RGB8_OES.
> 
> which doesn't feel right.

That's what it looks like though. I can think of a couple reasons this might be the case, I guess, though I'm still disappointed. Let's generate a JS warning here, since this is a little surprising.
Flags: needinfo?(jgilbert)
This extension has been moved to draft, so we're good to implement now.
Comment on attachment 8341366 [details] [diff] [review]
Add ETC1 compressed texture format to WebGL.

Review of attachment 8341366 [details] [diff] [review]:
-----------------------------------------------------------------

Let's do another round.

::: content/canvas/src/WebGLContextGL.cpp
@@ +3400,5 @@
>          return;
>      }
>  
> +    if (format == LOCAL_GL_ETC1_RGB8_OES) {
> +        ErrorInvalidOperation("compressedTexImage2D: texture is LOCAL_GL_ETC1_RGB8_OES");

s/TexImage/TexSubImage/

::: content/canvas/src/WebGLExtensionCompressedTextureETC.cpp
@@ +7,5 @@
> +#include "mozilla/dom/WebGLRenderingContextBinding.h"
> +
> +using namespace mozilla;
> +
> +WebGLExtensionCompressedTextureETC1::WebGLExtensionCompressedTextureETC1(WebGLContext* context)

We should probably also call this file ...TextureETC1, since we *might* be getting a ...TextureETC2, depending on how we name the next one.

::: content/canvas/test/webgl/conformance/extensions/webgl-compressed-texture-etc1.html
@@ +153,5 @@
> +
> +    // check that all format enums exist.
> +    for (name in validFormats) {
> +        var expected = "0x" + validFormats[name].toString(16);
> +        var actual = "ext['" + name + "']";

`actual` looks like it will equal "ext['0']" here. This doesn't seem right, does it?

@@ +233,5 @@
> +        ];
> +
> +    function extend_4to8bits(r, g, b) {
> +        return [
> +            (r & 0xf0) | ((r >> 4) & 0x0f),

This is unusual. Do the four bits of `r` actually live in 0xf0? Usually these are at 0x0f, as if we had a uint4_t type that has been up-cast to a larger int type.

@@ +265,5 @@
> +                                    src[2] + 8 * _deltatable[(src[2] & 0x7)]);
> +            return [ col_1, col_2 ];
> +        }
> +
> +        return [];

Shouldn't this be invalid? (non-I-or-D mode?) If so, we should probably just `throw "Invalid mode: " + mode`.

@@ +414,5 @@
> +      glErrorShouldBe(gl, gl.NO_ERROR, "valid dimensions for level > 0");
> +    }
> +
> +/*
> +    // pick a wrong format that uses the same amount of data.

Just remove this, since there's only one format in this ext.

@@ +437,5 @@
> +*/
> +
> +    gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, width + 4, height, format, data);
> +//  glErrorShouldBe(gl, gl.INVALID_VALUE, "data size does not match dimensions");
> +    glErrorShouldBe(gl, gl.INVALID_OPERATION, "data size does not match dimensions");

Yep, the spec for ETC1 seems to forbid CompressedTexSubImage calls.

::: content/canvas/test/webgl/conformance/resources/webgl-test-utils.js
@@ +1308,5 @@
> + * @param {string} name Name of extension to look for
> + * @return {string} name of extension found or undefined if not
> + *     found.
> + */
> +var getSupportedExtensionWithKnownPrefixes = function(gl, name) {

Did you write this, or was this pulled down from a newer version of the test suite?

::: gfx/gl/GLContextFeatures.cpp
@@ +48,5 @@
>      },
>      {
> +        "compressed_texture_etc1",
> +        999, // OpenGL version
> +        999, // OpenGL ES version

0 means 'none', actually.
Attachment #8341366 - Flags: review?(jgilbert) → review-
Summary: Add ETC1 compressed texture format for WebGL → Implement WEBGL_compressed_texture_etc1
Blocks: webgl1ext
I'm taking this to finish it up.
Assignee: dglastonbury → jgilbert
Attached patch patch 1: Implement (obsolete) — Splinter Review
Attachment #8341366 - Attachment is obsolete: true
Attachment #8387976 - Flags: review?(dglastonbury)
Attachment #8387976 - Attachment description: ctex-etc1 → patch 1: Implement
Attached patch patch 2: TestSplinter Review
Attachment #8387977 - Flags: review?(dglastonbury)
Attachment #8387977 - Flags: review?(dglastonbury) → review+
Comment on attachment 8387976 [details] [diff] [review]
patch 1: Implement

Review of attachment 8387976 [details] [diff] [review]:
-----------------------------------------------------------------

The inability to call glCompressedTexSubImage2D seems wrong, but that's what the spec says. :-(

Good to kill all the trailing whitespace in WebGLRenderingContext.webidl.
Attachment #8387976 - Flags: review?(dglastonbury) → review+
r=kamidphish
de-bitrotted
Attachment #8387976 - Attachment is obsolete: true
Attachment #8388838 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/636a4f14af75
https://hg.mozilla.org/mozilla-central/rev/91c5ede1cb08
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: