Skip to content

Optimizing memory allocation for UMA devices. #857

Description

@gabrieljemail

Describe the request

I don't want to be this, but this is how I felt when I wrote the code behind this. I hope to help everyone here, and just improve others' code. Here is what the message is:

This is really easy to describe: you are allocating VRAM and the swapchain the standard way, but not the fast way. Here is a list of issues. I am already working on a PR since my fork already fixed all of them.

  1. No UMA support: Most people using VulkanMod just to play the game are using iGPUs like Intel integrated graphics. I am sure you understand the VRAM problem here. But you use device local memory for everything instead of host visible memory for them. This causes unnecessary copying and command uploading.
  2. Imprecise frame rate capping: This issue is actually a vanilla issue, but it could have been fixed. The issue is that normal thread sleep timers don't account for scheduler context switching while sleeping or just don't care if the timer is off by a couple milliseconds. The best way to fix this is to use a spin timer past a certain point. With my timing, this completely fixes frame pacing with FPS caps.
  3. Inflated shader parameters: You did compress position and UV parameters for the vertex shader, which is great. But it could have been smaller without breaking the game. I managed to get it down to 14 bytes per frame.
  4. Improper frame timing parameters: This one isn't as bad, but it is smoother to use more relaxed frame pacing modes with Vulkan. I used FIFO_RELAXED for VSync and MAILBOX for non-VSync, and it immediately felt smoother and didn't drop slightly off frames.
  5. Individual raycasts for block entities: This is also an issue that came with vanilla and doesn't affect rendering that much by default, but it matters. In your README, you claim reduced CPU overhead. While this is true, it can be improved even further.

These seem minor, but they personally got my low-end system from 110 average FPS to 220+ average FPS, with <2ms lower frame times. I am also not including some custom batching and optimized math/raycasting, but that's because they will break most mods. Even fullbright doesn't work, so don't even ask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions