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

Add kawase blur #120

Merged
merged 80 commits into from
Apr 17, 2023
Merged

Add kawase blur #120

merged 80 commits into from
Apr 17, 2023

Conversation

ErikReider
Copy link
Collaborator

@ErikReider ErikReider commented Mar 10, 2023

Fixes: #5

Todo/discussion:

  • Config options
  • Fix stencil issues with overlaying floating windows (damage tracking issue)
  • Code cleanup
  • Fix scaling issues
  • Option to ignore fully transparent windows? (Can be added through a separate PR instead)
  • Optimization: Blur the background of tiled windows once
  • Add xray option like Hyprland? (only blurs once instead of for each window)
  • Fix blur flickering when resizing window
  • Investigate the dual monitor issue
  • Ensure that 4a8214f and db68f4a still optimally track the damage in render_blur
  • Ensure passing the surface scale to render_blur (as is the case now) doesn't cause breakage when using a scaled output

image

@ErikReider ErikReider added the enhancement New feature or request label Mar 10, 2023
@ErikReider ErikReider self-assigned this Mar 10, 2023
@WillPower3309
Copy link
Owner

I suspect we wouldn't need to account for CSD with this, as it would just render in the region inside of the window

@ErikReider
Copy link
Collaborator Author

I suspect we wouldn't need to account for CSD with this, as it would just render in the region inside of the window

Good catch! :)

@ErikReider
Copy link
Collaborator Author

Sorry, tried to flick the mouse to the comment text field but accidentally clicked "close with comment"... Guess that's why I've always been stuck at DMG in CS 😅

Anyways, I found this interesting page with debugging flags. Running sway with -D damage=rerender (disabling damage tracking) fixes all artifacts. So now we just need to track down what's not working with out current damage tracking. Help would be appreciated :)

@WillPower3309
Copy link
Owner

Sorry, tried to flick the mouse to the comment text field but accidentally clicked "close with comment"... Guess that's why I've always been stuck at DMG in CS 😅

Anyways, I found this interesting page with debugging flags. Running sway with -D damage=rerender (disabling damage tracking) fixes all artifacts. So now we just need to track down what's not working with out current damage tracking. Help would be appreciated :)

Great to know, good find! I can take a look on Tuesday during my flight! I'll probably have time tomorrow as well

@ErikReider
Copy link
Collaborator Author

Made some damage tracking fixes. Not fully fixed. Looks like it's rendering more than it needs to, creating the artifacts.

It includes the black blurred edges which is only supposed to be rendered inside of the effects buffers, and render a cropped version (the red area in the image below) into the main buffer.

image

@ErikReider
Copy link
Collaborator Author

Here's a video summary of what the damage issues are in case anyone's curious:

2023-03-16.00-06-26.mp4

@WillPower3309
Copy link
Owner

As noted on our discord discussion, #127 would simplify this, and could potentially fix some of the damage tracking issues. We could even have blurred borders depending on how we implement #25 as a follow up

@WillPower3309
Copy link
Owner

Question: what do you mean by blur the background of tiled windows once? Is it currently done multiple times?

@ErikReider
Copy link
Collaborator Author

Question: what do you mean by blur the background of tiled windows once? Is it currently done multiple times?

Before rendering we should gather a whole monitor blurred texture of what's behind the tiled windows once and use that for tiled windows instead of regathering the blur for each window (which is really expressive)

@WillPower3309
Copy link
Owner

Rebased from head

@WillPower3309
Copy link
Owner

WillPower3309 commented Mar 21, 2023

Can't reproduce the issues anymore.
Edit: never mind, I definitely can, but it doesn't occur with a certain config:

config.txt

I have not been able to reproduce your damage tracking issue, if I use a config without the

corner_radius 5
smart_corner_radius on
smart_gaps on
smart_borders off
shadows on
shadows_on_csd on 
shadow_blur_radius 20
shadow_color #000000FF
gaps inner 10
default_border pixel 2

