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

Add support for WebGL2 TexStorage2D #26023

Merged
merged 8 commits into from Apr 30, 2020
Merged

Conversation

@mmatyas
Copy link
Contributor

mmatyas commented Mar 24, 2020

Adds initial support for the WebGL2 TexStorage2D call, adds support for the related texture enums and enables some of the texture tests.

See: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.6

cc @jdm @zakorgy

A couple of notes:

  • Currently tests/wpt/webgl/meta/conformance2/textures is disabled for testing; this patch enables the misc subdirectory and disables the rest, which is why there are so many new test files. The primary test for TexStorage2D is conformance2/textures/misc/tex-storage-2d.html.
  • Most of the test passes, except the "texSubImage2D should succeed on immutable texture as long as the format is compatible" checks. This produces INVALID_OPERATIONs here because the texture's image info is not set at that level. I'm probably forgetting to call set_image_infos_at_level somewhere but I'm not sure where.
  • There's a duplication of the internal texture format list with eg. the renderbuffer code, I wonder if there would be a good common place for it.

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes
@highfive
Copy link

highfive commented Mar 24, 2020

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webgltexture.rs, components/script/dom/webglrenderingcontext.rs
  • @KiChjang: components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webgltexture.rs, components/script/dom/webglrenderingcontext.rs
components/script/dom/webgltexture.rs Outdated Show resolved Hide resolved
@mmatyas
Copy link
Contributor Author

mmatyas commented Mar 26, 2020

Thanks, I was experimenting with adding a self.initialize step, but unfortunately I still run into the same invalid operation issue. I've included the changes as a separate work-in-progress commit, do you have some ideas about where it fails?

height as u32,
1,
TexFormat::from_gl_constant(internal_format).unwrap(),
levels as u32,

This comment has been minimized.

Copy link
@jdm

jdm Mar 27, 2020

Member

I stepped through the test failure in a debugger and realized that we are initializing a single level of the texture, but TexStorage2D expects all levels from 0 to levels to be initialized. See page 137 of https://www.khronos.org/registry/OpenGL/specs/es/3.0/es_spec_3.0.pdf#nameddest=section-3.8.4.

This comment has been minimized.

Copy link
@mmatyas

mmatyas Mar 30, 2020

Author Contributor

Ah you're right! Indeed I should've read the spec a bit more closely, I'll do some restructuring now.

@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_texstorage2d branch from 31e38ac to 742d27c Apr 6, 2020
@mmatyas
Copy link
Contributor Author

mmatyas commented Apr 6, 2020

So last week I've started restructuring things, which at first looked to be simple, but then I've ended up in the rabbit hole of dealing with texture formats: to store the format in the texture, I had to convert the integer to a TexFormat, but for that I had to add the enums for all the newly acceptable formats, but because the formats were now implemented, they were also accessible from each and every WebGL function, and so I also needed to implement the additional texture format and data type combination checks and update the verification of the texture related functions.

Anyway, there are still quite a few failing test cases, but here's the current WIP status of this patch. I've run a tidy on it but not updated or regenerated all the tests yet.

@bors-servo
Copy link
Contributor

bors-servo commented Apr 7, 2020

The latest upstream changes (presumably #26135) made this pull request unmergeable. Please resolve the merge conflicts.

@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_texstorage2d branch from 742d27c to 4bf4cb3 Apr 8, 2020
@mmatyas
Copy link
Contributor Author

mmatyas commented Apr 8, 2020

Well it keeps getting more and more out of scope, so I'll try to stop here for now. I've cleaned up the debug code, added the tests and rebased to master. There might be still a few misses here and there, but things seem to work mostly fine.

Copy link
Member

jdm left a comment

I agree, I think we should merge what we have before it keeps getting bigger. Thanks for all the work to fix up the missing pieces here!

}

