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

Associate WebGL textures with texture units #18580

Merged
merged 1 commit into from Sep 28, 2017

Conversation

@MortimerGoro
Copy link
Contributor

MortimerGoro commented Sep 20, 2017

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.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@MortimerGoro MortimerGoro requested a review from emilio Sep 20, 2017
@highfive
Copy link

highfive commented Sep 20, 2017

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/webglrenderingcontext.rs
  • @fitzgen: components/script/dom/webglrenderingcontext.rs
  • @emilio: components/script/dom/webglrenderingcontext.rs
@highfive
Copy link

highfive commented Sep 20, 2017

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@bors-servo
Copy link
Contributor

bors-servo commented Sep 26, 2017

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

Copy link
Member

jdm left a comment

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.

@jdm

jdm Sep 27, 2017

Member

Why is this necessary?

This comment has been minimized.

@MortimerGoro

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?

};
}

macro_rules! bound_texture {

This comment has been minimized.

@jdm

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.

@MortimerGoro

MortimerGoro Sep 28, 2017

Author Contributor

Done

@MortimerGoro MortimerGoro force-pushed the MortimerGoro:webgl_active_texture branch from b992375 to 918169a Sep 28, 2017
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.

@jdm

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.

@MortimerGoro

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.

@jdm

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)]
@MortimerGoro MortimerGoro force-pushed the MortimerGoro:webgl_active_texture branch from 918169a to b9710a5 Sep 28, 2017
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Sep 28, 2017

Changes made, thanks for the unrooted_must_root info!

@jdm
Copy link
Member

jdm commented Sep 28, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Sep 28, 2017

📌 Commit b9710a5 has been approved by jdm

@jdm
jdm approved these changes Sep 28, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Sep 28, 2017

Testing commit b9710a5 with merge ffa0338...

bors-servo added a commit that referenced this pull request Sep 28, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 28, 2017

@bors-servo bors-servo merged commit b9710a5 into servo:master Sep 28, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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

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