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 program_binary support #2032

Merged
merged 1 commit into from Nov 17, 2017
Merged

Add program_binary support #2032

merged 1 commit into from Nov 17, 2017

Conversation

sotaroikeda
Copy link
Contributor

@sotaroikeda sotaroikeda commented Nov 13, 2017

Fixes #2005, but still WIP. I did implementation, but I am not sure if it is a way to go.


This change is Reviewable

@sotaroikeda
Copy link
Contributor Author

Cargo.lock has two gl_generator version, since "servo-glutin" still uses "gl_generator 0.5.4.

@sotaroikeda
Copy link
Contributor Author

Cargo.lock has two gl_generator version, since "servo-glutin" still uses "gl_generator 0.5.4.

servo/glutin#129 is going to handle it.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sotaroikeda for pushing this forward!

My main concern would be having a lazy static map of program binaries. If we want (and I'm pretty sure we do) to cache the binaries on disk and the load on FF start, we should better explicitly manage this structure by the WR clients.

The API could look like:

impl Renderer {
  // create with a given program cache
  fn new(...,
    cached_programs: Option<&ProgramCache>,
  ) -> ... {... }
  // update the program cache with new binaries, e.g. when some of the lazy loaded shader programs got activated in the mean time
  fn update_program_cache(&self, &mut ProgramCache);
}

impl ProgramCache {
  // empty
  pub fn new() -> Self {...}
  // load from disk
  pub fn load(file) -> Self {..}
  // save to disk
  pub fn save(&self, file) {.. }
}

);
} else {
// Bind vertex attributes
for (i, attr) in descriptor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be necessary:

Additionally, all vertex shader input and fragment shader output assignments that were in effect when the program was linked before saving are restored with glProgramBinary is called

@@ -3791,6 +3794,11 @@ impl Renderer {
self.ps_composite.deinit(&mut self.device);
self.device.end_frame();
}

#[allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this public anyway?

@bors-servo
Copy link
Contributor

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

@sotaroikeda
Copy link
Contributor Author

Update the pull request based on the comments. But it does not handle "load from disk" nor "save to disk" yet. But it improves performance of 2nd shader load a lot with Windows + ANGLE.

@kvark
Copy link
Member

kvark commented Nov 16, 2017

Thanks @sotaroikeda !

But it does not handle "load from disk" nor "save to disk" yet. But it improves performance of 2nd shader load a lot with Windows + ANGLE.

Yes, I'm not saying that you should implement this within the PR. What I'm saying that the architecture chosen for this PR is not going to scale to what we need eventually, and likely soon. So it would be nice to have the foundation in place that would not need to be rewritten, especially if we have an idea of how it should look like.

@sotaroikeda
Copy link
Contributor Author

@kvark, can you clarify more about what kind of foundation are you expecting?

@sotaroikeda
Copy link
Contributor Author

@kvark, can you clarify more about what kind of foundation are you expecting?

I am not sure if latest pull request has an foundational problem.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now, thanks @sotaroikeda !
Could someone from the Gecko side confirm that this API would work for them?
Aside from that and a few nits I mentioned, this is good to go.

.bind_attrib_location(pid, i as gl::GLuint, attr.name);
let mut loaded = false;

if self.cached_programs.is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that you are accessing it right afterwards, would be simpler to do

if let Some(cached_programs) = self.cached_programs {
}

}
}

if self.cached_programs.is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly, should probably start with if let Some(cached_programs) = self.cached_programs {...}

@sotaroikeda
Copy link
Contributor Author

I updated the pull request by applying the comment and am asking @nical a feedback in Bug 1391159

@sotaroikeda
Copy link
Contributor Author

In Bug 1391159, feedback of @nical was feedback+.

@kvark
Copy link
Member

kvark commented Nov 17, 2017

Ok, great, thanks @sotaroikeda !
@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 35c22be has been approved by kvark

@bors-servo
Copy link
Contributor

⌛ Testing commit 35c22be with merge ab5a1b8...

bors-servo pushed a commit that referenced this pull request Nov 17, 2017
Add program_binary support

Fixes #2005, but still WIP. I did implementation, but I am not sure if it is a way to go.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2032)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: kvark
Pushing ab5a1b8 to master...

@bors-servo bors-servo merged commit 35c22be into servo:master Nov 17, 2017
@glennw
Copy link
Member

glennw commented Nov 19, 2017

@kvark @sotaroikeda This seems a bit odd - do we really need to introduce a lifetime parameter onto the Renderer object?

@glennw
Copy link
Member

glennw commented Nov 19, 2017

It seems like this would require the Servo compositor object to introduce a lifetime parameter, which is likely to complicate the code quite a bit. I haven't looked through this PR completely - but could we instead make the program cache a trait object with a callback, or something like that? What's the reason the device holds a mutable reference to the cache?

@sotaroikeda
Copy link
Contributor Author

but could we instead make the program cache a trait object with a callback, or something like that?

Ok, I am going to work as to use trait object.

What's the reason the device holds a mutable reference to the cache?

It was requested by a compiler to call cached_programs.insert.

@glennw
Copy link
Member

glennw commented Nov 20, 2017

OK, sounds good. Thank you!

bors-servo pushed a commit that referenced this pull request Nov 21, 2017
Remove lifetime parameter of Renderer

In #2032, @glennw commented about the problem about lifetime parameter of Renderer. The lifetime parameter could cause a problem to merge to Servo.  This pull request addresses it. There could be another ways to address the problem.

cc @glennw @kvark

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2064)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants