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 Native Wayland Support V2 + Minor Nvidia/Performance Optimisations #325

Merged
merged 8 commits into from
Nov 18, 2023

Conversation

thr3343
Copy link
Contributor

@thr3343 thr3343 commented Nov 3, 2023

This is similar to the prior PR, but with some various technical enhancements over the original

  • Use Alternate Swapchain System

    • Designed to fix and address major gamebreaking stability issues with the Mesa/RADV driver on Linux
    • Should not cause any issues on other platforms AFAIK
    • Swapchain is adjusted based on GPU minImageCount
      • Which may improve performance on some systems
  • Much more reliable display server detection

    • The original PR used a flawed detection method, that often failed to detect X11/Wayland properly
  • FastSync (aka Mailbox Mode) is used by default for VSync Off

    • Falls back to Immediate mode if not supported
    • This change was made to allow exposing FastSync on all platforms if supported
      • (instead of being restricted to Wayland only)
    • Also might be needed for FreeSync (Unconfirmed, i'm probably wrong)
  • Minor performance optimisations

    • includes a Nvidia specific adjustment to use 24-bit depth format instead of 32-bit
    • This also does some minor code cleanup, but have no issue reverting these if needed

Needed to fix Wayland stability on Mesa/RADV Driver
@thr3343 thr3343 changed the title Add Native Wayland Support V2 + Minor Performance Optimisations Add Native Wayland Support V2 + Minor Nvidia/Performance Optimisations Nov 3, 2023
@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch from 1eb8bfa to e9ca823 Compare November 3, 2023 17:11
@ElectricLizzzard
Copy link

I cannot break it in any way. It passed all stress tests and tested in real life scenarios with just playing it. Rock stable. Platform detection also works as expected.

@Etaash-mathamsetty
Copy link

Etaash-mathamsetty commented Nov 6, 2023

tysm for the RADV fixes, finally somebody figured out what the issue was after 2 years

Swapchain is adjusted based on GPU minImageCount

    Which may improve performance on some systems

I tried to make a PR for this and it never got merged lol, even though the code back then wasn't following spec

@Etaash-mathamsetty
Copy link

works as expected and working better than the main branch is on RADV, tysm once again

@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch 7 times, most recently from 56e8dab to 8b589c7 Compare November 10, 2023 14:33
@thr3343
Copy link
Contributor Author

thr3343 commented Nov 10, 2023

Apologies for the huge Use Queue Enum commit
It was originally for a refactor PR I was planning to do later in the year, but i misclicked and added it by complete accident.

It has a very minor FPS improvement and it also fixes VSync on old Nvidia GPUs,
But outside that it is alot of refactoring for not much benefit, and it has nothing to do with Wayland at all.
So feel free to remove it if needed.

@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch from 8b589c7 to 7eee159 Compare November 10, 2023 15:28
@ElectricLizzzard
Copy link

ElectricLizzzard commented Nov 13, 2023

I would state that right now this PR is giving seamless from Vanilla experience both on Wayland and X11. The only one difference is monstrous amount of frames per second. The only times my GPU not hitting 100% load is in locations with a large number of entities, but this is completely different story.

There is only problem with Nvidia being BAD on Wayland. I hope this will be fixed soon by Nvidia itself.

Last bug that do not affect gameplay in any way but still irritates is swapchain destroy bug, when game is closed by user and this cause instance lag and crash with error 6. But this is not that's PR explicit bug. It appears in stable release too.

@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch 8 times, most recently from 350f64a to f0382e3 Compare November 17, 2023 17:04
(i.e. Wayland is fussy about the order, and Window handle must be destroyed after the Swapchain and vkInstance, and not before)

Rebase

This reverts commit 7eb7a5f.

Refactor Chunk rendering + Improve Draw Direct Performance

Make PushConstants per ChunkArea instead of per RenderSection;  Reduces PushConstant CPU usage by over 100x in DrawCall heavy scenarios

Use compile time length for ChunkArea SectionQueues to improve JIT Optimisations

Merge Direct/Indirect Shaders:
Use same shader for both Direct and Draw Indirect + remove Indirect Pipeline

Skip 0 index (i.e. empty draw calls) checks + reduce DescriptorSet binding Frequency

Faster Gaussian Sky Blending

[GPU Optimisation]: Separate VertexBuffers per RenderType

Use Queue Enum + Split CommandPools based on Queue/Operation Type

Dedicated Transfer Queue specific fixes

Enable VK12 VMA Features

Bizarrely Improves Performance by at least 15/20% according to initial testing

Optimise Chunk Shader

(May either have no performance improvement and/or have possible Shader/Visual artefacts)

Early-Z Optimisations + Reduce AreaBuffer Fragmentation + Final Cleanup

(Quick Summary)

* Align Sizes to power of 2
* Reduce Pipeline Binding Frequency
* Refactor ChunkTask to use RenderType enums to reduce CPU +
* improve JIT optimisations
* Try to use Early-Z on Translucent RenderType

Fix Segfault on Wayland when closing the client

(i.e. Wayland is fussy about the order, and Window handle must be destroyed after the Swapchain and vkInstance, and not before)

Revert "Rebase"

This reverts commit f0382e3.
@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch from f0382e3 to 66bcb0a Compare November 17, 2023 17:05
@thr3343
Copy link
Contributor Author

thr3343 commented Nov 17, 2023

Reverted alot of the performance optimisations as one of them was causing specific errors on Staging buffer copies, and due to this PR being a mess the breaking commit couldn't be tracked down.

So used a Squash to delete/nuke the commits, including the breaking change(s).

Don't mind doing this as I have the unedited original + commits in a separate "backed up" branch made yesterday.

(So nothing was lost anyway TBH)

@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch 16 times, most recently from 2469467 to 57e2f83 Compare November 17, 2023 21:12
@thr3343
Copy link
Contributor Author

thr3343 commented Nov 17, 2023

Despite what I said above, i did decide in the end to re-add some of the optimisation-related changes,
These are relatively minor code changes unlike before, so the chance/risk of subsequent crashes/issues is very low, at least AFAIK

@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch 3 times, most recently from 0a0db52 to 5feef2a Compare November 17, 2023 23:52
@thr3343 thr3343 force-pushed the NativeWaylandTestV3.2-Final branch from 5feef2a to 5b86221 Compare November 17, 2023 23:52
@xCollateral xCollateral merged commit 74b12ca into xCollateral:1.20.x Nov 18, 2023
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.

4 participants