Closed Bug 1323626 Opened 8 years ago Closed 7 years ago

[WebGL2 conformance test] Pass conformance2/textures/misc/tex-mipmap-levels.html

Categories

(Core :: Graphics: CanvasWebGL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox51 --- fixed
firefox52 --- fixed
firefox53 --- fixed

People

(Reporter: daoshengmu, Assigned: jgilbert)

References

Details

Attachments

(2 files)

Blocks: webgl2
Assignee: nobody → dmu
Summary: Pass WebGL2 conformance conformance2/textures/misc/tex-mipmap-levels.html → [WebGL2 conformance test] Pass conformance2/textures/misc/tex-mipmap-levels.html
Attached file texSize.hlsl
wtu.checkCanvas(gl, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
FAIL should draw with [255, 0, 0, 255]

I am thinking that this is a fragement shader:

fragColor = (textureSize(tex, lod) == texSize ? vec4(255, 0, 0, 255) : vec4(0, 0, 0, 255));

In ANGLE, we will convert it to HLSL as this attachment. I have confirmed we get the same shader code as Chromium.
(In reply to Daosheng Mu[:daoshengmu] from comment #1)
> Created attachment 8818777 [details]
> texSize.hlsl
> 
> wtu.checkCanvas(gl, [255, 0, 0, 255], "should draw with [255, 0, 0, 255]");
> FAIL should draw with [255, 0, 0, 255]
> 
> I am thinking that this is a fragement shader:
> 
> fragColor = (textureSize(tex, lod) == texSize ? vec4(255, 0, 0, 255) :
> vec4(0, 0, 0, 255));
> 
The value of textureSize(tex, lod) is always (1, 1). No matter I change the texStorage2D or gl.TEXTURE_BASE_LEVEL.

HLSL doesn't support textureSize(), so ANGLE uses DriverConstants for this kind of stuff. But, I notice the SamplerMetadataD3D11 doesn't be consistent with the TextureState of Texture. (https://dxr.mozilla.org/mozilla-central/source/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp#2525)

> In ANGLE, we will convert it to HLSL as this attachment. I have confirmed we
> get the same shader code as Chromium.
Comment on attachment 8818777 [details]
texSize.hlsl

>
>static float4 out_webgl_b79fa51523a10f88 = {0, 0, 0, 0};
>
>cbuffer DriverConstants : register(b1)
>{
>    struct SamplerMetadata
>    {
>        int baseLevel;

Ideally, baseLevel should be 1 because we call gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_BASE_LEVEL, 1).
I have confirmed that SetTexParameteri() set the baseLevel to 1 to TextureState, but DriverConstants do not get this value.

>        int internalFormatBits;
>        int wrapModes;
>        int padding;
>    };
>    SamplerMetadata samplerMetadata[1] : packoffset(c4);
>};
>
>int3 gl_texture3DSize(const uint samplerIndex, int lod)
>{
>    const uint textureIndex = samplerIndex - textureIndexOffset3D;
>    const uint samplerArrayIndex = samplerIndex - samplerIndexOffset3D;
>int baseLevel = samplerMetadata[samplerIndex].baseLevel;
>    uint width; uint height; uint depth; uint numberOfLevels;
>    textures3D[textureIndex].GetDimensions(baseLevel, width, height, depth, numberOfLevels);
>    width = max(width >> lod, 1);
>    height = max(height >> lod, 1);
>    depth = max(depth >> lod, 1);
>    return int3(width, height, depth);}
>
On MacOSX runs native GL, textureSize(tex, lod) is (0,0). I think we might has some issues at the mipmap generation or texStorage function.
After set isDataInitialized to true at https://dxr.mozilla.org/mozilla-central/rev/d4b3146a5567a7ddbcdfa5244945db55616cb8d1/dom/canvas/WebGLTextureUpload.cpp#1145, we can fix this bug on Windows. On MacOSX, we still have something wrong for GL_TEXTURE_BASE_LEVEL. No matter the value of GL_TEXTURE_BASE_LEVEL, it would always be 0 at the result.
(In reply to Daosheng Mu[:daoshengmu] from comment #5)
> After set isDataInitialized to true at
> https://dxr.mozilla.org/mozilla-central/rev/
> d4b3146a5567a7ddbcdfa5244945db55616cb8d1/dom/canvas/WebGLTextureUpload.
> cpp#1145, we can fix this bug on Windows. On MacOSX, we still have something
> wrong for GL_TEXTURE_BASE_LEVEL. No matter the value of
> GL_TEXTURE_BASE_LEVEL, it would always be 0 at the result.

Probably, we have to make isDataInitialized to be true, otherwise, the out_fakeBlack would be  FakeBlackType::RGBA0001 at
https://dxr.mozilla.org/mozilla-central/rev/567894f026558e6dada617a3998f29aed06ac7d8/dom/canvas/WebGLTexture.cpp#474, and then BindFakeBlack().
Thanks for the investigation!

It turns out our optimization that uses FakeBlack textures for uninitialized texture data is incompatible with glsl's textureSize().

That's fine, since this isn't a useful optimization anyway.
Assignee: dmu → jgilbert
Comment on attachment 8820481 [details]
Bug 1323626 - Initialize tex image data during completeness checks. -

https://reviewboard.mozilla.org/r/99976/#review100514

r+ after checking the redundant function.

::: dom/canvas/WebGLTexture.h:196
(Diff revision 1)
>  
>          bool IsDataInitialized() const { return mIsDataInitialized; }
>  
>          void SetIsDataInitialized(bool isDataInitialized, WebGLTexture* tex);
> +
> +        bool Initialize();

Could you help me check if it is a redundant function? I didn't see any implementation on it.
Attachment #8820481 - Flags: review?(dmu) → review+
(In reply to Daosheng Mu[:daoshengmu] from comment #10)
> Comment on attachment 8820481 [details]
> Bug 1323626 - Initialize tex image data during completeness checks. -
> 
> https://reviewboard.mozilla.org/r/99976/#review100514
> 
> r+ after checking the redundant function.
> 
> ::: dom/canvas/WebGLTexture.h:196
> (Diff revision 1)
> >  
> >          bool IsDataInitialized() const { return mIsDataInitialized; }
> >  
> >          void SetIsDataInitialized(bool isDataInitialized, WebGLTexture* tex);
> > +
> > +        bool Initialize();
> 
> Could you help me check if it is a redundant function? I didn't see any
> implementation on it.

Yep, my bad. Ended up discarding it but forgot about the header decl.
Pushed by jgilbert@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ec779e626454
Initialize tex image data during completeness checks. - r=daoshengmu
https://hg.mozilla.org/mozilla-central/rev/ec779e626454
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: