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).
This commit is contained in:
Eric Anholt 2017-01-09 13:29:47 -08:00
parent 2e6eb547a8
commit 57ba1646bc
10 changed files with 70 additions and 34 deletions

View file

@ -1,5 +0,0 @@
[tex-image-and-sub-image-2d-with-image-data-rgb565.html]
type: testharness
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,227,0,255]
expected: FAIL

View file

@ -1,5 +0,0 @@
[tex-image-and-sub-image-2d-with-image-data-rgba4444.html]
type: testharness
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,255,0,255]
expected: FAIL

View file

@ -1,5 +0,0 @@
[tex-image-and-sub-image-2d-with-image-data-rgba5551.html]
type: testharness
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,231,0,255]
expected: FAIL

View file

@ -1,5 +0,0 @@
[tex-image-and-sub-image-2d-with-image-rgb565.html]
type: testharness
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,227,0]
expected: FAIL

View file

@ -1,5 +0,0 @@
[tex-image-and-sub-image-2d-with-image-rgba4444.html]
type: testharness
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,255,0]
expected: FAIL

View file

@ -1,5 +0,0 @@
[tex-image-and-sub-image-2d-with-image-rgba5551.html]
type: testharness
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,231,0]
expected: FAIL