Skip to content

Conversation

@mborgerson
Copy link
Member

Fix #2253 while we are at it

@gemini-code-assist
Copy link

Summary of Changes

Hello @mborgerson, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the Vulkan instance creation and initialization process by eliminating its reliance on SDL for windowing and associated extension management. The changes aim to simplify the codebase, enforce a baseline Vulkan 1.1 API version for physical devices, and improve the flexibility of the Vulkan Memory Allocator by allowing it to dynamically leverage the highest available Vulkan API version supported by the hardware.

Highlights

  • SDL Dependency Removal: The pull request completely removes the dependency on SDL for Vulkan instance creation and window management, streamlining the setup process.
  • Vulkan Extension Handling Simplification: The logic for handling required instance and device extensions has been simplified, removing several previously explicit KHR extensions and relying more on core Vulkan 1.1 features.
  • Vulkan API Version Enforcement and Adaptability: A minimum Vulkan 1.1 API version is now explicitly enforced for compatible physical devices. The Vulkan Memory Allocator (VMA) initialization dynamically adapts its API version based on the device's capabilities, conditionally enabling Vulkan 1.3 functions when available.
Changelog
  • hw/xbox/nv2a/pgraph/vk/instance.c
    • Removed includes for SDL3/SDL.h and SDL3/SDL_vulkan.h.
    • Deleted create_window and destroy_window functions, along with their calls within create_instance and pgraph_vk_finalize_instance.
    • Removed the required_instance_extensions array and the get_required_instance_extension_names function.
    • Updated the VkApplicationInfo.apiVersion from VK_API_VERSION_1_3 to VK_API_VERSION_1_1.
    • Added a check in is_device_compatible to ensure the physical device's API version is at least VK_API_VERSION_1_1.
    • Modified init_allocator to directly assign core Vulkan 1.1 functions to VMA's VmaVulkanFunctions struct and to dynamically set VmaAllocatorCreateInfo.vulkanApiVersion based on the device's API version, including conditional assignment for Vulkan 1.3 functions.
  • hw/xbox/nv2a/pgraph/vk/renderer.h
    • Removed the window member from the PGRAPHVkState struct.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request provides a nice cleanup of the Vulkan instance creation logic. Removing the dependency on SDL for creating a hidden window simplifies the code and improves portability for headless environments. The move to require Vulkan 1.1 as a baseline and dynamically checking for device capabilities is a solid improvement. The changes to the VMA initialization are also more robust. Overall, these changes enhance code clarity and maintainability. I have one minor suggestion to ensure build portability with older Vulkan SDKs.

Comment on lines +599 to +604
if (device_api_version >= VK_API_VERSION_1_3) {
vulkanFunctions.vkGetDeviceBufferMemoryRequirements =
vkGetDeviceBufferMemoryRequirements;
vulkanFunctions.vkGetDeviceImageMemoryRequirements =
vkGetDeviceImageMemoryRequirements;
}

Choose a reason for hiding this comment

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

medium

The conditional assignment for Vulkan 1.3 functions is a good improvement over the previous compile-time check. However, the fields vkGetDeviceBufferMemoryRequirements and vkGetDeviceImageMemoryRequirements only exist in the VmaVulkanFunctions struct if the Vulkan SDK version is 1.3 or newer (specifically, if VMA_VULKAN_VERSION >= 1003000).

By removing the preprocessor guard, this code might fail to compile with an older Vulkan SDK. To ensure portability, it would be safer to wrap this block in the same preprocessor condition that VMA uses for these struct members.

    #if VMA_VULKAN_VERSION >= 1003000
    if (device_api_version >= VK_API_VERSION_1_3) {
        vulkanFunctions.vkGetDeviceBufferMemoryRequirements =
            vkGetDeviceBufferMemoryRequirements;
        vulkanFunctions.vkGetDeviceImageMemoryRequirements =
            vkGetDeviceImageMemoryRequirements;
    }
    #endif

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.

Add support for Vulkan 1.1 or 1.2 for low end/older devices on Linux ARM64

1 participant