Some wrench reftests are failing with the error message:
ERROR - thread '<unnamed>' panicked at 'Caught GL error 502 at tex_sub_image_3d_pbo', webrender/src/device/gl.rs:1253:17
This presumably occurs on non-wrench tests too, although I haven't looked at enabling them yet, and real content if one were to run a debug build on the emulator. (Release builds will fail silently rather than panicking.)
This occurs when attempting to upload data from a buffer with a
stride != width * bpp.
stride being the stride of the data within the CPU side buffer we are uploading (the argument to
width being the width of the subregion being uploaded (the width of the texture itself is irrelevent).
For example, we are uploading a 64 * 32 region to the texture, with a stride of 512 bytes (rather than 256 were it tightly packed). In this case, we create a PBO that is
512 * 31 + 256 bytes long. That is
stride * (height - 1) + (width * bpp): the first 31 rows must be 512 bytes long, but the final row only has to contain the 64 pixels actually being uploaded.
This should work fine, however, there appears to be an emulator bug where it incorrectly tries to validate the length of the PBO we upload from during
glTexSubImage. It attempts to validate that the buffer is
stride * height rather than
stride * (height - 1) + (width * bpp), and emits a GL_INVALID_OPERATION error.
This appears to affect both the swiftshader and gpu backend of the emulator. I will create a reduced test case and file an issue upstream.
On our end, I believe the best fix is to simply pad the size of the PBO to
stride * height. I doubt the memory savings are worth any extra complexity of a emulator-specific workaround.