Bug 48877

Summary: [chromium] WebGL isFoo() tests fail in command buffer
Product: WebKit Reporter: Adrienne Walker <enne>
Component: WebGLAssignee: Adrienne Walker <enne>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarrin, commit-queue, enne, gman, kbr, simon.fraser, zmo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: OS X 10.6   
Attachments:
Description Flags
Add this test to LayoutTests/fast/canvas/webgl
none
Patch none

Description Adrienne Walker 2010-11-02 15:11:35 PDT
Created attachment 72748 [details]
Add this test to LayoutTests/fast/canvas/webgl

There are unexpected errors when running the attached file on WebKit r70788 (run with run-safari).  This works fine in Chromium at the same WebKit revision.  

I would expect gl.isBuffer(gl.createBuffer()) to return true.  Oddly, the object-deletion-behaviour.html should cover this test, but it doesn't.  Once fixed, perhaps this more simple test should be pushed to the conformance suite.

Here's the actual output from the test:

PASS buffer = gl.createBuffer() was expected value: NO_ERROR.
PASS framebuffer = gl.createFramebuffer() was expected value: NO_ERROR.
PASS program = wtu.setupSimpleTextureProgram(gl) was expected value: NO_ERROR.
PASS renderbuffer = gl.createRenderbuffer() was expected value: NO_ERROR.
PASS shader = gl.createShader(gl.VERTEX_SHADER) was expected value: NO_ERROR.
PASS texture = gl.createTexture() was expected value: NO_ERROR.
FAIL gl.isBuffer(buffer) should be true. Was false.
FAIL gl.isFramebuffer(framebuffer) should be true. Was false.
PASS gl.isProgram(program) is true
FAIL gl.isRenderbuffer(renderbuffer) should be true. Was false.
PASS gl.isShader(shader) is true
FAIL gl.isTexture(texture) should be true. Was false.
PASS successfullyParsed is true

TEST COMPLETE
Comment 1 Kenneth Russell 2010-11-03 19:01:24 PDT
It looks like the reason is this sentence in the documentation for glIsBuffer:

"A name returned by glGenBuffers, but not yet associated with a buffer object by calling glBindBuffer, is not the name of a buffer object."

Chromium's command buffer OpenGL implementation is actually probably incorrect here. Chromium fails this test when run with --in-process-webgl. Either the WebGL implementation needs to be changed to always temporarily bind a newly created buffer so that it returns true from isBuffer, or the test needs to be updated to do so. Either way the command buffer OpenGL code probably (unfortunately) needs to change behavior to be correct.
Comment 2 Adrienne Walker 2010-11-04 09:09:39 PDT
(In reply to comment #1)
> It looks like the reason is this sentence in the documentation for glIsBuffer:
> 
> "A name returned by glGenBuffers, but not yet associated with a buffer object by calling glBindBuffer, is not the name of a buffer object."

Thanks for the clarification.  It looks like the command buffer will need to be fixed.
Comment 3 Kenneth Russell 2010-11-04 16:53:43 PDT
Because WebGL tries to track OpenGL behavior, I think that the conformance test should bind the objects it creates appropriately before making the is* queries. Adrienne, can you take care of this in the Khronos repo and pull the test down to the WebKit layout tests?
Comment 4 Adrienne Walker 2010-11-04 17:34:01 PDT
(In reply to comment #3)
> Because WebGL tries to track OpenGL behavior, I think that the conformance test should bind the objects it creates appropriately before making the is* queries. Adrienne, can you take care of this in the Khronos repo and pull the test down to the WebKit layout tests?

I'm not sure I follow.  The above posted test was an example, that's not part of any existing test in the Khronos repository.

If you're asking that we fix the command buffer to follow this behavior and then add a test verifying that calling isBuffer on a non-bound buffer returns false, then I agree.
Comment 5 Kenneth Russell 2010-11-04 17:37:58 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > Because WebGL tries to track OpenGL behavior, I think that the conformance test should bind the objects it creates appropriately before making the is* queries. Adrienne, can you take care of this in the Khronos repo and pull the test down to the WebKit layout tests?
> 
> I'm not sure I follow.  The above posted test was an example, that's not part of any existing test in the Khronos repository.

Ah. I thought this was one of the conformance tests in the Khronos repo.

> If you're asking that we fix the command buffer to follow this behavior and then add a test verifying that calling isBuffer on a non-bound buffer returns false, then I agree.

To be precise, a buffer that has never been bound. Once the name is bound, it becomes a buffer object. My thought is that we could add a test that allocates each type of object, binds / unbinds it once, and verifies that is* returns true for the object. We can add the test verifying that is* returns false before the object is bound once the command buffer code is fixed.
Comment 6 Adrienne Walker 2010-11-09 17:26:46 PST
Created attachment 73442 [details]
Patch
Comment 7 Kenneth Russell 2010-11-10 10:17:30 PST
Comment on attachment 73442 [details]
Patch

Good catch and looks good overall. Per Brian Paul's comments on the Mesa bug you filed, if real drivers have incorrect behavior (and it seems that some do) then we may have a problem. In this case we would need to make the test more conservative, and only call isBuffer, isFramebuffer, etc. after the first bind of the object.

Please add the test to the Khronos repo if you haven't already.
Comment 8 WebKit Commit Bot 2010-11-10 10:37:43 PST
Comment on attachment 73442 [details]
Patch

Clearing flags on attachment: 73442

Committed r71753: <http://trac.webkit.org/changeset/71753>
Comment 9 WebKit Commit Bot 2010-11-10 10:37:48 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Adrienne Walker 2010-11-10 10:57:01 PST
Thanks.

(In reply to comment #7)
> (From update of attachment 73442 [details])
> Good catch and looks good overall. Per Brian Paul's comments on the Mesa bug you filed, if real drivers have incorrect behavior (and it seems that some do) then we may have a problem. In this case we would need to make the test more conservative, and only call isBuffer, isFramebuffer, etc. after the first bind of the object.

At the very least, the driver for the ATI card in my OS X machine had correct behavior.  We can certainly adjust this test later if this is a commonly mishandled edge case.

> Please add the test to the Khronos repo if you haven't already.

Done.
Comment 11 Zhenyao Mo 2010-11-10 13:26:52 PST
(In reply to comment #10)
> Thanks.
> 
> (In reply to comment #7)
> > (From update of attachment 73442 [details] [details])
> > Good catch and looks good overall. Per Brian Paul's comments on the Mesa bug you filed, if real drivers have incorrect behavior (and it seems that some do) then we may have a problem. In this case we would need to make the test more conservative, and only call isBuffer, isFramebuffer, etc. after the first bind of the object.
> 
> At the very least, the driver for the ATI card in my OS X machine had correct behavior.  We can certainly adjust this test later if this is a commonly mishandled edge case.

My Mac (Nvidia) also has the correct behavior, but my Windows (NVidia Quadro FX380) doesn't.  So my guess is Mac drivers get this correct, but not other platforms.

> 
> > Please add the test to the Khronos repo if you haven't already.
> 
> Done.