Class VulkanModulePhysicalDevice
Instances are created by createPhysicalDevice(VulkanModuleVulkanInstance, VulkanModuleEntrypoint, Logger), which enumerates every device, discards
those that cannot present graphics or lack a required extension, and picks one. Discrete GPUs
are preferred over integrated ones, and a device named in configuration wins outright.
The queried structures are allocated off-heap and are owned by this object, so every device
that is enumerated must eventually be passed to cleanup() — including the ones that
lose the selection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionExtensions a device must support to be considered usable, currently just the swap chain. -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Frees the off-heap structures queried about this device.static VulkanModulePhysicalDevicecreatePhysicalDevice(VulkanModuleVulkanInstance instance, VulkanModuleEntrypoint vulkanModuleEntrypoint, Logger logger) Enumerates the available devices and selects one to render with.Returns the device's reported name.protected static org.lwjgl.PointerBuffergetPhysicalDevices(VulkanModuleVulkanInstance instance, org.lwjgl.system.MemoryStack stack, Logger logger) Enumerates the handles of every physical device the instance can see.org.lwjgl.vulkan.VkPhysicalDeviceMemoryPropertiesReturns the device's memory heaps and types.org.lwjgl.vulkan.VkPhysicalDeviceReturns the underlying Vulkan physical device.org.lwjgl.vulkan.VkPhysicalDeviceFeaturesReturns the optional features this device supports.org.lwjgl.vulkan.VkPhysicalDeviceProperties2Returns the device's properties, including its name, type, and limits.org.lwjgl.vulkan.VkQueueFamilyProperties.BufferReturns the queue families this device offers.booleansupportsExtensions(Set<String> extensions) Returns whether this device supports every one of the given extensions.
-
Field Details
-
REQUIRED_EXTENSIONS
-
-
Method Details
-
createPhysicalDevice
public static VulkanModulePhysicalDevice createPhysicalDevice(VulkanModuleVulkanInstance instance, VulkanModuleEntrypoint vulkanModuleEntrypoint, Logger logger) Enumerates the available devices and selects one to render with.A device named by
preferredDeviceNamein configuration is taken if it is present and otherwise suitable; failing that, a discrete GPU is preferred over an integrated one. Every device not selected is cleaned up before returning.- Parameters:
instance- the instance to enumerate devices fromvulkanModuleEntrypoint- the entrypoint supplying the preferred device namelogger- the logger to write selection diagnostics to- Returns:
- the selected physical device, owned by the caller
- Throws:
RuntimeException- if no device is present, or none meets the requirements
-
getPhysicalDevices
protected static org.lwjgl.PointerBuffer getPhysicalDevices(VulkanModuleVulkanInstance instance, org.lwjgl.system.MemoryStack stack, Logger logger) Enumerates the handles of every physical device the instance can see.- Parameters:
instance- the instance to enumerate fromstack- the stack to allocate the result buffer onlogger- the logger to write the device count to- Returns:
- a buffer of
VkPhysicalDevicehandles, valid for the stack frame - Throws:
AssertionError- if enumeration fails
-
getDeviceName
Returns the device's reported name.- Returns:
- the device name as the driver reports it
-
cleanup
public void cleanup()Frees the off-heap structures queried about this device.Must be called for every enumerated device, including those rejected during selection.
-
supportsExtensions
-
getVkMemoryProperties
public org.lwjgl.vulkan.VkPhysicalDeviceMemoryProperties getVkMemoryProperties()Returns the device's memory heaps and types.- Returns:
- the memory properties, owned by this object
-
getVkPhysicalDevice
public org.lwjgl.vulkan.VkPhysicalDevice getVkPhysicalDevice()Returns the underlying Vulkan physical device.- Returns:
- the
VkPhysicalDevice
-
getVkPhysicalDeviceFeatures
public org.lwjgl.vulkan.VkPhysicalDeviceFeatures getVkPhysicalDeviceFeatures()Returns the optional features this device supports.- Returns:
- the device features, owned by this object
-
getVkPhysicalDeviceProperties
public org.lwjgl.vulkan.VkPhysicalDeviceProperties2 getVkPhysicalDeviceProperties()Returns the device's properties, including its name, type, and limits.- Returns:
- the device properties, owned by this object
-
getVkQueueFamilyProps
public org.lwjgl.vulkan.VkQueueFamilyProperties.Buffer getVkQueueFamilyProps()Returns the queue families this device offers.Callers scan this to find a family with the capability they need, such as graphics or presentation.
- Returns:
- the queue family properties, owned by this object
-