From dff1d91c64e55541174141b528d90a7aeab9b0da Mon Sep 17 00:00:00 2001 From: John Anthony Date: Mon, 7 Jul 2025 22:05:23 +0200 Subject: [PATCH] panvk: Enable VK_ARM_shader_core_builtins While the shaderCoreBuiltins feature is only supported on v9+, the extension itself provides some useful physical device properties and is supported on all GPUs. Reviewed-by: Mary Guillemard Part-of: --- docs/features.txt | 1 + docs/relnotes/new_features.txt | 1 + src/panfrost/vulkan/panvk_vX_physical_device.c | 10 ++++++++++ src/panfrost/vulkan/panvk_vX_shader.c | 8 +++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/features.txt b/docs/features.txt index 71a50614fa7..2d39b81b4fb 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -698,6 +698,7 @@ Khronos extensions that are not part of any Vulkan version: VK_AMD_shader_trinary_minmax DONE (radv) VK_AMD_texture_gather_bias_lod DONE (anv, radv) VK_ARM_rasterization_order_attachment_access DONE (lvp, tu, vn) + VK_ARM_shader_core_builtins DONE (panvk) VK_ARM_shader_core_properties DONE (panvk/v10+) VK_EXT_mutable_descriptor_type DONE (anv, hk, lvp, nvk, panvk/v9+, radv, tu, vn) VK_EXT_swapchain_colorspace DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index a53c3614ea8..7b0ad576a1b 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -2,3 +2,4 @@ EGL_EXT_create_context_robustness support on Panfrost V10+ GL_ARB_robust_buffer_access_behavior, GL_KHR_robust_buffer_access_behavior and GL_KHR_robustness support on Panfrost VK_EXT_mutable_descriptor_type on panvk/v9+ GL_KHR_robustness on v3d +VK_ARM_shader_core_builtins on panvk diff --git a/src/panfrost/vulkan/panvk_vX_physical_device.c b/src/panfrost/vulkan/panvk_vX_physical_device.c index 2a46074486c..26dd52073c2 100644 --- a/src/panfrost/vulkan/panvk_vX_physical_device.c +++ b/src/panfrost/vulkan/panvk_vX_physical_device.c @@ -179,6 +179,7 @@ panvk_per_arch(get_physical_device_extensions)( .GOOGLE_hlsl_functionality1 = true, .GOOGLE_user_type = true, + .ARM_shader_core_builtins = true, .ARM_shader_core_properties = has_vk1_1, }; } @@ -503,6 +504,9 @@ panvk_per_arch(get_physical_device_features)( /* VK_KHR_present_wait2 */ .presentWait2 = true, #endif + + /* VK_ARM_shader_core_builtins */ + .shaderCoreBuiltins = PAN_ARCH >= 9, }; } @@ -962,6 +966,12 @@ panvk_per_arch(get_physical_device_properties)( /* VK_EXT_host_image_copy */ .identicalMemoryTypeRequirements = true, + + /* VK_ARM_shader_core_builtins */ + .shaderCoreMask = device->kmod.props.shader_present, + .shaderCoreCount = util_bitcount(device->kmod.props.shader_present), + .shaderWarpsPerCore = device->kmod.props.max_threads_per_core / + (pan_subgroup_size(PAN_ARCH) * 2), }; snprintf(properties->deviceName, sizeof(properties->deviceName), "%s", diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index 08f85ab301e..de39c4e9864 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -385,10 +385,12 @@ panvk_get_spirv_options(UNUSED struct vk_physical_device *vk_pdev, } static void -panvk_preprocess_nir(UNUSED struct vk_physical_device *vk_pdev, +panvk_preprocess_nir(struct vk_physical_device *vk_pdev, nir_shader *nir, UNUSED const struct vk_pipeline_robustness_state *rs) { + struct panvk_physical_device *pdev = to_panvk_physical_device(vk_pdev); + /* Ensure to regroup output variables at the same location */ if (nir->info.stage == MESA_SHADER_FRAGMENT) NIR_PASS(_, nir, nir_opt_vectorize_io_vars, nir_var_shader_out); @@ -456,6 +458,10 @@ panvk_preprocess_nir(UNUSED struct vk_physical_device *vk_pdev, NIR_PASS(_, nir, nir_split_var_copies); NIR_PASS(_, nir, nir_lower_var_copies); + + uint64_t core_max_id = util_last_bit(pdev->kmod.props.shader_present) - 1; + NIR_PASS(_, nir, nir_inline_sysval, nir_intrinsic_load_core_max_id_arm, + core_max_id); } static void