From 7de9d1ff9e42ec9e3a08c3e9f328cf0374a04354 Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Tue, 24 Nov 2026 01:50:22 -0500 Subject: [PATCH 1/3] borealis: offer R32_SFLOAT image atomics with float image atomics G16G advertises shaderImageFloat32Atomics, shaderImageFloat32AtomicAdd and shaderImageFloat32AtomicMinMax through the shared HAL200 block of hk_create_drm_physical_device(), but hk_get_image_plane_format_features() offered VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT on R32_SFLOAT only on G17P and M5. Vulkan requires that bit on R32_SFLOAT when shaderImageFloat32Atomics is supported, and without it an application cannot use the advertised feature on an optimal-tiled image. Take the bit from the advertised feature instead of a chip list. The storage texel buffer bit gets the same rule; it already covered every chip that advertises the feature, so it does not change. The image atomics go through the same code on every native AGX3 part: nir_lower_image_atomics_to_global(), then agx_nir_lower_atomics(), which keeps a native 32-bit global fadd on the AGX3B encoding and turns fmin/fmax into compare-and-swap loops. G16G and G17P share that encoding. G16G already exposes R32_SFLOAT texel buffer atomics and R32_UINT/SINT image atomics through the same lowering. Signed-off-by: Diljit Singh --- src/asahi/vulkan/hk_buffer_view.c | 3 +-- src/asahi/vulkan/hk_image.c | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/asahi/vulkan/hk_buffer_view.c b/src/asahi/vulkan/hk_buffer_view.c index b3f955031d48..50490a7cf02d 100644 --- a/src/asahi/vulkan/hk_buffer_view.c +++ b/src/asahi/vulkan/hk_buffer_view.c @@ -79,8 +79,7 @@ hk_get_buffer_format_features(struct hk_physical_device *pdev, if (p_format == PIPE_FORMAT_R32_UINT || p_format == PIPE_FORMAT_R32_SINT || (p_format == PIPE_FORMAT_R32_FLOAT && - (agx_chip_native_hal200(pdev->dev.chip) || - agx_chip_g17_m5(pdev->dev.chip)))) + pdev->vk.supported_features.shaderImageFloat32Atomics)) features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; } diff --git a/src/asahi/vulkan/hk_image.c b/src/asahi/vulkan/hk_image.c index 54d2fd0f8132..a9fd68134b0d 100644 --- a/src/asahi/vulkan/hk_image.c +++ b/src/asahi/vulkan/hk_image.c @@ -230,10 +230,11 @@ hk_get_image_plane_format_features(struct hk_physical_device *pdev, VK_FORMAT_FEATURE_2_BLIT_DST_BIT; } - /* Our image atomic lowering doesn't bother to handle linear */ + /* Our image atomic lowering doesn't bother to handle linear. R32_SFLOAT + * atomics are required wherever shaderImageFloat32Atomics is advertised. */ if ((p_format == PIPE_FORMAT_R32_UINT || p_format == PIPE_FORMAT_R32_SINT || (p_format == PIPE_FORMAT_R32_FLOAT && - agx_chip_g17p_or_m5(pdev->dev.chip))) && + pdev->vk.supported_features.shaderImageFloat32Atomics)) && tiling == VK_IMAGE_TILING_OPTIMAL) { features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT; From 51582de823f2ac12e637fe8d89058b20f4d3597f Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Tue, 24 Nov 2026 01:50:42 -0500 Subject: [PATCH 2/3] borealis: prune unused fragment colours from depth-only G16G pipelines hk_populate_fs_key() sets discard_color_outputs only on G17P and M5. With the key set, hk_prune_unused_fragment_colors() removes a fragment shader's colour stores before linking, when the complete pipeline state proves there are no colour attachments and alpha-to-coverage is statically off. Output reads, depth, sample masks, discard and memory effects are kept. The pass is plain NIR and uses no encoding or command-stream feature, so nothing in it is specific to G17P or M5. Take it on G16G too. Its depth-only and shadow passes then stop computing colours that no attachment stores. The gate now names the HAL200 native parts and M5 explicitly. It still leaves out G15 and the AGX2 parts, which have not run it. Signed-off-by: Diljit Singh --- src/asahi/vulkan/hk_shader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asahi/vulkan/hk_shader.c b/src/asahi/vulkan/hk_shader.c index 7c4503ede47e..ea84b0342178 100644 --- a/src/asahi/vulkan/hk_shader.c +++ b/src/asahi/vulkan/hk_shader.c @@ -712,7 +712,7 @@ hk_populate_fs_key(struct hk_fs_key *key, /* A fragment library without output-interface state may acquire color * attachments later. Alpha-to-coverage also consumes color even without * an attachment, so require it to be statically disabled. */ - if (agx_chip_g17p_or_m5(chip) && + if ((agx_chip_native_hal200(chip) || agx_chip_g17_m5(chip)) && state->rp && (state->cal || BITSET_TEST(state->dynamic, MESA_VK_DYNAMIC_COLOR_ATTACHMENT_MAP)) && From f18253a63b8e46a121eda5e6b76cd22ecf6d4b4f Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Tue, 24 Nov 2026 01:50:42 -0500 Subject: [PATCH 3/3] borealis: preserve vertex position arithmetic across pass variants on G16G agx_nir_preserve_position_order() keeps NIR from reassociating or algebraically rewriting what vertex Position depends on. Without it, a depth-only link and a colour link of the same vertex shader can round the same position expression differently when an intermediate value also feeds a live varying. A depth pre-pass with LESS_OR_EQUAL then rejects samples of the colour pass. The pass runs only on G17P and M5. The difference comes from NIR optimisation of the two links, not from the hardware, so G16G links can differ in the same way. Run the pass on G16G vertex shaders too. Multiply-add contraction and unrelated outputs are still optimised. Signed-off-by: Diljit Singh --- src/asahi/vulkan/hk_shader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/asahi/vulkan/hk_shader.c b/src/asahi/vulkan/hk_shader.c index ea84b0342178..cfa3548690c3 100644 --- a/src/asahi/vulkan/hk_shader.c +++ b/src/asahi/vulkan/hk_shader.c @@ -5493,7 +5493,8 @@ hk_compile_nir(struct hk_device *dev, const VkAllocationCallbacks *pAllocator, nir_metadata_control_flow, NULL); } if (sw_stage == MESA_SHADER_VERTEX && - agx_chip_g17p_or_m5(dev->dev.chip)) + (agx_chip_native_hal200(dev->dev.chip) || + agx_chip_g17_m5(dev->dev.chip))) NIR_PASS(_, nir, agx_nir_preserve_position_order); hk_lower_hw_vs(dev, nir, shader, kill_psiz, agx_chip_native_or_m5(dev->dev.chip),