From: Jason Ekstrand Date: Fri, 28 Aug 2020 20:42:45 +0000 (-0500) Subject: anv: Set alignments on UBO/SSBO root derefs X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=commitdiff_plain;h=21fbffc5425e7ee2912285737ef68398bb156732 anv: Set alignments on UBO/SSBO root derefs This doesn't really do anything for us today. One day, I suppose we could use it to do something with wide loads with non-uniform offsets. The big reason to do this is to get better testing to make sure that NIR doesn't blow up on the deref paths. Part-of: --- diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 789913d57b8..7cf8667420f 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1587,7 +1587,7 @@ void anv_GetPhysicalDeviceProperties( */ .minTexelBufferOffsetAlignment = 16, .minUniformBufferOffsetAlignment = ANV_UBO_ALIGNMENT, - .minStorageBufferOffsetAlignment = 4, + .minStorageBufferOffsetAlignment = ANV_SSBO_ALIGNMENT, .minTexelOffset = -8, .maxTexelOffset = 7, .minTexelGatherOffset = -32, diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c index 882d7cb6456..4884ba325cd 100644 --- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c +++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c @@ -552,6 +552,31 @@ lower_load_vulkan_descriptor(nir_intrinsic_instr *intrin, const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin); + assert(intrin->dest.is_ssa); + nir_foreach_use(src, &intrin->dest.ssa) { + if (src->parent_instr->type != nir_instr_type_deref) + continue; + + nir_deref_instr *cast = nir_instr_as_deref(src->parent_instr); + assert(cast->deref_type == nir_deref_type_cast); + switch (desc_type) { + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + cast->cast.align_mul = ANV_UBO_ALIGNMENT; + cast->cast.align_offset = 0; + break; + + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: + cast->cast.align_mul = ANV_SSBO_ALIGNMENT; + cast->cast.align_offset = 0; + break; + + default: + break; + } + } + assert(intrin->src[0].is_ssa); nir_ssa_def *index = intrin->src[0].ssa; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 4787243ee79..48283435a21 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -181,6 +181,7 @@ struct gen_perf_query_result; * GEM object. */ #define ANV_UBO_ALIGNMENT 64 +#define ANV_SSBO_ALIGNMENT 4 #define ANV_SSBO_BOUNDS_CHECK_ALIGNMENT 4 #define MAX_VIEWS_FOR_PRIMITIVE_REPLICATION 16