Closed Bug 1587047 Opened 5 years ago Closed 5 years ago

GL_INVALID_OPERATION error in glTexSubImage3D (webrender on Android Emulator)

Categories

(Core :: Graphics: WebRender, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: jnicol, Assigned: jnicol)

References

Details

Attachments

(2 files)

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 TextureUpload::upload(), and 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.

When uploading texture data with a PBO we currently ensure the PBO
is the size of (height - 1) * stride + (width * bpp), ie the final row
only contains the width's worth of data, not the stride. This should
be okay, and works fine on other implementations, but the android
emulator thinks it is invalid and emits a GL_INVALID_OPERATION error
in the glTexSubImage* call. To avoid this, ensure that the PBO is the
full height * stride size.

Depends on D48541

Pushed by jnicol@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ca08f015b430
Ensure PBO is at least height * stride size to avoid emulator error. r=gw
https://hg.mozilla.org/integration/autoland/rev/ac3bcdd939b4
Update wrench reftest expectations. r=gw
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
See Also: → 1582954
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: