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 upAssociate WebGL textures with texture units #18580
Conversation
highfive
commented
Sep 20, 2017
highfive
commented
Sep 20, 2017
|
|
|
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)] | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Sep 28, 2017
Author
Contributor
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?
This comment has been minimized.
This comment has been minimized.
| }; | ||
| } | ||
|
|
||
| macro_rules! bound_texture { |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 27, 2017
Member
Rather than a macro, I think a bound_texture method that accepts an enum argument would be more readable.
This comment has been minimized.
This comment has been minimized.
b992375
to
918169a
| TexImageTarget::CubeMapNegativeY | | ||
| TexImageTarget::CubeMapPositiveZ | | ||
| TexImageTarget::CubeMapNegativeZ => self.bound_texture_cube_map.get(), | ||
| fn bound_texture(&self, target: u32) -> Option<DomRoot<WebGLTexture>> { |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 28, 2017
Member
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.
This comment has been minimized.
This comment has been minimized.
MortimerGoro
Sep 28, 2017
Author
Contributor
Ok, I'll create the new enum. The result will be an Option too because the bound texture is nullable.
This comment has been minimized.
This comment has been minimized.
jdm
Sep 28, 2017
Member
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)] | |||
This comment has been minimized.
This comment has been minimized.
918169a
to
b9710a5
|
Changes made, thanks for the unrooted_must_root info! |
|
@bors-servo: r+ |
|
|
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 -->
|
|
MortimerGoro commentedSep 20, 2017
•
edited
Currently
bound_texture_2dandbound_texture_cube_mapfields 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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is