Skip to content

core: fix background screenshot on nvidia#656

Merged
vaxerski merged 6 commits intohyprwm:mainfrom
PointerDilemma:nvidia-fix-screencopy
Jan 24, 2025
Merged

core: fix background screenshot on nvidia#656
vaxerski merged 6 commits intohyprwm:mainfrom
PointerDilemma:nvidia-fix-screencopy

Conversation

@PointerDilemma
Copy link
Collaborator

@PointerDilemma PointerDilemma commented Jan 21, 2025

Fixes screencopy on nvidia by falling back to a shm buffer when dma failes.

Closes #59

@PointerDilemma
Copy link
Collaborator Author

I guess we probably want a option to enable it per default, so that we don't have to wait for dma to fail.

@PointerDilemma PointerDilemma marked this pull request as ready for review January 21, 2025 11:41
@PointerDilemma PointerDilemma force-pushed the nvidia-fix-screencopy branch 3 times, most recently from 6f7f93f to 9a7b544 Compare January 21, 2025 11:48
@PointerDilemma PointerDilemma force-pushed the nvidia-fix-screencopy branch 2 times, most recently from 01f1022 to e5c35ff Compare January 21, 2025 12:09
@PointerDilemma
Copy link
Collaborator Author

I tested with a 3060ti and 550.142 drivers on Hyprland (10-bit as well) and sway (sends a different shm format, tested 24->32).

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

generally dma on nvidia should work and there's likely a mistake in the code somewhere. I mean, aquamarine creates buffers just fine.

I guess this is a fair enough compromise for now though (shm is slooow)

@PointerDilemma
Copy link
Collaborator Author

you mean it should work with non-linear modifiers??

@vaxerski
Copy link
Member

yeah, nvidia can render to non-linear.

@PointerDilemma
Copy link
Collaborator Author

... but it can't bind them to GL_TEXTURE_2D right?
And when using GL_TEXTURE_EXTERNAL_OES, i do get a frame for non linear mods and can render it, but there are graphical glitches, that i assumed to be cause egl cannot handle non linear. Did i get smth wrong here?

@vaxerski
Copy link
Member

no, external is needed for linear. Most modifiers should be fine with GL_TEXTURE_2D. See
https://github.com/hyprwm/Hyprland/blob/d335c8f10135e165a1085fd14134c659e4caf05a/src/render/OpenGL.cpp#L379-L422

@PointerDilemma
Copy link
Collaborator Author

Using eglCreateDRMImageMESA instead of eglCreateImage works. Probably because the buffer get's exported via mesa and not nvidia.

@PointerDilemma PointerDilemma force-pushed the nvidia-fix-screencopy branch 2 times, most recently from 9b55cb6 to b778376 Compare January 22, 2025 18:43
@PointerDilemma
Copy link
Collaborator Author

Ok since dma also works for nvidia now, I removed the auto option from general:screencopy_mode.
We will keep the cpu buffer implementation just in case someone needs it.

Fixes DMA buffer screencopy on nvidia cards.
Probably because the sc buffer gets exported by mesa and not nvidia.
Why was it so hard to find this?
@PointerDilemma
Copy link
Collaborator Author

Ok so on my old intel laptop eglCreateDRMImageMESA did not work. presumably because the frame was not exported by mesa but by an intel driver??

It now tries eglCreateImage if the mesa one failed to fix that.

Removes the need for eglCreateDRMImageMESA.
@PointerDilemma
Copy link
Collaborator Author

So in the end we were just missing EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT and EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT. No need for eglCreateDRMImageMesa.
Thankfully vaxry pointed me to the aquamarine source, where I noticed that was missing.

@PointerDilemma PointerDilemma changed the title core: add cpu fallback for screencopy core: fix background screenshot on nvidia Jan 23, 2025
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

wonderful

@vaxerski vaxerski merged commit 07b5e1b into hyprwm:main Jan 24, 2025
1 check passed
@PointerDilemma PointerDilemma deleted the nvidia-fix-screencopy branch April 4, 2025 07:46
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.

[nvidia] Screenshot feature seems to be broken

2 participants