Closed Bug 1267147 Opened 8 years ago Closed 8 years ago

WebGL2 conformance test fail: conformance/misc/uninitialized-test.html

Categories

(Core :: Graphics: CanvasWebGL, defect)

Unspecified
Windows 8
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ethlin, Assigned: ethlin)

References

()

Details

Attachments

(1 file, 3 obsolete files)

OS: Unspecified → Windows 8
On windows platform, angle will return invalid operation[1] in this conformance test due to the mismatched format between source and destination. In CopyTexImae2D, we try to get the dstFormat by the internal format and srcFormat->componentType[2]. In this test, the internalFormat is RGBA and componentType is NormUInt, so we set dstFormat as RGBA8 while the srcFormat is RGBA4.
I think we may use the srcUsage as dstUsage directly while the internal format matches the source's unsized format to fix this problem.
 


[1] https://hg.mozilla.org/mozilla-central/annotate/fc15477ce628599519cb0055f52cc195d640dc94/gfx/angle/src/libANGLE/validationES3.cpp#l837
[2] https://dxr.mozilla.org/mozilla-central/source/dom/canvas/WebGLTextureUpload.cpp#1747
Assignee: nobody → ethlin
Attachment #8744843 - Flags: review?(jgilbert)
Comment on attachment 8744843 [details] [diff] [review]
fix destination format in CopyTexImage2D

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

I believe ANGLE is wrong.
Attachment #8744843 - Flags: review?(jgilbert) → review-
Comment on attachment 8744843 [details] [diff] [review]
fix destination format in CopyTexImage2D

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

ANGLE was right, but we need a different change.

Relevant spec text is GLES 3.0.4 p141:

The effective internal format of the source buffer is determined with the fol-
lowing rules applied in order:
* If the source buffer is a texture or renderbuffer that was created with a sized
internal format then the effective internal format is the source buffer’s sized
internal format.
* If the source buffer is a texture that was created with an unsized base internal
format, then the effective internal format is the source image array’s effective
internal format, as specified by table 3.12, which is determined from the
`format` and `type` that were used when the source image array was specified
by `TexImage*`.

::: dom/canvas/WebGLTextureUpload.cpp
@@ +1747,5 @@
> +           (srcFormat->unsizedFormat == webgl::UnsizedFormat::LA && internalFormat == LOCAL_GL_LUMINANCE_ALPHA) ||
> +           (srcFormat->unsizedFormat == webgl::UnsizedFormat::L && internalFormat == LOCAL_GL_LUMINANCE) ||
> +           (srcFormat->unsizedFormat == webgl::UnsizedFormat::A && internalFormat == LOCAL_GL_ALPHA)) {
> +           // If the internal format matches source unsized format, use the srcUsage directly.
> +           dstUsage = srcUsage;

I think we doing this unconditionally.
I found the spec p140 has some descriptions about how to determine effective internal format by source component size. So I tried to implement the rules. The p141 descriptions seem about the source format which we already have in this stage.
Attachment #8744843 - Attachment is obsolete: true
Attachment #8750237 - Flags: review?(jgilbert)
Comment on attachment 8750237 [details] [diff] [review]
fix destination format in CopyTexImage2D

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

Thanks for investigating this. It's just a super awful part of the spec. :(

::: dom/canvas/WebGLFormats.cpp
@@ +971,5 @@
> +    //  a luminance component, a luminance component is considered to match with a red
> +    //  component. Note that the above rules disallow matches where some components
> +    //  sizes are smaller and others are larger. If multiple possible matches exist in the
> +    //  same rule, the one with the closest component sizes is chosen."
> +    const FormatUsageInfo *greaterFormatInfo = nullptr;

Star to the left!

@@ +979,5 @@
> +
> +    for (const std::pair<const PackingInfo, const FormatUsageInfo*> texFormat : mUnsizedTexFormatMap) {
> +        if (texFormat.first.format == internalFormat) {
> +            const FormatUsageInfo *usageInfo = texFormat.second;
> +            if (usageInfo->format->estimatedBytesPerPixel == bytesPerPixel) {

Don't use estimatedBytesPerPixel for this. (it doesn't work)

This is actually a really insane part of the spec.
For instance, for a source effective format of RGB10_A2, internalformat=RGB appears to yield a dest effective format of R11F_G11F_B10F.

If we end up pursuing this, we should just hardcode the correct shortened format into the format info.

However, I'm going to propose we write this out of the spec. I think WebGL 2 should require that effective formats always match exactly. (it sounds like ANGLE already behaves like this)

Let's patch this based on that assumption.

@@ +995,5 @@
> +    }
> +
> +    if (greaterFormatInfo) {
> +        return greaterFormatInfo;
> +    }

Don't brace single-line returns.
Attachment #8750237 - Flags: review?(jgilbert) → review-
I'll propose the spec change.
Flags: needinfo?(jgilbert)
Address jgilbert's comments. Find a format with matched effective format.
Attachment #8750237 - Attachment is obsolete: true
Attachment #8752075 - Flags: review?(jgilbert)
(In reply to Ethan Lin[:ethlin] from comment #7)
> Created attachment 8752075 [details] [diff] [review]
> Fix destination format in CopyTexImage2D
> 
> Address jgilbert's comments. Find a format with matched effective format.

This way still can fix the uninitialized-test.html failures.
Correct the indent.
Attachment #8752075 - Attachment is obsolete: true
Attachment #8752075 - Flags: review?(jgilbert)
Attachment #8752077 - Flags: review?(jgilbert)
This WFM on Nightly now.
Can you confirm?
Flags: needinfo?(jgilbert) → needinfo?(ethlin)
Confirmed.
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: needinfo?(ethlin)
Resolution: --- → WORKSFORME
Attachment #8752077 - Flags: review?(jgilbert)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: