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

chore: Support multiple render backends #2359

Merged
merged 5 commits into from
Mar 30, 2024

Conversation

fredizzimo
Copy link
Member

What kind of change does this PR introduce?

This is mostly a refactoring in order to support multiple render backends, like D3D, and makes the actual PR that implements the D3D backend much smaller.

  • WindowContext has been renamed to SkiaRenderer, which can have different implementations depending on the platform
  • The Gpu profiling system now supports multiple backends, and code has been moved to a dedicated opengl implementation
  • VSyncWin has been renamed to VSyncWinDwm to allow a swapchain implementation for D3D.
  • The latency reduction optimization has been removed, as it is incompatible with some render backends.

Did this PR introduce a breaking change?

  • No

@fredizzimo fredizzimo marked this pull request as draft February 14, 2024 00:37
@fredizzimo fredizzimo force-pushed the fsundvik/support-render-backend branch 3 times, most recently from 31deb86 to 038b995 Compare February 14, 2024 00:51
@fredizzimo fredizzimo marked this pull request as ready for review February 14, 2024 00:52
@fredizzimo fredizzimo force-pushed the fsundvik/support-render-backend branch 2 times, most recently from 70fc54a to 110ea99 Compare February 14, 2024 00:59
use crate::profiling::{opengl::create_opengl_gpu_context, GpuCtx};

pub struct OpenGLSkiaRenderer {
// NOTE: The destruction order is important, so don't re-arrange
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a SAFETY instead of NOTE could fit better in order to convey that a critical invariant is upheld here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll keep the NOTE: the syntax highlighter highligts it, but not SAFETY:

Copy link
Contributor

@MultisampledNight MultisampledNight left a comment

Choose a reason for hiding this comment

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

Almost no nits code-wise, typical noisy GL setup. Haven't tested yet.

Comment on lines +88 to +89
NonZeroU32::new(size.width).unwrap(),
NonZeroU32::new(size.height).unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Those unwraps might very well blow up if starting in e.g. an initially minimized state, need to try that out.

Copy link
Member Author

Choose a reason for hiding this comment

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

The code is just moved, so it has been the same before. clamp_render_buffer_size should ensure that it's not zero.


let interface = skia_safe::gpu::gl::Interface::new_load_with(|name| {
if name == "eglGetCurrentDisplay" {
return std::ptr::null();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is eglGetCurrentDisplay filtered out? Can't we let get_proc_address also find eglGetCurrentDisplay? (possibly this is a peculiarity of EGL, I've never used EGL)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea, it was introduced here

After some discussion here

I found no issues in the glutin repository.

Comment on lines 16 to 17
#[cfg(target_os = "linux")]
use std::env;
Copy link
Contributor

Choose a reason for hiding this comment

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

Fwiw due to the moved detection logic, this import is actually unused and yields a warning

warning: unused import: `std::env`
  --> src/renderer/vsync/mod.rs:17:5
   |
17 | use std::env;
   |     ^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

Copy link
Member Author

Choose a reason for hiding this comment

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

That is now fixed. I was doing most of my testing on Windows, and that was part of one late change that never got properly tested on Linux.

@MultisampledNight
Copy link
Contributor

Test results:

  • On native wayland, everything's fine and smooth as ever.
  • On Xwayland, there's a few freezes the first few seconds after starting up, where interestingly the view keeps updating (the profiler keeps moving and displaying), but the entire text contents are not responding to any keypresses for a few seconds. Maybe this doesn't come from this PR though, I haven't tested main in a while.

@MultisampledNight
Copy link
Contributor

After retrying a few times between main and this branch on Xwayland, I can't seem to reproduce what I found initially, and found no meaningful differences. Ignore that then.

@fredizzimo
Copy link
Member Author

I'm not sure about the XWayland freeze, I can't think of any changes that could cause it, except this one 110ea99, but that should not affect x11 or xwayland at all.

The rest of the code should have stayed functionally the same.

@fredizzimo fredizzimo force-pushed the fsundvik/support-render-backend branch from dda3c83 to 4dabee7 Compare March 24, 2024 10:59
@Kethku Kethku merged commit 33237ed into neovide:main Mar 30, 2024
2 checks passed
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.

None yet

3 participants