-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Iced on Raspberry PI 4 (almost working) #428
Comments
Interesting!
We should definitely update this dependency in
I recently implemented an OpenGL renderer in #354. You can enable it using the |
Awesome! I will have a look.
Oh, that's unfortunate. Being able to render images is key to my application. Could you please give me a hint on how hard or time consuming it is to implement image support for this backend? |
Just in case, I've tried to build
Is it possible to lower required GL version? It's kinda strange to think that 2D rendering stuff requires the latest GL version. |
A temporary workaround for GLSL ES issue would be to replace the #version 300 es
precision mediump float; In both shaders like this: diff --git a/src/shader/fragment.frag b/src/shader/fragment.frag
index 5464b3f..60fb836 100644
--- a/src/shader/fragment.frag
+++ b/src/shader/fragment.frag
@@ -1,7 +1,9 @@
-#version 330
+#version 300 es
+precision mediump float;
uniform sampler2D font_sampler;
in vec2 f_tex_pos;
in vec4 f_color;
diff --git a/src/shader/vertex.vert b/src/shader/vertex.vert
index 023ce31..968f197 100644
--- a/src/shader/vertex.vert
+++ b/src/shader/vertex.vert
@@ -1,4 +1,5 @@
-#version 330
+#version 300 es
+precision mediump float;
uniform mat4 transform;
I've only tested this on https://github.com/hecrj/glow_glyph repo on Raspberry Pi 4 device, haven't really tested further with |
Got diff --git a/Cargo.toml b/Cargo.toml
index 9ab57bc..f61890f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -90,3 +90,6 @@ iced_web = { version = "0.2", path = "web" }
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = ["image", "svg", "canvas"]
+
+# glow_glyph with patched shaders
+[patch.crates-io]
+glow_glyph = { path = "../glow_glyph" }
diff --git a/examples/bezier_tool/Cargo.toml b/examples/bezier_tool/Cargo.toml
index a88975a..e1c32f4 100644
--- a/examples/bezier_tool/Cargo.toml
+++ b/examples/bezier_tool/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
publish = false
[dependencies]
-iced = { path = "../..", features = ["canvas"] }
+iced = { path = "../..", features = ["canvas", "glow", "glow_canvas"] }
diff --git a/glow/src/shader/quad.frag b/glow/src/shader/quad.frag
index cea36bd..aa6045d 100644
--- a/glow/src/shader/quad.frag
+++ b/glow/src/shader/quad.frag
@@ -1,4 +1,5 @@
-#version 330
+#version 300 es
+precision mediump float;
uniform float u_ScreenHeight;
@@ -11,7 +12,7 @@ in float v_BorderWidth;
out vec4 o_Color;
-float distance(in vec2 frag_coord, in vec2 position, in vec2 size, float radius)
+// Apparently this conflicts with existing GLSL distance(T a, T b) function
+float distance1(in vec2 frag_coord, in vec2 position, in vec2 size, float radius)
{
// TODO: Try SDF approach: https://www.shadertoy.com/view/wd3XRN
vec2 inner_size = size - vec2(radius, radius) * 2.0;
@@ -35,10 +36,10 @@ void main() {
vec2 fragCoord = vec2(gl_FragCoord.x, u_ScreenHeight - gl_FragCoord.y);
// TODO: Remove branching (?)
- if(v_BorderWidth > 0) {
+ if(v_BorderWidth > 0.) { // 0 is int, 0. is float
float internal_border = max(v_BorderRadius - v_BorderWidth, 0.0);
- float internal_distance = distance(
+ float internal_distance = distance1(
fragCoord,
v_Pos + vec2(v_BorderWidth),
v_Scale - vec2(v_BorderWidth * 2.0),
@@ -56,7 +57,7 @@ void main() {
mixed_color = v_Color;
}
- float d = distance(
+ float d = distance1(
fragCoord,
v_Pos,
v_Scale,
diff --git a/glow/src/shader/quad.vert b/glow/src/shader/quad.vert
index d37b5c8..08a4d7c 100644
--- a/glow/src/shader/quad.vert
+++ b/glow/src/shader/quad.vert
@@ -1,4 +1,5 @@
-#version 330
+#version 300 es
+precision mediump float;
uniform mat4 u_Transform;
uniform float u_Scale;
diff --git a/glow/src/shader/triangle.frag b/glow/src/shader/triangle.frag
index d186784..e71c07c 100644
--- a/glow/src/shader/triangle.frag
+++ b/glow/src/shader/triangle.frag
@@ -1,4 +1,5 @@
-#version 330
+#version 300 es
+precision mediump float;
in vec4 v_Color;
diff --git a/glow/src/shader/triangle.vert b/glow/src/shader/triangle.vert
index 5723436..e1efa59 100644
--- a/glow/src/shader/triangle.vert
+++ b/glow/src/shader/triangle.vert
@@ -1,4 +1,5 @@
-#version 330
+#version 300 es
+precision mediump float;
uniform mat4 u_Transform;
diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml
index 8e078d7..9a1e912 100644
--- a/graphics/Cargo.toml
+++ b/graphics/Cargo.toml
@@ -29,7 +29,7 @@ version = "0.15"
optional = true
[dependencies.font-kit]
-version = "0.6"
+version = "0.9"
optional = true
[package.metadata.docs.rs] |
Correction: it really should be |
@w23, awesome, thank you very much for looking into this! |
@hecrj, any ideas on why Vulkan version does not work? The UI window is shown, but not a single frame is rendered. Eventually the app crashes with the message:
I've updated vulkan drivers and standard demos like gears are working perfectly. Even complicated scenes like this are reportedly working. So I doubt that the issue is with the drivers themselves. How can I help to debug the issue? |
@0x7CFE It'd help if you could try the |
In the meantime I contacted wgpu developers on their Matrix channel and we discussed the situation. Wgpu examples all fail in one way or another. They also suggested me to try out the Still, I think that implementing |
Here's the issue related to a swap chain timeout error that's triggered by the Vulkan backend: https://gitlab.freedesktop.org/apinheiro/mesa/-/issues/8 Looks like the v3dv authors do not quite understand why that happens. Unfortunately, that probably means that they would not investigate more before sorting out other issues and making the driver conformant. So far, nothing had changed regarding the issue :( |
Good news everyone! I was finally able to run some Igalia v3dv driver is now approaching its 1.0 and authors are working on Vulkan conformance tests, so core functionality is already there. Hopefully we would have real Vulkan support soon on RPi4. |
Still, current performance is quite low and there are a lot of rendering artifacts. |
Can you share more about your setup? The v3dv driver is now merged into mesa, but I don't seem to be able to get it to run Iced properly. For instance:
I have also tried some wgpu examples and I reproduce the observations made there... My setup:
|
in my case I get this error when I run some basic code using Iced (branch: master) with RP4:
|
See the comment above: #428 (comment) |
It's glitching for me as well, much like solar system and others. Tested on Also game of life example looks kinda upside-down. All controls and fonts are mirrored vertically. |
Patched GL version now work seamlessly for me 🎉 |
@hecrj, @SimplyNaOH, @dancespiele, you may check out my patch: https://github.com/0x7CFE/iced/tree/gl300es |
@0x7CFE I looked this branch https://github.com/0x7CFE/iced/tree/gl300es and it seems that it just adds those lines to Cargo.toml: [patch.crates-io]
glow_glyph = { git = "https://github.com/0x7CFE/glow_glyph.git", branch = "gl300es" } And it seems change that you made for I saw the same error message on RPi as @dancespiele reported and I tried to reproduce @0x7CFE results, however so far unsuccesfully. My application Cargo.toml looks like this: [dependencies]
iced = { version = "0.2", default_features = false, features = ["tokio_old", "glow", "glow_canvas"] }
iced_native = "0.3"
tokio = { version = "0.2", features = ["full"] }
[patch.crates-io]
glow_glyph = { git = "https://github.com/0x7CFE/glow_glyph.git", branch = "gl300es" } Cargo.lock file shows that
I wonder what I am missing, what else must be patched? |
That's strange. Maybe I didn't commited everything and some shader still refer to GL 3.30 |
See this commit which is in the branch: 6ff29ef |
would a simple ui work on raspberry pi zero? or does it need harware graphics? |
Hi,
I'm trying to use iced on my Raspberry 4. So far I managed to make it compile. It even runs and the window is shown, but no frame is rendered. Eventually it exits with the following error:
Before I patched the
iced
dependencies it failed to compile:I updated
iced_graphics
'font-kit
dependency to0.9
and the error disappeared. I was able to build and execute examples, but rendering fails for some reason. Here's the typical output: https://gist.github.com/0x7CFE/3f29f6d7fccd67bd8804ad47c97daaa5 Also, please notice a ton of font errors.Currently Raspberry Pi 4 has only experimental but working Vulkan support. Yet I thought that for 2D stuff it should probably be enough.
I will be happy to hear any suggestions.
P.S.: Since iced is render agnostc, is it possible to build it on top of OpenGL? Maybe that would be easier than trying to debug alpha version of the Vulkan driver.
The text was updated successfully, but these errors were encountered: