From b9fe5aad37d20dd767b44528da251e0ed322d3de Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Mon, 24 Feb 2025 14:51:06 +0100 Subject: [PATCH] anv: enable VK_KHR_shader_bfloat16 Signed-off-by: Rohan Garg Reviewed-by: Caio Oliveira Reviewed-by: Ian Romanick Part-of: --- docs/features.txt | 1 + docs/relnotes/new_features.txt | 1 + src/intel/vulkan/anv_physical_device.c | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/docs/features.txt b/docs/features.txt index 087a3012520..eeb754596d4 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -559,6 +559,7 @@ Khronos extensions that are not part of any Vulkan version: VK_KHR_ray_tracing_maintenance1 DONE (anv/gfx12.5+, radv/gfx10.3+, tu/a740+, vn) VK_KHR_ray_tracing_pipeline DONE (anv/gfx12.5+, lvp, radv/gfx10.3+, vn) VK_KHR_ray_tracing_position_fetch DONE (anv, radv/gfx10.3+, vn) + VK_KHR_shader_bfloat16 DONE (anv/gfx12.5+) VK_KHR_shader_clock DONE (anv, hasvk, lvp, nvk, radv, tu, vn) VK_KHR_shader_maximal_reconvergence DONE (anv, lvp, nvk, panvk/v10+, radv, vn) VK_KHR_shader_relaxed_extended_instruction DONE (anv, hasvk, nvk, panvk, radv, tu, v3dv, vn) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index f9bc5431464..84939254e5d 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -19,3 +19,4 @@ VK_KHR_shader_terminate_invocation on panvk VK_EXT_shader_demote_to_helper_invocation on panvk VK_EXT_shader_replicated_composites on panvk VK_EXT_depth_bias_control on panvk +VK_KHR_shader_bfloat16 on anv/gfx125+ diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 4759328e07b..c8472d3a2c7 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -123,6 +123,21 @@ get_device_descriptor_limits(const struct anv_physical_device *device, limits->max_resources = MIN2(limits->max_resources, limits->max_samplers); } + +static const bool +anv_device_has_bfloat16_cooperative_matrix(const struct anv_physical_device *pdevice) +{ + const struct intel_device_info *devinfo = &pdevice->info; + + for (int i = 0; i < ARRAY_SIZE(devinfo->cooperative_matrix_configurations); i++) { + const struct intel_cooperative_matrix_configuration *cfg = + &devinfo->cooperative_matrix_configurations[i]; + if (cfg->a == INTEL_CMAT_BFLOAT16 || cfg->b == INTEL_CMAT_BFLOAT16) + return true; + } + return false; +} + static void get_device_extensions(const struct anv_physical_device *device, struct vk_device_extension_table *ext) @@ -378,6 +393,7 @@ get_device_extensions(const struct anv_physical_device *device, .MESA_image_alignment_control = true, .NV_compute_shader_derivatives = true, .VALVE_mutable_descriptor_type = true, + .KHR_shader_bfloat16 = device->info.has_bfloat16, }; } @@ -935,6 +951,12 @@ get_features(const struct anv_physical_device *pdevice, /* VK_KHR_maintenance8 */ .maintenance8 = true, + + /* VK_KHR_shader_bfloat16 */ + .shaderBFloat16Type = pdevice->info.has_bfloat16, + .shaderBFloat16CooperativeMatrix = + anv_device_has_bfloat16_cooperative_matrix(pdevice), + .shaderBFloat16DotProduct = pdevice->info.has_bfloat16, }; /* The new DOOM and Wolfenstein games require depthBounds without