-
-
Couldn't load subscription status.
- Fork 1.4k
Software renderer, runtime renderer fallback, and core consolidation #1748
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
Merged
Parent:
Advanced text
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update `resvg` in `iced_graphics`
Fix `Padding::fit` on irregular values for an axis
... with a nice little color trick :^)
Implementing this generically in our `flex` logic has an exponential cost. Let's explore other options!
... since we are not reusing the `SwashCache`
Remove `Fill` variant for `Alignment`
This won't be necessary once we reuse the buffers from layouting by leveraging layout linearity.
|
goat |
|
Changes look really good!! Tested both backends & a few examples on MacOS M1 & PopOS; tiny-skia is of course quite a bit slower but pretty damn good. Nice job! 🚀 🥳 |
Merged
fenhl
added a commit
to midoshouse/ootr-multiworld
that referenced
this pull request
Sep 5, 2023
In theory, iced should automatically fall back to a software renderer at runtime if wgpu is not available (according to iced-rs/iced#1748). In practice, for at least one user, a test app closes silently with the wgpu feature enabled but runs normally with it disabled.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
canvas
compatibility
feature
New feature or request
image
improvement
An internal improvement
rendering
svg
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a software renderer (#1071), implements runtime renderer fallback (#1199), and reorganizes most of the codebase.
tiny-skiarendererI have implemented a new renderer on top of
tiny-skia.tiny-skiais an absolute minimal, CPU only, 2D rendering library for the Rust ecosystem, with a focus on rendering quality, speed and binary size.This renderer lives in the new
iced_tiny_skiasubcrate. Besides the mesh primitives, it has feature parity withiced_wgpu. The more complex graphical widgets likeCanvas,Image, andSvgare fully supported!Canvassupport was particularly challenging. The current implementation was designed with GPUs in mind. Acanvas::Frametessellates any geometry into triangles, which GPUs can very easily render.However,
tiny-skiadirectly supports Bézier paths. We can use aCanvasto directly drive thetiny-skiarenderer. No tessellation necessary! For this, I introduced a couple of new variants toPrimitiveiniced_graphicsand implemented a newFrametype iniced_tiny_skiathat records paths instead of tessellating the geometry withlyon.Finally,
softbuffertakes care of presentation.iced_renderersubcrateNow that we have a software renderer that can run anywhere, it would be great if we could have an abstraction that unifies both
iced_wgpuandiced_tiny_skiaand fall back to software rendering whenever a GPU-accelerated backend fails during initialization. This is what the newiced_renderercrate does!The
iced_renderercrate exposes a renderer implementation that chooses a backend at runtime and delegates accordingly. The available backends can be enabled using feature flags (currentlywgpuandtiny-skia).iced_coreconsolidationThe implementation of these new subcrates prompted me to reevaluate the concepts shared between different parts of the codebase.
Specifically, it seems everything needs to depend on
iced_nativecurrently. This is not ideal, sinceiced_nativecontains both core concepts (like theWidgettrait) and also types that are very likely to change (like the widgets themselves). Ideally, subcrates should be able to choose a set of minimal but stable foundations to rely on. This is not currently possible in theicedecosystem.The solution is simple! Move the core concepts of the library to the actual
iced_coresubcrate! Thus, the wholeWidgetAPI now lives there (and everything related to it like renderer traits, events, layout and overlay types, etc.).As a result, most of the subcrates only rely on
iced_corenow. If someone wants to implement a custom widget, they can do so without indirectly depending on all the other built-in widgets.Also, I renamed
iced_nativetoiced_runtime.iced_nativecould not originally be built for WebAssembly and I chose to name itnativeto differentiate it fromiced_web. However, this is no longer the case.iced_nativecan perfectly run on a browser. Thus, the nameiced_nativedid not make much sense anymore.The built-in widgets have also moved to their own subcrate:
iced_widget, reducing the surface oficed_runtimefurther. The main goal here is to makeiced_runtimethe official runtime providing theUserInterfacetype and aCommandimplementation (which may eventually become core concepts as well!).Furthermore, since the widget types are now perfectly isolated, the renderer subcrates do not depend on them. This means we can make
iced_widgetrely oniced_rendererand set the default type for theRenderergeneric type right in the struct definition. This gets rid of all the annoying widget type aliases present in the root crate! No more links toiced_nativein the docs!Finally, I have introduced a new
advancedfeature flag in theicedroot crate. Enabling this flag exposes a newadvancedmodule that contains concepts necessary to build custom widgets and subscriptions. As a consequence, users do not need to depend on any subcrate to leverage advanced concepts anymore. No more figuring out the correct version numbers!Next steps
As I mentioned in #1697, this was one of the needed steps before the
advanced-textbranch can land onmaster. These changes will be merged there for now.After this, I believe we just need to polish some rough edges (e.g. configurable line height) and we will be able to bring everything to
master! 🥳