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

Introduce geometry primitives #1862

Merged
merged 25 commits into from
May 7, 2024
Merged

Introduce geometry primitives #1862

merged 25 commits into from
May 7, 2024

Conversation

Caellian
Copy link
Collaborator

@Caellian Caellian commented Apr 25, 2024

Changes

This PR introduces point and rect primitives and replaces previous value pairs with them. It also replaces output-wayland.cc rectangle as it's effectively doing the same.

This aims to make future changes more consistent and to reduce number of global variables by grouping them. As a side bonus, it allows us to optimize some common operations a little by relying on Vc to make the compiler more aware of available opportunities to parallelize computation. Just grouping things results in significant reduction in number of generated move instructions:

image

Details

  • Added vec and rect structures.
  • Added Vc dependency for better SIMD optimization of common vector operations.
    • This was previously done through Eigen, but I removed Eigen as 90% of its functionality wouldn't ever be used by Conky so it only added to maintenance burdain.

These are based on Eigen and will basically get compiled away into ideal
representations for each platform conky is compiled for. This means that
many operations can be SIMD optimized with very little effort.

Signed-off-by: Tin Švagelj <[email protected]>
Copy link

netlify bot commented Apr 25, 2024

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit c22dba9
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/6637e1c936cd2c000874ff76

@github-actions github-actions bot added sources PR modifies project sources dependencies adds or removes dependencies, or suggests alternatives display: x11 related to X11 backend lua related to Lua integration in conky mouse events related to mouse event handling labels Apr 25, 2024
@Caellian Caellian force-pushed the fix/screen-geometry branch from c680997 to 31da166 Compare April 25, 2024 16:52
@github-actions github-actions bot added the gh-actions suggest changing GitHub actions label Apr 25, 2024
@github-actions github-actions bot added the display: wayland related to Wayland backend label Apr 25, 2024
@Caellian
Copy link
Collaborator Author

Caellian commented Apr 25, 2024

@brndnmtthws Is it okay to add Eigen as dependency? I can do without it, but it might optimize some instructions. Alternatively, I could make it optional and apply SIMD only if present.

EDIT: We do surprisingly many vector computations while drawing components. I don't use majority of Eigen though. It might be better to simply add a way to provide optimized assembly for certain architectures and data types. 🤷‍♂️ And then someone can easily add optimizations later if they want to.

@Caellian Caellian force-pushed the fix/screen-geometry branch 2 times, most recently from 672fa4e to e3f8d3f Compare April 25, 2024 18:16
Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the fix/screen-geometry branch from e3f8d3f to a7c6fd1 Compare April 25, 2024 18:19
This should help avoid bad pointer reinterpretation.

Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the fix/screen-geometry branch from 35feea4 to edc6390 Compare April 25, 2024 18:29
@Caellian Caellian linked an issue Apr 25, 2024 that may be closed by this pull request
Also fixed bad previous substitutions. Will go through all of them at
the end just in case, though this time I replaced them one component at
a time.

Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian linked an issue Apr 25, 2024 that may be closed by this pull request
Copy link
Collaborator Author

@Caellian Caellian left a comment

Choose a reason for hiding this comment

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

Last commit is expected be functionally equivalent to original. Besides noted exceptions.

@Caellian Caellian force-pushed the fix/screen-geometry branch from 251bd38 to cac4361 Compare April 25, 2024 20:00
Added intermediate member access structures which map direct
member access and mutation into indirect one as provided by eigen an
most other representations. This should _almost_ always just work, but
in some cases template specialization consuming these values might fail
in which case dereferencing them should work.

Sadly there's no way of providing `T&` access to values because actual
data layout and representation can be wildly different between different
architectures. Even if eigen wasn't being used, if we want to make use
of SIMD we have to provide access through separate getters and setters.

All this abstraction should be optimized away by the compiler, so it's
just adding API ergonomics.

Signed-off-by: Tin Švagelj <[email protected]>
Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian added the priority: low issue that's not encountered often or hard to reproduce label Apr 29, 2024
Signed-off-by: Tin Švagelj <[email protected]>
Signed-off-by: Tin Švagelj <[email protected]>
@Caellian Caellian force-pushed the fix/screen-geometry branch from e324fae to bb232b0 Compare April 30, 2024 16:31
@github-actions github-actions bot removed 3rdparty suggests changes to 3rd party dependencies dependencies adds or removes dependencies, or suggests alternatives build system related to build system (CMake) and/or building process/assumptions labels Apr 30, 2024
@brndnmtthws brndnmtthws added the feature suggest addition of new functionality that isn't currently supported in any way label May 1, 2024
@github-actions github-actions bot added 3rdparty suggests changes to 3rd party dependencies build system related to build system (CMake) and/or building process/assumptions and removed tests related to project tests labels May 5, 2024
@Caellian Caellian force-pushed the fix/screen-geometry branch from 9b96af3 to 963552c Compare May 5, 2024 19:13
@Caellian Caellian marked this pull request as ready for review May 5, 2024 19:45
@Caellian Caellian removed the priority: low issue that's not encountered often or hard to reproduce label May 5, 2024
Copy link
Owner

@brndnmtthws brndnmtthws left a comment

Choose a reason for hiding this comment

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

👍 , seems like Vc is a better choice than Eigen for our needs.

This is a pretty big change, so it's probably going to have some unintended side effects. There are a few things I'd refactor, but probably better to do it in a separate PR later.

@Caellian
Copy link
Collaborator Author

Caellian commented May 7, 2024

There are a few things I'd refactor, but probably better to do it in a separate PR later.

Same here 😆, I just tried adding semantics to rectangle via tempates (absolute vs. sized) and realized there's a lot that could be improved. C++ doesn't have traits as Rust does so it's somewhat tricky to get things like swizzling to layer properly and still allow the compiler to optimize code.

I'll probably address those issues at some point, but it's better to have something and I don't want to keep this PR waiting for too long as it will be painful to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rdparty suggests changes to 3rd party dependencies build system related to build system (CMake) and/or building process/assumptions display: wayland related to Wayland backend display: x11 related to X11 backend feature suggest addition of new functionality that isn't currently supported in any way lua related to Lua integration in conky mouse events related to mouse event handling sources PR modifies project sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants