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

Write custom shaders for circular gauges #602

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chriadam
Copy link
Contributor

@chriadam chriadam commented Dec 8, 2023

Animating the Shape-based circular gauges is too expensive. So reimplement it as a single-pass shader.

@chriadam
Copy link
Contributor Author

chriadam commented Dec 8, 2023

WIP, don't merge. I'll create implementations for the generic ProgressArcs too (they're trickier since the arc specified can be part of a notional circle whose diameter is far greater than the width or height of the gauge itself).

@chriadam chriadam force-pushed the chriadam/shader-circular-guage branch from 6bc678f to d6bf8b5 Compare December 14, 2023 09:40
Animating the Shape-based gauges is too expensive.
So reimplement them as single-pass shaders.
@chriadam chriadam force-pushed the chriadam/shader-circular-guage branch from d6bf8b5 to 10e70ee Compare December 14, 2023 09:46
@chriadam chriadam changed the title WIP: write customer shaders for circular gauges Write custom shaders for circular gauges Dec 14, 2023
@chriadam
Copy link
Contributor Author

Still WIP. Need to test on CerboGX.
Doesn't work on WebAssembly (but it definitely should, I think it's just a qsb issue).
Aside from that, basically finished.

@chriadam
Copy link
Contributor Author

Unfortunately, https://bugreports.qt.io/browse/QTBUG-120112 might mean that we have to wait until Qt 6.6.x for this to work on webassembly, at least. This may not be a problem, since the performance problems don't show up on webassembly or desktop, but only on the CerboGX, so we can just load different types depending on the platform (shader vs non-shader gauges).

The bigger problem is: (I haven't tested yet, but it's very possible that) the shader performance is poor on CerboGX due to the complexity of the shader. It may not be possible to draw everything using the shader, but instead draw only the progress bar with the shader. But, let's see, once we have the shader tools added to the SDK.

@DanielMcInnes
Copy link
Contributor

@chriadam can you convert this PR to draft if it is not ready for review yet?

@chriadam chriadam marked this pull request as draft December 19, 2023 03:24
@chriadam
Copy link
Contributor Author

By changing the name of the fragment shader's input from "coord" to "qt_TexCoord0" (to match Qt's default vertex shader output for older GLSL targets) the shaders now work.

However, on the CerboGX they are incredibly slow, due to how complex the shaders are (e.g. the antialiasing, shine effect, etc).
I will look at simplifying them to see whether we can get them to acceptable performance.

@@ -343,6 +343,7 @@ int main(int argc, char *argv[])
engine.setProperty("screenSize", (round(screenDiagonalMm / 10 / 2.5) == 7)
? Victron::VenusOS::Theme::SevenInch
: Victron::VenusOS::Theme::FiveInch);
engine.setProperty("screenSize", Victron::VenusOS::Theme::SevenInch);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

debugging, should remove.

#version 440
#define CONSTANT_PI 3.141592653589793
#define CONSTANT_TAU 6.283185307179586
layout(location = 0) in vec2 coord;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

have to change this to qt_TexCoord0 to work around QTBUG-120112

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