diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 2cc1e2c2cfa..a928bf9f915 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -4749,12 +4749,18 @@ void visit_load_input(isel_context *ctx, nir_intrinsic_instr *instr) unsigned fetch_offset = attrib_offset + channel_start * vtx_info->chan_byte_size; bool expanded = false; - /* use MUBUF when possible to avoid possible alignment issues */ + /* Use MUBUF when possible to avoid possible alignment issues. + * We don't use MUBUF for multi-component loads because + * robustBufferAccess2 requires that bounds checking is per-attribute, + * but MUBUF is per-dword. Other generations get around this by doing + * bounds checking with the index, instead of the offset like GFX8. */ /* TODO: we could use SDWA to unpack 8/16-bit attributes without extra instructions */ bool use_mubuf = (nfmt == V_008F0C_BUF_NUM_FORMAT_FLOAT || nfmt == V_008F0C_BUF_NUM_FORMAT_UINT || nfmt == V_008F0C_BUF_NUM_FORMAT_SINT) && - vtx_info->chan_byte_size == 4; + vtx_info->chan_byte_size == 4 && + (fetch_component == 1 || ctx->options->chip_class != GFX8 || + !ctx->options->robust_buffer_access2); unsigned fetch_dfmt = V_008F0C_BUF_DATA_FORMAT_INVALID; if (!use_mubuf) { fetch_dfmt = get_fetch_data_format(ctx, vtx_info, fetch_offset, attrib_stride, &fetch_component); diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 3819ee6c377..17e3ddd5f1d 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2672,6 +2672,7 @@ VkResult radv_CreateDevice( bool keep_shader_info = false; bool robust_buffer_access = false; + bool robust_buffer_access2 = false; bool overallocation_disallowed = false; bool custom_border_colors = false; @@ -2710,6 +2711,12 @@ VkResult radv_CreateDevice( custom_border_colors = border_color_features->customBorderColors; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT: { + const VkPhysicalDeviceRobustness2FeaturesEXT *features = (const void *)ext; + if (features->robustBufferAccess2) + robust_buffer_access2 = true; + break; + } default: break; } @@ -2753,7 +2760,8 @@ VkResult radv_CreateDevice( device->enabled_extensions.EXT_buffer_device_address || device->enabled_extensions.KHR_buffer_device_address; - device->robust_buffer_access = robust_buffer_access; + device->robust_buffer_access = robust_buffer_access || robust_buffer_access2; + device->robust_buffer_access2 = robust_buffer_access2; mtx_init(&device->shader_slab_mutex, mtx_plain); list_inithead(&device->shader_slabs); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 82788fafbd5..3d9986dee78 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -822,8 +822,9 @@ struct radv_device { struct radv_device_extension_table enabled_extensions; struct radv_device_dispatch_table dispatch; - /* Whether the app has enabled the robustBufferAccess feature. */ + /* Whether the app has enabled the robustBufferAccess/robustBufferAccess2 features. */ bool robust_buffer_access; + bool robust_buffer_access2; /* Whether the driver uses a global BO list. */ bool use_global_bo_list; diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 67b99e8bed3..7dab62862ce 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -1398,6 +1398,7 @@ radv_shader_variant_compile(struct radv_device *device, options.explicit_scratch_args = !radv_use_llvm_for_stage(device, stage); options.robust_buffer_access = device->robust_buffer_access; + options.robust_buffer_access2 = device->robust_buffer_access2; options.disable_optimizations = disable_optimizations; return shader_variant_compile(device, module, shaders, shader_count, stage, info, diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index 2eb3ba4e64e..6b69a2d9639 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -135,6 +135,7 @@ struct radv_nir_compiler_options { bool explicit_scratch_args; bool clamp_shadow_reference; bool robust_buffer_access; + bool robust_buffer_access2; bool dump_shader; bool dump_preoptir; bool record_ir;