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

Detect more GL limits. #123

Merged
merged 1 commit into from May 31, 2018
Merged

Detect more GL limits. #123

merged 1 commit into from May 31, 2018

Conversation

@jdm
Copy link
Member

jdm commented May 30, 2018

No description provided.

bors-servo added a commit to servo/servo that referenced this pull request May 31, 2018
Don't forward GL parameter gets for constant limits.

This avoids IPC traffic for unchanging constants that are determined when the GL context is created. These changes require servo/surfman#123.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #20876.
- [x] There are tests for these changes

<!-- 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/20884)
<!-- Reviewable:end -->
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for GLLimits {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>
{
let values = try!(<[_; 3]>::deserialize(deserializer));
let values = try!(<[_; 10]>::deserialize(deserializer));

This comment has been minimized.

Copy link
@kvark

kvark May 31, 2018

Member

any reason why GLLimits can't just derive deserialization?

This comment has been minimized.

Copy link
@jdm

jdm May 31, 2018

Author Member

This was an explicit choice a while ago in c97823f (from #57). I'd rather look into that separately from this work.

.serialize(serializer)
}
}

macro_rules! gl_integer {
($gl:ident, $pname:ident) => {

This comment has been minimized.

Copy link
@kvark

kvark May 31, 2018

Member

what's a particular reason for this to be a macro as opposed to a function?

This comment has been minimized.

Copy link
@jdm

jdm May 31, 2018

Author Member

The debugging output stringifies the name of the enum used.

let max_texture_image_units = gl_integer!(gl_, MAX_TEXTURE_IMAGE_UNITS);
let max_vertex_texture_image_units = gl_integer!(gl_, MAX_VERTEX_TEXTURE_IMAGE_UNITS);

// Based off of https://searchfox.org/mozilla-central/rev/5a744713370ec47969595e369fd5125f123e6d24/dom/canvas/WebGLContextValidate.cpp#523-558

This comment has been minimized.

Copy link
@kvark

kvark May 31, 2018

Member

jeez, I would not want to accept this code if I was reviewing it:

We are now going to try to read GL_MAX_VERTEX_OUTPUT_COMPONENTS
* and GL_MAX_FRAGMENT_INPUT_COMPONENTS, however these constants
* only entered the OpenGL standard at OpenGL 3.2. So we will try
* reading, and check OpenGL error for INVALID_ENUM.

I think it's a bad idea. If a constant was introduced in GL 3.2, wouldn't it be better for us to just check the context version and go from that?

For an example of what can be wrong with this code: an error could be triggered by something else before our fallible check, and we'd think that it occurred due to the check.

This comment has been minimized.

Copy link
@kvark

kvark May 31, 2018

Member

On a second thought, maybe checking for the context version is not that trivial, since it's returned as string (d'oh, GL).
I still don't like this approach, but I'd not want you to get stuck finding a better way here. At the very least, could we ensure the fallible integer queries expect GL_INVALID_ENUM error and nothing else?

Copy link
Member

emilio left a comment

Heh, I magically started receiving github bugmail again for this repo :)

}

fn gl_fallible_integer(gl_: &gl::Gl, pname: gl::GLenum) -> Result<u32, ()> {
let mut val = [0];

This comment has been minimized.

Copy link
@emilio

emilio May 31, 2018

Member

You should probably debug_assert that gl_.get_error() is gl::NO_ERROR here, otherwise you'll reject known values.

unsafe {
$gl.get_integer_v(gl::$pname, &mut val);
}
assert_eq!($gl.get_error(), gl::NO_ERROR, "Error retrieving {}", stringify!($pname));

This comment has been minimized.

Copy link
@emilio

emilio May 31, 2018

Member

Maybe just debug_assert_eq!, though not big deal :)

This comment has been minimized.

Copy link
@jdm

jdm May 31, 2018

Author Member

I think it's important to catch this in release builds too.

@jdm jdm force-pushed the more-limits branch from 41c51ad to b8cd398 May 31, 2018
@jdm
Copy link
Member Author

jdm commented May 31, 2018

Comments addressed.

@kvark
kvark approved these changes May 31, 2018
Copy link
Member

kvark left a comment

Thank you for addressing the concerns!
I'm looking forward to have both GLLimits serialization and fallible integer queries fixed/rewritten one day.

@jdm jdm merged commit fcbbb4d into master May 31, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
bors-servo added a commit to servo/servo that referenced this pull request May 31, 2018
Don't forward GL parameter gets for constant limits.

This avoids IPC traffic for unchanging constants that are determined when the GL context is created. These changes require servo/surfman#123.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #20876.
- [x] There are tests for these changes

<!-- 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/20884)
<!-- Reviewable:end -->
@emilio emilio deleted the more-limits branch May 31, 2018
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

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