New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 712096 link

Starred by 2 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocking:
issue 634519



Sign in to add a comment

WebGL2 generateMipmap failing for SRGB8_ALPHA8 textures

Project Member Reported by gman@chromium.org, Apr 17 2017

Issue description

Chrome Version: 60.0.3072.0 (Official Build) canary (64-bit)
OS: OSX 10.12.4

What steps will reproduce the problem?
(1) run this fiddle https://jsfiddle.net/greggman/zn6p957v/

What is the expected result?

It prints 0 0

What happens instead?

It prints 1282 and 1286 and in the JavaScript console prints

[.Offscreen-For-WebGL-0x7fda57806600]GL ERROR :GL_INVALID_OPERATION : glGenerateMipmap:  [.Offscreen-For-WebGL-0x7fda57806600]GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glGenerateMipmap: 

AFAIK the OpenGL ES 3.0 spec expects this to work.

Firefox prints 0 0 as expected.

I didn't check the results actually work


 

Comment 1 by gman@chromium.org, Apr 17 2017

From the ES 3.0 spec 3.8.10.5

> If the levelbase array was not specified with an unsized internal format from table
> 3.3 or a sized internal format that is both color-renderable and texture-filterable
> according to table 3.13, an INVALID_OPERATION error is generated

Checking the table 3.13 SRGB8_ALPHA8 is both color-renderable and texture-filterable

Comment 2 by gman@chromium.org, Apr 17 2017

There's even a test for this.

https://www.khronos.org/registry/webgl/sdk/tests/conformance2/textures/misc/tex-srgb-mipmap.html

Maybe this bug is already filed?

I see this bug 

https://bugs.chromium.org/p/chromium/issues/detail?id=634519

but that bug is about generating the mips, not that fact that Chrome is incorrectly generating an error


Comment 3 by gman@chromium.org, Apr 17 2017

Actually although the test above fails it doesn't generate any errors in the console like the jsfiddle test does which suggests there are 2 issues. One is generating the correct mips (for some definition of correct) the other is not generating errors

Comment 4 by zmo@chromium.org, Apr 17 2017

Cc: kainino@chromium.org
Labels: -Pri-3 OS-All Pri-2
Owner: yunchao...@intel.com
Status: Assigned (was: Untriaged)
First, it is probably an issue in Chrome's handling of generateMipmap with sRGB formats. Almost all drivers do the wrong thing when generateMipmap() is called with sRGB formats by simply doing linear interpretation in sRGB color space.  The right thing to do is to map to linear color space, do linear interpretation, and map back to sRGB color space.  That's exactly what we did in Chrome. The errors are likely coming from the emulation.

Yunchao, can you take a look at gman's sample code and see what triggered the two GL errors?
Cc: yizhou.j...@intel.com
Yizhou, could you take a look at this issue?
@zmo and @gman, we haven't take texStorage2D into consideration when we handle generateMipmap with sRGB formats. In this test case, texStorage2D create an immutable texture, setting the levels param to log2(canvas.width). So the levels would be less than full mipmap count. It could pass if set levels to  log2(canvas.width) + 1 in this case. I will investigate this issue further.
Cc: qiankun....@intel.com yunchao...@intel.com
Owner: yizhou.j...@intel.com
I discussed with Yizhou about this issue. In the current implementation, when we we call generateMipmap to generate srgb texture format for desktop GL prior to GL 4.4, we need to emulate: srgb in original texture -> decode to linear in a temp texture -> generateMipmap against the temp texture to get linear data in the temp texture for all mipmap levels -> encode to srgb and copy to original texture for each mipmap levels.

During the emulation, the current implementation will generate all mipmaps in temp texture and try to copy all mipmap levels to the original texture.But if the original texture is immutable (call texStorage2D without full mipmap levels, then call generateMipmap), then some mipmap levels may don't exist at all in the immutable texture, which will lead to GL error. 

Yizhou will write a WebGL conformance test to reproduce this issue. Then she will try to fix the bug in command buffer in Chromium.
Cc: yang...@intel.com

Comment 9 by kbr@chromium.org, Apr 25 2017

Blocking: 634519

Comment 10 by kbr@chromium.org, Apr 25 2017

Linked this to the bug under which the sRGB mipmap generation emulation was written.

