radv: Refactor buffer robustness to an enum

Will be taken advantage of with pipeline robustness.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
Reviewed-by: Friedrich Vock <friedrich.vock@gmx.de>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23912>
This commit is contained in:
Joshua Ashton
2023-06-28 17:34:58 +01:00
parent 59aa49494c
commit f52ebc8b40
5 changed files with 18 additions and 14 deletions

View File

@@ -647,9 +647,8 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr
VkResult result; VkResult result;
struct radv_device *device; struct radv_device *device;
enum radv_buffer_robustness buffer_robustness = RADV_BUFFER_ROBUSTNESS_DISABLED;
bool keep_shader_info = false; bool keep_shader_info = false;
bool robust_buffer_access = false;
bool robust_buffer_access2 = false;
bool overallocation_disallowed = false; bool overallocation_disallowed = false;
bool custom_border_colors = false; bool custom_border_colors = false;
bool attachment_vrs_enabled = false; bool attachment_vrs_enabled = false;
@@ -666,7 +665,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr
/* Check enabled features */ /* Check enabled features */
if (pCreateInfo->pEnabledFeatures) { if (pCreateInfo->pEnabledFeatures) {
if (pCreateInfo->pEnabledFeatures->robustBufferAccess) if (pCreateInfo->pEnabledFeatures->robustBufferAccess)
robust_buffer_access = true; buffer_robustness = MAX2(buffer_robustness, RADV_BUFFER_ROBUSTNESS_1);
} }
vk_foreach_struct_const (ext, pCreateInfo->pNext) { 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: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2: {
const VkPhysicalDeviceFeatures2 *features = (const void *)ext; const VkPhysicalDeviceFeatures2 *features = (const void *)ext;
if (features->features.robustBufferAccess) if (features->features.robustBufferAccess)
robust_buffer_access = true; buffer_robustness = MAX2(buffer_robustness, RADV_BUFFER_ROBUSTNESS_1);
break; break;
} }
case VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD: { 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: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT: {
const VkPhysicalDeviceRobustness2FeaturesEXT *features = (const void *)ext; const VkPhysicalDeviceRobustness2FeaturesEXT *features = (const void *)ext;
if (features->robustBufferAccess2) if (features->robustBufferAccess2)
robust_buffer_access2 = true; buffer_robustness = MAX2(buffer_robustness, RADV_BUFFER_ROBUSTNESS_2);
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT: { 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.KHR_acceleration_structure ||
device->vk.enabled_extensions.VALVE_descriptor_set_host_mapping; device->vk.enabled_extensions.VALVE_descriptor_set_host_mapping;
device->robust_buffer_access = robust_buffer_access || robust_buffer_access2; device->buffer_robustness = buffer_robustness;
device->robust_buffer_access2 = robust_buffer_access2;
device->attachment_vrs_enabled = attachment_vrs_enabled; device->attachment_vrs_enabled = attachment_vrs_enabled;

View File

@@ -203,9 +203,9 @@ radv_get_hash_flags(const struct radv_device *device, bool stats)
hash_flags |= RADV_HASH_SHADER_LLVM; hash_flags |= RADV_HASH_SHADER_LLVM;
if (stats) if (stats)
hash_flags |= RADV_HASH_SHADER_KEEP_STATISTICS; 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; 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; hash_flags |= RADV_HASH_SHADER_ROBUST_BUFFER_ACCESS2;
if (device->instance->debug_flags & RADV_DEBUG_SPLIT_FMA) if (device->instance->debug_flags & RADV_DEBUG_SPLIT_FMA)
hash_flags |= RADV_HASH_SHADER_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, .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; vectorize_opts.robust_modes = nir_var_mem_ubo | nir_var_mem_ssbo;
} }

View File

@@ -942,6 +942,12 @@ struct radv_layer_dispatch_tables {
struct vk_device_dispatch_table rmv; 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 radv_device {
struct vk_device vk; struct vk_device vk;
@@ -1013,8 +1019,7 @@ struct radv_device {
uint64_t dmesg_timestamp; uint64_t dmesg_timestamp;
/* Whether the app has enabled the robustBufferAccess/robustBufferAccess2 features. */ /* Whether the app has enabled the robustBufferAccess/robustBufferAccess2 features. */
bool robust_buffer_access; enum radv_buffer_robustness buffer_robustness;
bool robust_buffer_access2;
/* Whether to inline the compute dispatch size in user sgprs. */ /* Whether to inline the compute dispatch size in user sgprs. */
bool load_grid_size_from_user_sgpr; bool load_grid_size_from_user_sgpr;

View File

@@ -2041,7 +2041,7 @@ radv_fill_nir_compiler_options(struct radv_nir_compiler_options *options, struct
if (key) if (key)
options->key = *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->wgp_mode = should_use_wgp;
options->info = &device->physical_device->rad_info; options->info = &device->physical_device->rad_info;
options->dump_shader = can_dump_shader; options->dump_shader = can_dump_shader;

View File

@@ -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. */ /* 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 /* We have to ensure consistent input register assignments between the main shader and the
* prolog. * prolog.