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

Complete glium.rs backend and update glutin_glium.rs example accordingly. #852

Merged

Conversation

mitchmindtree
Copy link
Contributor

@mitchmindtree mitchmindtree commented Nov 11, 2016

The glium backend feature is now complete! Big thanks to @clicketyclack for kicking this off :)

The implementation uses a single shader program to render the entire GUI. For GUIs consisting of purely text and shapes, the entire GUI will be drawn with a single draw call. Otherwise a new unique draw call will be required for each new image and scizzor that appears, however we might be able to improve this using a TextureArray or mapping to a single texture in the future if necessary.

After updating the glutin_glium.rs example, I did some profiling and found the changes to be a significant improvement over the all_widgets.rs example (the same gui but rendered via piston_window).

The all_widgets.rs example (piston_window backend) idles at ~6.5% CPU, draws 60 frames of text at about ~60% CPU and at about ~65% CPU when scrolling.

On the other hand, the glutin_glium.rs example idles at about 1% CPU (though I anticipate this to drop further once we configure the gui to only update upon new input events). When using ui.draw instead of ui.draw_if_changed (and in turn uploading to the GPU roughly 60 times per second) the example peaks about about 7% - a very promising sign for heavily animated GUIs like timelines, etc. When scrolling continuously over large blocks of text it peaked at around 20%, though the vast majority of this time was spent in rusttype's glyph cache.

Here are some pics!

screen shot 2016-11-12 at 1 04 05 am

screen shot 2016-11-12 at 1 04 13 am

screen shot 2016-11-12 at 1 04 29 am

screen shot 2016-11-12 at 1 05 28 am

screen shot 2016-11-12 at 1 05 48 am

Room for improvement

  • haven't had a chance to do line joins/caps yet, but that should be easy to add.
  • might be able to improve performance slightly again by using an index buffer. By doing this, we'd probably be able to cut back on about a third of the vertices uploaded via the vertex buffer.
  • use a TextureArray (or one big large texture) for uploading multiple images to the GPU at once, allowing to cut down on draw calls.

Closes #752.

@mitchmindtree mitchmindtree mentioned this pull request Nov 12, 2016
example.

Implement drawing for Image example (should be working but is not, will
fix this in a following commit).

Abstract image_map creation in examples/support module.
Added an image mode to fix image drawing.

Avoid entering new Commands when rendering the same image multiple times
in a row.

Moved the event polling before the rendering for quicker feedback.
glium backend now provides a new Renderer type designed specifically for
rendering `render::Primitives` to a `glium::Surface`. It does this in a
modular process through public methods which the user can access in the
case that they require more granular control.
@mitchmindtree
Copy link
Contributor Author

Travis' failure is due to some breakage upstream when compiling gfx with nightly. Going to merge!

@mitchmindtree mitchmindtree merged commit ce395e8 into PistonDevelopers:master Nov 12, 2016
@mitchmindtree
Copy link
Contributor Author

@Boscop did you say you were using glium? If so you might be interested in this.

@Boscop
Copy link
Contributor

Boscop commented Nov 12, 2016

Thanks @mitchmindtree, great work!
Does this mean it's possible draw a HUD GUI over a glium-rendered scene now?

@mitchmindtree
Copy link
Contributor Author

@Boscop Yep!

@Boscop
Copy link
Contributor

Boscop commented Nov 19, 2016

Ok, great. If I want to draw my glium widgets in a certain rect area that will be spared out by conrod rendering, what's the best way to calculate the rect pos / size to align the areas?
Or can I even use conrod's layouting for this?

@mitchmindtree mitchmindtree deleted the glutin_glium_example branch November 23, 2016 09:56
@mitchmindtree
Copy link
Contributor Author

rect area that will be spared out by conrod rendering

Hmmm not 100% sure what you mean by this?

@Boscop
Copy link
Contributor

Boscop commented Nov 23, 2016

I mean I want to render some of my GUI in conrod, and some of it in glium with shaders, so I draw the glium stuff first, and then conrod over it, but how can I prevent conrod from drawing its background over what I drew underneath?

@Boscop
Copy link
Contributor

Boscop commented Dec 2, 2016

@mitchmindtree For example, let's say I want to render my midi view with glium because it has so many rectangles for the notes and I want to batch draw them in a shader. But I want to draw the rest of the GUI with conrod so that I can have sliders and dropdown menus etc.
So I have to know the rect area where the midi view should be, so I can render it there, and tell conrod not to draw anything there, not even background. How should I do this?

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.

2 participants