pub fn usable_as_internal(self) -> bool {
/*match self {

This comment has been minimized.

Copy link
@jdm

jdm Apr 8, 2020

Member

We should remove this commented code.

};
if !dimensions_valid {
context.webgl_error(InvalidEnum);
return Err(TexImageValidationError::InvalidBorder);

This comment has been minimized.

Copy link
@jdm

jdm Apr 8, 2020

Member

I think a bunch of these error values don't match what's actually happening.

This comment has been minimized.

Copy link
@mmatyas

mmatyas Apr 8, 2020

Author Contributor

Whoops, indeed, fixed.

@mmatyas mmatyas force-pushed the mmatyas:webgl_fns_texstorage2d branch from 4bf4cb3 to 1c79147 Apr 8, 2020
@jdm
Copy link
Member

jdm commented Apr 8, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Apr 8, 2020

📌 Commit 1c79147 has been approved by jdm

bors-servo added a commit that referenced this pull request Apr 8, 2020
Add support for WebGL2 TexStorage2D

Adds initial support for the WebGL2 `TexStorage2D` call, adds support for the related texture enums and enables some of the texture tests.

See: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.6

<!-- Please describe your changes on the following line: -->

cc @jdm @zakorgy

A couple of notes:

- Currently `tests/wpt/webgl/meta/conformance2/textures` is disabled for testing; this patch enables the `misc` subdirectory and disables the rest, which is why there are so many new test files. The primary test for `TexStorage2D` is `conformance2/textures/misc/tex-storage-2d.html`.
- Most of the test passes, except the "texSubImage2D should succeed on immutable texture as long as the format is compatible" checks. This produces INVALID_OPERATIONs [here](https://github.com/servo/servo/blob/d5e5414be372a28215c5162b1257765b89fbd619/components/script/dom/webglrenderingcontext.rs#L798) because the texture's image info is not set at that level. I'm probably forgetting to call `set_image_infos_at_level` somewhere but I'm not sure where.
- There's a duplication of the internal texture format list with eg. the renderbuffer code, I wonder if there would be a good common place for it.

---
<!-- 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] There are tests for these changes

<!-- 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
Copy link
Contributor

bors-servo commented Apr 8, 2020

Testing commit 1c79147 with merge 19cbea9...

@bors-servo
Copy link
Contributor

bors-servo commented Apr 8, 2020

💔 Test failed - status-taskcluster

@jdm jdm force-pushed the mmatyas:webgl_fns_texstorage2d branch from 8d1b60e to 0c87590 Apr 30, 2020
@jdm
Copy link
Member

jdm commented Apr 30, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Apr 30, 2020

📌 Commit 0c87590 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Apr 30, 2020

Testing commit 0c87590 with merge e544a97...

bors-servo added a commit that referenced this pull request Apr 30, 2020
Add support for WebGL2 TexStorage2D

Adds initial support for the WebGL2 `TexStorage2D` call, adds support for the related texture enums and enables some of the texture tests.

See: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.6

<!-- Please describe your changes on the following line: -->

cc @jdm @zakorgy

A couple of notes:

- Currently `tests/wpt/webgl/meta/conformance2/textures` is disabled for testing; this patch enables the `misc` subdirectory and disables the rest, which is why there are so many new test files. The primary test for `TexStorage2D` is `conformance2/textures/misc/tex-storage-2d.html`.
- Most of the test passes, except the "texSubImage2D should succeed on immutable texture as long as the format is compatible" checks. This produces INVALID_OPERATIONs [here](https://github.com/servo/servo/blob/d5e5414be372a28215c5162b1257765b89fbd619/components/script/dom/webglrenderingcontext.rs#L798) because the texture's image info is not set at that level. I'm probably forgetting to call `set_image_infos_at_level` somewhere but I'm not sure where.
- There's a duplication of the internal texture format list with eg. the renderbuffer code, I wonder if there would be a good common place for it.

---
<!-- 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] There are tests for these changes

<!-- 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
Copy link
Contributor

bors-servo commented Apr 30, 2020

💔 Test failed - status-taskcluster

@CYBAI
Copy link
Collaborator

CYBAI commented Apr 30, 2020

  ▶ Unexpected subtest result in /_webgl/conformance/textures/misc/tex-sub-image-2d.html:
  │ FAIL [expected PASS] WebGL test #0: pixel at (1, 0) was (0, 0, 0), should be (1, 1, 1)
  │   → assert_true: pixel at (1, 0) was (0, 0, 0), should be (1, 1, 1) expected true got false
  │ 
  │ reportTestResultsToHarness/<@http://web-platform.test:8000/_webgl/js/js-test-pre.js:123:24
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1988:25
  │ test@http://web-platform.test:8000/resources/testharness.js:535:30
  │ reportTestResultsToHarness@http://web-platform.test:8000/_webgl/js/js-test-pre.js:122:15
  │ testFailed@http://web-platform.test:8000/_webgl/js/js-test-pre.js:249:31
  └ @http://web-platform.test:8000/_webgl/conformance/textures/misc/tex-sub-image-2d.html:107:19

Not sure if this is an intermittent failure, other than it, other failures are #25513 and #23290.

@jdm
Copy link
Member

jdm commented Apr 30, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Apr 30, 2020

Testing commit 0c87590 with merge 2b20f04...

@bors-servo
Copy link
Contributor

bors-servo commented Apr 30, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing 2b20f04 to master...

@bors-servo bors-servo merged commit 2b20f04 into servo:master Apr 30, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Apr 30, 2020
3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.