Project Member

Comment 11 by bugdroid1@chromium.org, Apr 28 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8d0947b6ff35a8b033a38ce689cd6fb121c31f88

commit 8d0947b6ff35a8b033a38ce689cd6fb121c31f88
Author: yizhou.jiang <yizhou.jiang@intel.com>
Date: Fri Apr 28 18:28:44 2017

Roll WebGL f7157c2..2395287

https://chromium.googlesource.com/external/khronosgroup/webgl.git/+log/f7157c2..2395287

BUG=693090,712096

TEST=bots

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2844363004
Cr-Commit-Position: refs/heads/master@{#468067}

[modify] https://crrev.com/8d0947b6ff35a8b033a38ce689cd6fb121c31f88/DEPS
[modify] https://crrev.com/8d0947b6ff35a8b033a38ce689cd6fb121c31f88/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
[modify] https://crrev.com/8d0947b6ff35a8b033a38ce689cd6fb121c31f88/content/test/gpu/gpu_tests/webgl_conformance_revision.txt

Project Member

Comment 12 by bugdroid1@chromium.org, Apr 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a916ec8af80b660d45454ccdf5b88d97249327a8

commit a916ec8af80b660d45454ccdf5b88d97249327a8
Author: yizhou.jiang <yizhou.jiang@intel.com>
Date: Sat Apr 29 11:11:06 2017

Fix immutable tex srgb emulation issue of generateMipmap

During the emulation of srgb for generateMipmap, we tried to generate all
levels of the original texture. But if the texture is immutable texture,
we can't generate mipmaps exceed the original range.
Also, when the width and height are not equal, they should be at least one
during the emulation.

BUG=712096
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2841503002
Cr-Commit-Position: refs/heads/master@{#468238}

[modify] https://crrev.com/a916ec8af80b660d45454ccdf5b88d97249327a8/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
[modify] https://crrev.com/a916ec8af80b660d45454ccdf5b88d97249327a8/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc

Comment 13 by kbr@chromium.org, May 1 2017

Status: Started (was: Assigned)
Thanks Yizhou for this fix. Can this bug be closed as Fixed?

I think so, Ken. Yizhou is on vacation these days.I will remind her to have a double check and change the status of this issue accordingly when she is back to office.
Project Member

Comment 15 by bugdroid1@chromium.org, May 14 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/df78633101a43642053c681b8530c88bf7032e06

commit df78633101a43642053c681b8530c88bf7032e06
Author: yizhou.jiang <yizhou.jiang@intel.com>
Date: Sun May 14 17:33:05 2017

Roll WebGL 73b300f..6517159

https://chromium.googlesource.com/external/khronosgroup/webgl.git/+log/73b300f..6517159

BUG=693090,712096

TEST=bots

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2874933003
Cr-Commit-Position: refs/heads/master@{#471635}

[modify] https://crrev.com/df78633101a43642053c681b8530c88bf7032e06/DEPS
[modify] https://crrev.com/df78633101a43642053c681b8530c88bf7032e06/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
[modify] https://crrev.com/df78633101a43642053c681b8530c88bf7032e06/content/test/gpu/gpu_tests/webgl_conformance_revision.txt

Project Member

Comment 16 by bugdroid1@chromium.org, May 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2e20e662edabca0927a21000850778eef038a7cf

commit 2e20e662edabca0927a21000850778eef038a7cf
Author: yizhou.jiang <yizhou.jiang@intel.com>
Date: Mon May 15 05:39:59 2017

Follow up immutable tex srgb emulation issue of generateMipmap.

when calculating max available mipmap level, as base level can
be set by client to any value, so there is an overflow danger.
In addition, when max level of srgb texture is less than full
mipmap level, the max level isn't generated.

BUG=712096
TEST=conformance2/textures/misc/tex-srgb-mipmap.html

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2866663002
Cr-Commit-Position: refs/heads/master@{#471676}

[modify] https://crrev.com/2e20e662edabca0927a21000850778eef038a7cf/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
[modify] https://crrev.com/2e20e662edabca0927a21000850778eef038a7cf/gpu/command_buffer/service/gles2_cmd_srgb_converter.cc

Components: -Internals>GPU>WebGL Blink>WebGL

Sign in to add a comment