At the bottom, i just get artifacts at the bottom of the surface, visible on the window on the right:
2023-03-21_00-03-1679372112

The artifact at the top strangely only appears when I screenshot.

@ErikReider
Copy link
Collaborator Author

Yeah, when switching focus to a different "layer" the artifacts always appear just like when I switch focus to another window when running it inside my current sway session

@WillPower3309
Copy link
Owner

Here's the commit that added blur to Hyprland: hyprwm/Hyprland@969bebb

Obviously the complexity there has increased with time, but thats the initial commit they had.

@ErikReider
Copy link
Collaborator Author

@vector1dev does it work with tiled windows/floating windows with blur_xray?

@WillPower3309
Copy link
Owner

WillPower3309 commented Apr 14, 2023

  • Ensure that 4a8214f and db68f4a still optimally track the damage in render_blur

Tested and it works as expected :)

Like it damages the exact same area? Just wanna make sure we're as performant as possible :)

sway/desktop/render.c Outdated Show resolved Hide resolved
sway/desktop/render.c Outdated Show resolved Hide resolved
@WillPower3309
Copy link
Owner

Happy to address the review comments myself, just left them in case anyone gets to it before me as my time is limited tomorrow :)

@ghost
Copy link

ghost commented Apr 15, 2023

@vector1dev does it work with tiled windows/floating windows with blur_xray?

No, floating windows broken. Tiled broken too.
on first monitor - works.
on second monitor - blur don't work.

@ErikReider
Copy link
Collaborator Author

ErikReider commented Apr 15, 2023

Like it damages the exact same area? Just wanna make sure we're as performant as possible :)

I'm guessing that you were referring to the pixman functions right?

pixman_region32_intersect_rect(&render_damage, &damage, dst_box->x, dst_box->y, dst_box->width, dst_box->height);

Should do the same thing as

pixman_region32_union_rect(&render_damage, &render_damage, dst_box.x, dst_box.y, dst_box.width, dst_box.height);
pixman_region32_intersect(&render_damage, &render_damage, damage);

But I might have misunderstood what the functions are doing due to the lack of pixman documentation...

Edit: Reading the code confirms that it's the same :)

@WillPower3309
Copy link
Owner

@vector1dev does it work with tiled windows/floating windows with blur_xray?

No, floating windows broken. Tiled broken too.
on first monitor - works.
on second monitor - blur don't work.

Thanks for letting us know! Were you using the latest version of the blur branch?

@ghost
Copy link

ghost commented Apr 15, 2023

@vector1dev does it work with tiled windows/floating windows with blur_xray?

No, floating windows broken. Tiled broken too.
on first monitor - works.
on second monitor - blur don't work.

Thanks for letting us know! Were you using the latest version of the blur branch?

Yes.

Copy link
Collaborator Author

@ErikReider ErikReider left a comment

Choose a reason for hiding this comment

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

Thanks! My fever brain couldn't really figure this one out 😅

@ErikReider
Copy link
Collaborator Author

ErikReider commented Apr 15, 2023

@vector1dev can you send a log? My guess would be that

*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed
Set a breakpoint on '_pixman_log_error' to debug

will appear.

Also, what specs are you rocking?

@WillPower3309
Copy link
Owner

Also, config pls :)

@ErikReider
Copy link
Collaborator Author

a7d6d5e Should fix any damage integer overflow issues so you @vector1dev should try the latest commit and see if it's fixed or not :)

@ghost
Copy link

ghost commented Apr 16, 2023

a7d6d5e Should fix any damage integer overflow issues so you @vector1dev should try the latest commit and see if it's fixed or not :)

Fixed. Thank you!

@ErikReider
Copy link
Collaborator Author

Everything should finally be ready for review! 🥳

@ErikReider ErikReider merged commit cbfb7af into master Apr 17, 2023
@ErikReider ErikReider deleted the blur branch April 17, 2023 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blur transparent window elements
3 participants