Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd support for WebGL2 TexImage2D #26787
Conversation
highfive
commented
Jun 4, 2020
|
Heads up! This PR modifies the following files:
|
|
I'm getting |
The reason this occurs is the pixel unpack buffer is bound when we invoke glTexImage2d. This causes us to treat the pointer passed as the pixel data buffer to be used as an offset into the bound pixel unpack buffer, instead. The following patch works around this: diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index 9b7b4ed468..da9a502d1d 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -1586,6 +1586,11 @@ impl WebGLImpl {
);
gl.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32);
+ let mut buffer = [0];
+ unsafe {
+ gl.get_integer_v(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut buffer);
+ }
+ gl.bind_buffer(gl::PIXEL_UNPACK_BUFFER, 0);
gl.tex_image_2d(
target,
level as i32,
@@ -1597,6 +1602,7 @@ impl WebGLImpl {
effective_data_type,
Some(&pixels),
);
+ gl.bind_buffer(gl::PIXEL_UNPACK_BUFFER, buffer[0] as u32);
},
WebGLCommand::TexSubImage2D {
target,However, it would be more efficient to use a different model - instead of retrieving the pixels from the unpack buffer, then sending those pixels to be treated like any other 2d texture, I think we should make the WebGLRenderingContext::tex_image_2d take an enum argument like: enum TexSource {
Pixels(TexPixels),
BufferOffset(i64),
}and modify WebGLThread to handle that case appropriately. |
|
@jdm Thank you for your help! I've updated the pull request. A lot of test timeouts on my side while running the |
| let ptr = gl.map_buffer_range( | ||
| gl::PIXEL_UNPACK_BUFFER, | ||
| offset as isize, | ||
| length as isize, | ||
| gl::MAP_READ_BIT, | ||
| ); | ||
| let data: &[u8] = unsafe { slice::from_raw_parts(ptr as _, length) }; | ||
| gl.unmap_buffer(gl::PIXEL_UNPACK_BUFFER); | ||
|
|
||
| gl.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32); | ||
| let mut buffer = [0]; | ||
| unsafe { | ||
| gl.get_integer_v(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut buffer); | ||
| } | ||
| gl.bind_buffer(gl::PIXEL_UNPACK_BUFFER, 0); | ||
|
|
||
| let pixels = prepare_pixels( | ||
| internal_format, | ||
| data_type, | ||
| size, | ||
| unpacking_alignment, | ||
| alpha_treatment, | ||
| y_axis_treatment, | ||
| None, | ||
| Cow::Borrowed(&data), | ||
| ); |
This comment has been minimized.
This comment has been minimized.
jdm
Jun 10, 2020
Member
glTexImage2D will automatically use the contents of the pixel unpack buffer if it's bound, so I suggest we modify the tex_image_2d API in sparkle to take an enum argument for the pixels. If the enum value is BufferOffset, then have we can have a debug assert that the pixel unpack buffer is bound and convert the offset to a pointer instead of https://github.com/servo/sparkle/blob/master/src/lib.rs#L120.
|
@bors-servo try=wpt |
[WIP] Add support for WebGL2 TexImage2D Adds initial support for one of the WebGL2 `TexImage2D` call. I've enabled the `tests/wpt/webgl/tests/deqp/` tests. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #26512 - [x] There are tests for these changes @mmatyas @zakorgy @jdm <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
|
I suspect that the deqp just take longer than the default harness timeout in a debug build. Using something like |
|
@jdm Thank you! I've updated the pull request with the changes you mentioned, also updated the test expectations according to the ci. This pull request is depends on servo/sparkle#28. |
|
@bors-servo r+ |
|
I've rebased the pull request and updated the test expectations. |
|
@bors-servo try=wpt |
Add support for WebGL2 TexImage2D Adds initial support for one of the WebGL2 `TexImage2D` call. I've enabled the `tests/wpt/webgl/tests/deqp/` tests. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #26512 - [x] There are tests for these changes @mmatyas @zakorgy @jdm <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
|
I fear the deqp tests may be too inconsistent to enable :/ |
Adds initial support for one of the WebGL2 `TexImage2D` call.
|
I've disabled the |
|
@bors-servo r+ |
|
|
Add support for WebGL2 TexImage2D Adds initial support for one of the WebGL2 `TexImage2D` call. I've enabled the `tests/wpt/webgl/tests/deqp/` tests. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #26512 - [x] There are tests for these changes @mmatyas @zakorgy @jdm <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
|
|
@bors-servo retry |
|
|
imiklos commentedJun 4, 2020
Adds initial support for one of the WebGL2
TexImage2Dcall.I've enabled the
tests/wpt/webgl/tests/deqp/tests../mach build -ddoes not report any errors./mach test-tidydoes not report any errors@mmatyas @zakorgy @jdm