From c87d5c67d9b1bb4c0eaf9fe1877a32dcadd7deb2 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 21 Jun 2022 18:48:03 -0700 Subject: [PATCH] anv: implement VK_EXT_pipeline_robustness v2: - Use vk_pipeline_robustness_state Reviewed-by: Ivan Briano Part-of: --- docs/features.txt | 2 +- docs/relnotes/new_features.txt | 1 + src/intel/vulkan/anv_device.c | 18 ++++++++++++ src/intel/vulkan/anv_image.c | 7 ++++- src/intel/vulkan/anv_pipeline.c | 49 +++++++++++++++++++++------------ 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index cc227d7a62a..5779e41a7a0 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -588,7 +588,7 @@ Khronos extensions that are not part of any Vulkan version: VK_EXT_pci_bus_info DONE (anv, hasvk, nvk, radv, vn) VK_EXT_physical_device_drm DONE (anv, hasvk, nvk, radv, tu, v3dv, vn) VK_EXT_pipeline_library_group_handles DONE (anv, radv) - VK_EXT_pipeline_robustness DONE (radv, v3dv) + VK_EXT_pipeline_robustness DONE (anv, radv, v3dv) VK_EXT_post_depth_coverage DONE (anv/gfx10+, lvp, radv/gfx10+) VK_EXT_primitive_topology_list_restart DONE (anv, hasvk, lvp, radv, tu, v3dv, vn) VK_EXT_primitives_generated_query DONE (anv, hasvk, lvp, radv, tu, vn) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 1528dd5208e..5e4661d0e5c 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -5,3 +5,4 @@ New drivers New features ------------ +VK_EXT_pipeline_robustness on ANV diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index ed6d3abcdf5..71b12af42cd 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -346,6 +346,7 @@ get_device_extensions(const struct anv_physical_device *device, .EXT_pipeline_creation_cache_control = true, .EXT_pipeline_creation_feedback = true, .EXT_pipeline_library_group_handles = rt_enabled, + .EXT_pipeline_robustness = true, .EXT_post_depth_coverage = true, .EXT_primitives_generated_query = true, .EXT_primitive_topology_list_restart = true, @@ -829,6 +830,9 @@ get_features(const struct anv_physical_device *pdevice, .floatRepresentation = true, .leastRepresentableValueForceUnormRepresentation = false, .depthBiasExact = true, + + /* VK_EXT_pipeline_robustness */ + .pipelineRobustness = true, }; /* The new DOOM and Wolfenstein games require depthBounds without @@ -2411,6 +2415,20 @@ void anv_GetPhysicalDeviceProperties2( break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_PROPERTIES_EXT: { + VkPhysicalDevicePipelineRobustnessPropertiesEXT *properties = + (VkPhysicalDevicePipelineRobustnessPropertiesEXT *)ext; + properties->defaultRobustnessStorageBuffers = + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT; + properties->defaultRobustnessUniformBuffers = + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT; + properties->defaultRobustnessVertexInputs = + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2_EXT; + properties->defaultRobustnessImages = + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_2_EXT; + break; + } + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch" case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: { diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index a4f9a31063d..dff815784ba 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -2567,9 +2567,14 @@ anv_image_fill_surface_state(struct anv_device *device, view_usage), .x_offset_sa = tile_x_sa, .y_offset_sa = tile_y_sa, + /* Assume robustness with EXT_pipeline_robustness + * because this can be turned on/off per pipeline and + * we have no visibility on this here. + */ .robust_image_access = device->vk.enabled_features.robustImageAccess || - device->vk.enabled_features.robustImageAccess2); + device->vk.enabled_features.robustImageAccess2 || + device->vk.enabled_extensions.EXT_pipeline_robustness); /* With the exception of gfx8, the bottom 12 bits of the MCS base address * are used to store other information. This should be ok, however, because diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 569656230d5..3ff6655edda 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -382,6 +382,10 @@ struct anv_pipeline_stage { struct vk_pipeline_robustness_state rstate; + /* VkComputePipelineCreateInfo, VkGraphicsPipelineCreateInfo or + * VkRayTracingPipelineCreateInfoKHR pNext field + */ + const void *pipeline_pNext; const VkPipelineShaderStageCreateInfo *info; unsigned char shader_sha1[20]; @@ -687,9 +691,22 @@ populate_bs_prog_key(struct anv_pipeline_stage *stage, static void anv_stage_write_shader_hash(struct anv_pipeline_stage *stage, - const VkPipelineShaderStageCreateInfo *sinfo) + const struct anv_device *device) { - vk_pipeline_hash_shader_stage(sinfo, NULL, stage->shader_sha1); + vk_pipeline_robustness_state_fill(&device->vk, + &stage->rstate, + stage->pipeline_pNext, + stage->info->pNext); + + vk_pipeline_hash_shader_stage(stage->info, &stage->rstate, stage->shader_sha1); + + stage->robust_flags = + ((stage->rstate.storage_buffers != + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT) ? + BRW_ROBUSTNESS_SSBO : 0) | + ((stage->rstate.uniform_buffers != + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT) ? + BRW_ROBUSTNESS_UBO : 0); /* Use lowest dword of source shader sha1 for shader hash. */ stage->source_hash = ((uint32_t*)stage->shader_sha1)[0]; @@ -1669,13 +1686,6 @@ anv_graphics_pipeline_skip_shader_compile(struct anv_graphics_base_pipeline *pip return stages[stage].info == NULL; } -static enum brw_robustness_flags -anv_device_get_robust_flags(const struct anv_device *device) -{ - return device->robust_buffer_access ? - (BRW_ROBUSTNESS_UBO | BRW_ROBUSTNESS_SSBO) : 0; -} - static void anv_graphics_pipeline_init_keys(struct anv_graphics_base_pipeline *pipeline, const struct vk_graphics_pipeline_state *state, @@ -1984,9 +1994,12 @@ anv_pipeline_nir_preprocess(struct anv_pipeline *pipeline, struct brw_nir_compiler_opts opts = { .softfp64 = device->fp64_nir, - .robust_image_access = - device->vk.enabled_features.robustImageAccess || - device->vk.enabled_features.robustImageAccess2, + /* Assume robustness with EXT_pipeline_robustness because this can be + * turned on/off per pipeline and we have no visibility on this here. + */ + .robust_image_access = device->vk.enabled_features.robustImageAccess || + device->vk.enabled_features.robustImageAccess2 || + device->vk.enabled_extensions.EXT_pipeline_robustness, .input_vertices = stage->nir->info.stage == MESA_SHADER_TESS_CTRL ? stage->key.tcs.input_vertices : 0, }; @@ -2081,12 +2094,11 @@ anv_graphics_pipeline_compile(struct anv_graphics_base_pipeline *pipeline, continue; stages[stage].stage = stage; + stages[stage].pipeline_pNext = info->pNext; stages[stage].info = &info->pStages[i]; stages[stage].feedback_idx = shader_count++; - anv_stage_write_shader_hash(&stages[stage], stages[stage].info); - - stages[stage].robust_flags = anv_device_get_robust_flags(device); + anv_stage_write_shader_hash(&stages[stage], device); } /* Prepare shader keys for all shaders in pipeline->base.active_stages @@ -2504,6 +2516,7 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline, struct anv_pipeline_stage stage = { .stage = MESA_SHADER_COMPUTE, .info = &info->stage, + .pipeline_pNext = info->pNext, .cache_key = { .stage = MESA_SHADER_COMPUTE, }, @@ -2511,7 +2524,7 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline, .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, }, }; - anv_stage_write_shader_hash(&stage, &info->stage); + anv_stage_write_shader_hash(&stage, device); struct anv_shader_bin *bin = NULL; @@ -3416,6 +3429,7 @@ anv_pipeline_init_ray_tracing_stages(struct anv_ray_tracing_pipeline *pipeline, const VkRayTracingPipelineCreateInfoKHR *info, void *pipeline_ctx) { + struct anv_device *device = pipeline->base.device; /* Create enough stage entries for all shader modules plus potential * combinaisons in the groups. */ @@ -3434,6 +3448,7 @@ anv_pipeline_init_ray_tracing_stages(struct anv_ray_tracing_pipeline *pipeline, stages[i] = (struct anv_pipeline_stage) { .stage = vk_to_mesa_shader_stage(sinfo->stage), + .pipeline_pNext = info->pNext, .info = sinfo, .cache_key = { .stage = vk_to_mesa_shader_stage(sinfo->stage), @@ -3445,7 +3460,7 @@ anv_pipeline_init_ray_tracing_stages(struct anv_ray_tracing_pipeline *pipeline, pipeline->base.active_stages |= sinfo->stage; - anv_stage_write_shader_hash(&stages[i], sinfo); + anv_stage_write_shader_hash(&stages[i], device); populate_bs_prog_key(&stages[i], pipeline->base.device,