Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webgl: premultiplication, y flipping, and format conversion #15122

Merged
merged 4 commits into from Feb 3, 2017

Commits on Jan 28, 2017

  1. webgl: Implement FLIP_Y_AXIS unpacking flag for TexImage, TexSubImage.

    This fixes a couple of tests doing RGBA/ubyte image uploads with
    flipping.  Other tests with flipping get their expectations changed,
    because some other feature is missing (premultiplication or
    ImageData/canvas format conversion)
    anholt committed Jan 28, 2017
  2. webgl: Convert non-raw TexImage sources to the requested format.

    The code was returning RGBA8 data from the non-raw sources (HTML
    canvas elements, JS ImageData, etc.), but we then validated and passed
    that rgba8 data as if it was whatever format/datatype was specified in
    TexImage2D/TexSubImage2D, so the pixels would come out as garbage.
    
    It would seem like we could just rewrite the passed in format/datatype
    for the TexImage call to be RGBA/UNSIGNED_BYTE, but that would leave
    incorrect levels of precision if the internalformat didn't match the
    format/datatype (and older desktop implementations often ignore the
    internalformat in choosing their internal format, anyway).
    anholt committed Jan 28, 2017
  3. webgl: Add support for premultiplying alpha.

    Now the affected testcase only fails due to unpack alignment.
    anholt committed Jan 28, 2017

Commits on Jan 29, 2017

  1. webgl: Fix handling of UNPACK_ALIGNMENT.

    We were setting it to whatever value from {1,2,4,8} the user requested
    and otherwise ignoring it.  There were two problems there:
    
    1) Validation ignored it, so GL could read outside of the user's array
       in TexImage() or TexSubImage() if the aligment was greater than
       cpp.
    
    2) TexImage()/TexSubImage() from image/canvas sources wasn't packing
       its data according to the unpack alignment.
    
    To fix this, start tracking the user-requested alignment in the DOM
    side of the context.  Set the GL's alignment to 1 for image/canvas
    sources or the user's value for array sources, and pass the user's
    alignment in to validation so that it can figure out the correct size
    of image that the GL will ready.
    anholt committed Jan 29, 2017
You can’t perform that action at this time.