Repository navigation
BGF: Minor Vulkan fixits - #129
Merged
Merged
Conversation
…numeration
Fix Vulkan device creation and capability reporting bugs in
base_game_framework:
- Reduced precision features: QueryDeviceCapabilities advertised F16/I8
math and 16-bit storage through GraphicsAPIFeatures, but the device was
created with none of them enabled, so shaders relying on them were
invalid. CreateDevice now chains the supported
VkPhysicalDeviceShaderFloat16Int8Features /
VkPhysicalDevice16BitStorageFeatures bits and enables any extensions
they need. 16-bit storage is core in Vulkan 1.1, and Float16/Int8 in
1.2, so the extensions are only used below those versions. On 1.0,
VK_KHR_16bit_storage also requires VK_KHR_storage_buffer_storage_class.
Feature structs that report no supported bits are not chained.
Extensions are only recorded once the feature query has succeeded, and
feature bits are reset before each query.
- InitializeGraphicsAPI queries device capabilities again on the real
instance's physical device. QueryCapabilities used a temporary instance.
- CreateDevice no longer sets device layers. They are deprecated, and VVL
1.4.347+ rejects them (VUID-VkDeviceCreateInfo-enabledLayerCount-12384),
so SetValidationLayersEnabled(true) failed device creation. Instance
layers already validate device calls. CreateDevice also returns failure
when vkCreateDevice fails instead of using a null device.
- Validation layer state: "validation layers were requested but
unavailable" is only logged when validation was actually requested (it
was logged on every launch). Unavailable layers no longer clear the
caller's static request.
- GetGraphicsAPIResourcesVk: fill in physical_device, which was always
VK_NULL_HANDLE. ShutdownGraphicsAPI clears it with the instance, and a
failed InitializeGraphicsAPI releases what it created.
- InitSwapchain: a VkSurfaceCapabilitiesKHR::maxImageCount of 0 means no
upper limit. It was treated as a maximum of 0, so every swapchain
request failed on such drivers. Document 0 as "no limit" for
SwapchainConfigurations::max_swapchain_frame_count.
- GetDisplayFormats: each format is listed once, and only if the surface
supports the exact VkFormat. RGBA8 was listed twice when the surface
reported both R8G8B8A8_UNORM and _SRGB, and was offered as
VK_FORMAT_R8G8B8A8_SRGB even if only UNORM existed. The color space now
means the same as in GLES. sRGB is an _SRGB VkFormat, which sRGB-encodes
writes, so it applies only to RGBA8/BGRA8. Linear covers RGBA8/BGRA8
UNORM (previously never offered) and the formats without an sRGB variant
(RGB565, RGBA_16F, ABGR2_10_10_10, ...). Those were labelled sRGB even
though writes are not encoded.
Tested on a Pixel 10 Pro with agdktunnel and Vulkan Validation Layers
1.4.363.1 (from third_party/android-binaries-1.4.363.1), using a
temporary test hook:
- With the layer injected via the Android GPU debug layer settings:
- A shader module using the Float16 and StorageBuffer16BitAccess
capabilities creates with no validation errors. Before, VVL reported
VUID-VkShaderModuleCreateInfo-pCode-08740 and
VUID-RuntimeSpirv-storageBuffer16BitAccess-11161.
- physical_device is valid (was 0x0).
- Display formats: 30 unique (RGBA8 sRGB and linear, RGBA_16F, RGB565,
ABGR2_10_10_10, each with 6 depth/stencil options). Before: 30 with 6
duplicate RGBA8 entries and no linear RGBA8.
- With SetValidationLayersEnabled(true) and no injection, the layer loads
through BGF and reports through its debug messenger. There is no
device layer error.
- No new validation errors in either mode. The two errors already on
main (swapchain semaphore reuse, and the surface destroyed before the
swapchain on window loss) are unchanged and tracked for PR 12.
- agdktunnel (requests RGBA8 sRGB) renders as before.
Not exercised on device: maxImageCount == 0 (this device reports 64), and
the Vulkan 1.0/1.1 extension paths (the device runs Vulkan 1.3, which
uses the core features).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Vulkan device creation and capability reporting bugs in
base_game_framework:
math and 16-bit storage through GraphicsAPIFeatures, but the device was
created with none of them enabled, so shaders relying on them were
invalid. CreateDevice now chains the supported
VkPhysicalDeviceShaderFloat16Int8Features /
VkPhysicalDevice16BitStorageFeatures bits and enables any extensions
they need. 16-bit storage is core in Vulkan 1.1, and Float16/Int8 in
1.2, so the extensions are only used below those versions. On 1.0,
VK_KHR_16bit_storage also requires VK_KHR_storage_buffer_storage_class.
Feature structs that report no supported bits are not chained.
Extensions are only recorded once the feature query has succeeded, and
feature bits are reset before each query.
instance's physical device. QueryCapabilities used a temporary instance.
1.4.347+ rejects them (VUID-VkDeviceCreateInfo-enabledLayerCount-12384),
so SetValidationLayersEnabled(true) failed device creation. Instance
layers already validate device calls. CreateDevice also returns failure
when vkCreateDevice fails instead of using a null device.
unavailable" is only logged when validation was actually requested (it
was logged on every launch). Unavailable layers no longer clear the
caller's static request.
VK_NULL_HANDLE. ShutdownGraphicsAPI clears it with the instance, and a
failed InitializeGraphicsAPI releases what it created.
upper limit. It was treated as a maximum of 0, so every swapchain
request failed on such drivers. Document 0 as "no limit" for
SwapchainConfigurations::max_swapchain_frame_count.
supports the exact VkFormat. RGBA8 was listed twice when the surface
reported both R8G8B8A8_UNORM and _SRGB, and was offered as
VK_FORMAT_R8G8B8A8_SRGB even if only UNORM existed. The color space now
means the same as in GLES. sRGB is an _SRGB VkFormat, which sRGB-encodes
writes, so it applies only to RGBA8/BGRA8. Linear covers RGBA8/BGRA8
UNORM (previously never offered) and the formats without an sRGB variant
(RGB565, RGBA_16F, ABGR2_10_10_10, ...). Those were labelled sRGB even
though writes are not encoded.