diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 3a586f43940..bd441dc1072 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -647,9 +647,8 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr VkResult result; struct radv_device *device; + enum radv_buffer_robustness buffer_robustness = RADV_BUFFER_ROBUSTNESS_DISABLED; bool keep_shader_info = false; - bool robust_buffer_access = false; - bool robust_buffer_access2 = false; bool overallocation_disallowed = false; bool custom_border_colors = false; bool attachment_vrs_enabled = false; @@ -666,7 +665,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr /* Check enabled features */ if (pCreateInfo->pEnabledFeatures) { if (pCreateInfo->pEnabledFeatures->robustBufferAccess) - robust_buffer_access = true; + buffer_robustness = MAX2(buffer_robustness, RADV_BUFFER_ROBUSTNESS_1); } vk_foreach_struct_const (ext, pCreateInfo->pNext) { @@ -674,7 +673,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2: { const VkPhysicalDeviceFeatures2 *features = (const void *)ext; if (features->features.robustBufferAccess) - robust_buffer_access = true; + buffer_robustness = MAX2(buffer_robustness, RADV_BUFFER_ROBUSTNESS_1); break; } case VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD: { @@ -696,7 +695,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT: { const VkPhysicalDeviceRobustness2FeaturesEXT *features = (const void *)ext; if (features->robustBufferAccess2) - robust_buffer_access2 = true; + buffer_robustness = MAX2(buffer_robustness, RADV_BUFFER_ROBUSTNESS_2); break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT: { @@ -812,8 +811,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr device->vk.enabled_extensions.KHR_acceleration_structure || device->vk.enabled_extensions.VALVE_descriptor_set_host_mapping; - device->robust_buffer_access = robust_buffer_access || robust_buffer_access2; - device->robust_buffer_access2 = robust_buffer_access2; + device->buffer_robustness = buffer_robustness; device->attachment_vrs_enabled = attachment_vrs_enabled; diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index f5a1913a96d..f8cb928f228 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -203,9 +203,9 @@ radv_get_hash_flags(const struct radv_device *device, bool stats) hash_flags |= RADV_HASH_SHADER_LLVM; if (stats) hash_flags |= RADV_HASH_SHADER_KEEP_STATISTICS; - if (device->robust_buffer_access) /* forces per-attribute vertex descriptors */ + if (device->buffer_robustness >= RADV_BUFFER_ROBUSTNESS_1) /* forces per-attribute vertex descriptors */ hash_flags |= RADV_HASH_SHADER_ROBUST_BUFFER_ACCESS; - if (device->robust_buffer_access2) /* affects load/store vectorizer */ + if (device->buffer_robustness >= RADV_BUFFER_ROBUSTNESS_2) /* affects load/store vectorizer */ hash_flags |= RADV_HASH_SHADER_ROBUST_BUFFER_ACCESS2; if (device->instance->debug_flags & RADV_DEBUG_SPLIT_FMA) hash_flags |= RADV_HASH_SHADER_SPLIT_FMA; @@ -509,7 +509,7 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_pipeline_layo .has_shared2_amd = gfx_level >= GFX7, }; - if (device->robust_buffer_access2) { + if (device->buffer_robustness >= RADV_BUFFER_ROBUSTNESS_2) { vectorize_opts.robust_modes = nir_var_mem_ubo | nir_var_mem_ssbo; } diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 2ff9c3d9499..90b060b0559 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -942,6 +942,12 @@ struct radv_layer_dispatch_tables { struct vk_device_dispatch_table rmv; }; +enum radv_buffer_robustness { + RADV_BUFFER_ROBUSTNESS_DISABLED, + RADV_BUFFER_ROBUSTNESS_1, /* robustBufferAccess */ + RADV_BUFFER_ROBUSTNESS_2, /* robustBufferAccess2 */ +}; + struct radv_device { struct vk_device vk; @@ -1013,8 +1019,7 @@ struct radv_device { uint64_t dmesg_timestamp; /* Whether the app has enabled the robustBufferAccess/robustBufferAccess2 features. */ - bool robust_buffer_access; - bool robust_buffer_access2; + enum radv_buffer_robustness buffer_robustness; /* Whether to inline the compute dispatch size in user sgprs. */ bool load_grid_size_from_user_sgpr; diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 3ad4579e8c3..00ee22b3db8 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -2041,7 +2041,7 @@ radv_fill_nir_compiler_options(struct radv_nir_compiler_options *options, struct if (key) options->key = *key; - options->robust_buffer_access = device->robust_buffer_access; + options->robust_buffer_access = device->buffer_robustness >= RADV_BUFFER_ROBUSTNESS_1; options->wgp_mode = should_use_wgp; options->info = &device->physical_device->rad_info; options->dump_shader = can_dump_shader; diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 1ef0ffd71d2..8d4a2027f17 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -414,7 +414,8 @@ gather_shader_info_vs(struct radv_device *device, const nir_shader *nir, const s } /* Use per-attribute vertex descriptors to prevent faults and for correct bounds checking. */ - info->vs.use_per_attribute_vb_descs = device->robust_buffer_access || info->vs.dynamic_inputs; + info->vs.use_per_attribute_vb_descs = + device->buffer_robustness >= RADV_BUFFER_ROBUSTNESS_1 || info->vs.dynamic_inputs; /* We have to ensure consistent input register assignments between the main shader and the * prolog.