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
Associate WebGL textures with texture units #18580
Conversation
☔ The latest upstream changes (presumably #18635) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking for!
@@ -1938,12 +2001,32 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { | |||
} | |||
|
|||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 | |||
#[allow(unrooted_must_root)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the dictionary iterator()
Expression of type std::collections::hash_map::Iter<'_, u32, dom::webglrenderingcontext::TextureUnitBindings> must be rooted'''
Is there any better way to avoid that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | ||
} | ||
|
||
macro_rules! bound_texture { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than a macro, I think a bound_texture
method that accepts an enum argument would be more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
b992375
to
918169a
Compare
TexImageTarget::CubeMapNegativeY | | ||
TexImageTarget::CubeMapPositiveZ | | ||
TexImageTarget::CubeMapNegativeZ => self.bound_texture_cube_map.get(), | ||
fn bound_texture(&self, target: u32) -> Option<DomRoot<WebGLTexture>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we take a custom enum argument that only accepts Texture2d and TextureCubeMap, we don't need to return an Option. This will simplify other calling code, and then we can remove the optional_root_object_tojs_or_null macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll create the new enum. The result will be an Option too because the bound texture is nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. In that case I don't think there's any strong benefit to using a separate enum.
@@ -1938,12 +2001,32 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { | |||
} | |||
|
|||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 | |||
#[allow(unrooted_must_root)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
918169a
to
b9710a5
Compare
Changes made, thanks for the unrooted_must_root info! |
@bors-servo: r+ |
📌 Commit b9710a5 has been approved by |
Associate WebGL textures with texture units <!-- Please describe your changes on the following line: --> Currently `bound_texture_2d` and `bound_texture_cube_map` fields are used to restore texture states and to get the current bindings in GetParams(...). But as soon as active texture is changed all the values can become dirty, leading to broken textures in some demos or invalid getParam(...) call results. This PR implements the texture binding association with the texture units. --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18580) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Currently
bound_texture_2d
andbound_texture_cube_map
fields are used to restore texture states and to get the current bindings in GetParams(...). But as soon as active texture is changed all the values can become dirty, leading to broken textures in some demos or invalid getParam(...) call results.This PR implements the texture binding association with the texture units.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is