From 67739b02de08e97128673f05bf1a525047873d3e Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 30 Oct 2023 11:06:24 -0700 Subject: [PATCH] anv: Add anv_physical_device::has_cooperative_matrix This flag tracks whether or not cooperative matrices are fully enabled on the physica device (i.e., both the configs exist and the environment varible is set). This is mainly to support a later commit "anv: Set PIPELINE_SELECT systolic mode enable flag." This could be squashed into "anv: Implement VK_KHR_cooperative_matrix." I left it separate because we might go back to the previous method. v3: Don't hide the extension behind an environment variable (ANV_COOPERATIVE_MATRIX) now the we have a better solution for setting PIPELINE_SELECT. Reviewed-by: Caio Oliveira Part-of: --- src/intel/vulkan/anv_device.c | 12 ++++++------ src/intel/vulkan/anv_pipeline.c | 2 +- src/intel/vulkan/anv_private.h | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 7392474428c..31fc69ad9ec 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -218,9 +218,6 @@ get_device_extensions(const struct anv_physical_device *device, const bool rt_enabled = ANV_SUPPORT_RT && device->info.has_ray_tracing; - const bool cooperative_matrix_enabled = - anv_has_cooperative_matrix(&device->info); - *ext = (struct vk_device_extension_table) { .KHR_8bit_storage = true, .KHR_16bit_storage = !device->instance->no_16bit, @@ -229,7 +226,7 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_buffer_device_address = true, .KHR_calibrated_timestamps = device->has_reg_timestamp, .KHR_copy_commands2 = true, - .KHR_cooperative_matrix = cooperative_matrix_enabled, + .KHR_cooperative_matrix = anv_has_cooperative_matrix(device), .KHR_create_renderpass2 = true, .KHR_dedicated_allocation = true, .KHR_deferred_host_operations = true, @@ -868,7 +865,7 @@ get_features(const struct anv_physical_device *pdevice, .nestedCommandBufferSimultaneousUse = false, /* VK_KHR_cooperative_matrix */ - .cooperativeMatrix = anv_has_cooperative_matrix(&pdevice->info), + .cooperativeMatrix = anv_has_cooperative_matrix(pdevice), }; /* The new DOOM and Wolfenstein games require depthBounds without @@ -2250,6 +2247,9 @@ anv_physical_device_try_create(struct vk_instance *vk_instance, debug_get_bool_option("ANV_ENABLE_GENERATED_INDIRECT_DRAWS", true); + device->has_cooperative_matrix = + device->info.cooperative_matrix_configurations[0].scope != SCOPE_NONE; + unsigned st_idx = 0; device->sync_syncobj_type = vk_drm_syncobj_get_type(fd); @@ -5173,7 +5173,7 @@ VkResult anv_GetPhysicalDeviceCooperativeMatrixPropertiesKHR( ANV_FROM_HANDLE(anv_physical_device, pdevice, physicalDevice); const struct intel_device_info *devinfo = &pdevice->info; - assert(anv_has_cooperative_matrix(devinfo)); + assert(anv_has_cooperative_matrix(pdevice)); VK_OUTARRAY_MAKE_TYPED(VkCooperativeMatrixPropertiesKHR, out, pProperties, pPropertyCount); diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 2e98f17e8ba..2ab7fefc322 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -144,7 +144,7 @@ anv_shader_stage_to_nir(struct anv_device *device, const bool rt_enabled = ANV_SUPPORT_RT && pdevice->info.has_ray_tracing; const struct spirv_to_nir_options spirv_options = { .caps = { - .cooperative_matrix = anv_has_cooperative_matrix(&pdevice->info), + .cooperative_matrix = anv_has_cooperative_matrix(pdevice), .demote_to_helper_invocation = true, .derivative_group = true, .descriptor_array_dynamic_indexing = true, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index b4407f57cca..eb6232da06d 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1036,6 +1036,9 @@ struct anv_physical_device { bool uses_relocs; + /** Can the platform support cooperative matrices and is it enabled? */ + bool has_cooperative_matrix; + struct { uint32_t family_count; struct anv_queue_family families[ANV_MAX_QUEUE_FAMILIES]; @@ -5805,9 +5808,9 @@ static inline void anv_perfetto_end_submit(struct anv_queue *queue, #endif static bool -anv_has_cooperative_matrix(const struct intel_device_info *info) +anv_has_cooperative_matrix(const struct anv_physical_device *device) { - return info->cooperative_matrix_configurations[0].scope != SCOPE_NONE; + return device->has_cooperative_matrix; } #define ANV_FROM_HANDLE(__anv_type, __name, __handle) \